-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
47 lines (31 loc) · 993 Bytes
/
main.py
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import asyncio
import logging
import os
from aiogram import Dispatcher, Bot, F
from aiogram.fsm.storage.memory import MemoryStorage
from bot import middleware
from bot.handlers import commands, text, inline
from bot.run import Environment
Environment().load_env()
async def run():
logging.basicConfig(level=logging.INFO)
BOT_TOKEN = os.getenv("BOT_TOKEN")
assert BOT_TOKEN
bot = Bot(BOT_TOKEN)
storage = MemoryStorage()
dp = Dispatcher(storage=storage)
dp["dp"] = dp
dp["storage"] = storage
dp["bot"] = bot
dp["bot_id"] = bot.id
dp.message.filter(F.chat.type == "private")
dp.include_router(commands.router)
dp.include_router(text.router)
dp.include_router(inline.router)
dp.message.middleware(middleware.AntiFloodMiddleware())
try:
await dp.start_polling(bot, allowed_updates=dp.resolve_used_update_types())
finally:
await bot.session.close()
if __name__ == "__main__":
asyncio.run(run())