-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathliker.py
46 lines (35 loc) · 1.17 KB
/
liker.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
from abc import ABC, abstractmethod
import click
from uyaml.loader import YamlFromPath
from badoo.connections.web import Browser
from badoo.services import Liker, BadooLiker
from badoo.setup import Setup
class _Executor(ABC):
"""Abstract executor interface."""
@abstractmethod
def run(self) -> None:
"""Runs executor."""
pass
class _LikerExecutor(_Executor):
"""Represents liker executor item."""
def __init__(self, setup: Setup) -> None:
self._message_to_send: str = setup.badoo().intro_message()
self._attempts: int = setup.badoo().likes()
self._liker: Liker = BadooLiker(
Browser(setup.browser()), setup.badoo().credentials()
)
def run(self) -> None:
self._liker.start(self._attempts, self._message_to_send)
@click.command()
@click.option(
"--config",
"-c",
help="Setup badoo config file (e.g `setup.yaml`)",
default="setup.yaml",
)
def _run_badoo_liker(config: str) -> None:
"""The program allows to run badoo liker service."""
executor: _Executor = _LikerExecutor(Setup(YamlFromPath(config)))
executor.run()
if __name__ == "__main__":
_run_badoo_liker()