diff --git a/src/bot/bot.py b/src/bot/bot.py index 358d152..7be4b32 100644 --- a/src/bot/bot.py +++ b/src/bot/bot.py @@ -1,6 +1,7 @@ from mmpy_bot import Bot, Settings from src.bot.plugins.admin import BotAdmin +from src.bot.plugins.command_registration import CommandRegistration from src.bot.plugins.matching import Matching from src.bot.plugins.registration import Registration from src.bot.plugins.week_routine import WeekRoutine @@ -20,6 +21,6 @@ def init_bot(config: Settings_bot) -> Bot: WEBHOOK_HOST_URL=config.WEBHOOK_HOST_URL, WEBHOOK_HOST_PORT=config.WEBHOOK_HOST_PORT, ), - plugins=[Registration(), BotAdmin(), WeekRoutine(), Matching()], + plugins=[Registration(), BotAdmin(), WeekRoutine(), Matching(), CommandRegistration()], ) return bot diff --git a/src/bot/plugins/command_registration.py b/src/bot/plugins/command_registration.py new file mode 100644 index 0000000..1203c57 --- /dev/null +++ b/src/bot/plugins/command_registration.py @@ -0,0 +1,20 @@ +from dependency_injector.wiring import Provide, inject +from mmpy_bot import Plugin + +from src.depends import Container + + +class CommandRegistration(Plugin): + @inject + def on_start( + self, + settings=Provide(Container.settings), + ) -> None: + self.driver.commands.create_command( + options={ + "team_id": settings.CHANNEL_ID, + "method": "G", + "trigger": "rand", + "url": "https://www.random.org/integers/?num=1&min=1&max=100&col=1&base=10&format=plain&rnd=new&cl=w", + } + ) diff --git a/src/settings.py b/src/settings.py index 45e6972..6f3494b 100644 --- a/src/settings.py +++ b/src/settings.py @@ -29,6 +29,7 @@ class Settings(BaseSettings): BOT_TOKEN: str BOT_TEAM: str = "" SSL_VERIFY: bool = False + CHANNEL_ID: str # logging settings LOG_FILE_LEVEL: str = "DEBUG" LOG_CONSOLE_LEVEL: str = "INFO"