import asyncio import os import telegram import yaml class Telegram: def __init__(self, config: dict): self.config: dict = config self.bot = telegram.Bot(config['token']) asyncio.run(self.init_bot()) def send_message(self, text): asyncio.run(self.async_send_message(text)) async def async_send_message(self, text): async with self.bot: await self.bot.send_message(text=text, chat_id=self.config['chat_id']) async def init_bot(self): async with self.bot: print(await self.bot.get_me())