blob: 649471dcc40334c1354254b947185cc810f8e45e (
plain)
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
|
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())
|