33 lines
746 B
Python
33 lines
746 B
Python
import asyncio
|
|
|
|
import typer
|
|
|
|
from birthday_pool_bot.repositories import RepositoriesContainer
|
|
from .fabric import get_telegram_bot_service
|
|
from .settings import TelegramBotSettings
|
|
|
|
|
|
def callback(ctx: typer.Context):
|
|
ctx.obj["settings"] = ctx.obj["settings"].telegram_bot
|
|
|
|
|
|
def run(ctx: typer.Context):
|
|
settings: TelegramBotSettings = ctx.obj["settings"]
|
|
repositories_container: RepositoriesContainer = ctx.obj["repositories_container"]
|
|
|
|
service = get_telegram_bot_service(
|
|
settings=settings,
|
|
repositories_container=repositories_container,
|
|
)
|
|
|
|
asyncio.run(service.run())
|
|
|
|
|
|
def get_cli() -> typer.Typer:
|
|
cli = typer.Typer()
|
|
|
|
cli.callback()(callback)
|
|
cli.command(name="run")(run)
|
|
|
|
return cli
|