-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbot.py
More file actions
32 lines (20 loc) · 662 Bytes
/
bot.py
File metadata and controls
32 lines (20 loc) · 662 Bytes
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
28
29
30
31
32
import tomllib
import asyncio
from aiogram import Bot, Dispatcher
from aiogram.filters import Command, CommandStart
from aiogram.types import Message
with open("secrets.toml", "rb") as f:
secrets = tomllib.load(f)
TOKEN = secrets["tg_token"]
dp = Dispatcher()
@dp.message(CommandStart())
async def command_start_handler(message: Message) -> None:
await message.answer("Hello! I'm a bot created with aiogram.")
@dp.message()
async def message_handler(message: Message) -> None:
print(message)
async def main() -> None:
bot = Bot(token=TOKEN)
await dp.start_polling(bot)
if __name__ == "__main__":
asyncio.run(main())