mirror of
https://github.com/openmax-server/server.git
synced 2026-05-23 03:51:43 +03:00
first commit
This commit is contained in:
28
src/telegrambot/controller.py
Normal file
28
src/telegrambot/controller.py
Normal file
@@ -0,0 +1,28 @@
|
||||
import asyncio
|
||||
from telegrambot.bot import TelegramBot
|
||||
from classes.controllerbase import ControllerBase
|
||||
from common.config import ServerConfig
|
||||
|
||||
class TelegramBotController(ControllerBase):
|
||||
def __init__(self):
|
||||
self.config = ServerConfig()
|
||||
self.bot = None
|
||||
|
||||
def launch(self, api):
|
||||
async def _start_all():
|
||||
await asyncio.gather(
|
||||
self.bot.start()
|
||||
)
|
||||
|
||||
# Инициализируем бота
|
||||
self.bot = TelegramBot(
|
||||
token=self.config.telegram_bot_token,
|
||||
enabled=self.config.telegram_bot_enabled,
|
||||
db_pool=api['db'],
|
||||
whitelist_ids=self.config.telegram_whitelist_ids
|
||||
)
|
||||
|
||||
return _start_all()
|
||||
|
||||
async def send_code(self, chat_id, phone, code):
|
||||
await self.bot.send_auth_code(chat_id, phone, code)
|
||||
Reference in New Issue
Block a user