blob: 0484e9bb0d9855c30d969c245a3710ddc23421d5 (
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
27
|
import asyncio
import os
import telegram
import yaml
with open(os.path.join('configs', 'telegram.yml'), 'r') as file:
config = yaml.safe_load(file.read())
bot = telegram.Bot(config['token'])
def send_message(text):
asyncio.run(async_send_message(text))
async def async_send_message(text):
async with bot:
await bot.send_message(text=text, chat_id=config['chat_id'])
async def init_bot():
async with bot:
print(await bot.get_me())
asyncio.run(init_bot())
|