-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.py
37 lines (29 loc) · 1.13 KB
/
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
import asyncio
import logging
import os
from aiogram import types
from aiogram.contrib.middlewares.logging import LoggingMiddleware
from func.config import bot, dp
from handlers.help_handler import help_handler
from handlers.media_handler import media_handler
from handlers.start_handler import start_handler
logging.basicConfig(level=logging.INFO)
async def main():
if os.path.exists('media') == False:
os.mkdir('media')
@dp.message_handler(commands=["start"])
async def wrapper(message: types.Message):
await start_handler(message, bot)
@dp.message_handler(commands=["help"])
async def wrapper(message: types.Message):
await help_handler(message, bot)
@dp.message_handler(content_types=[types.ContentType.PHOTO, types.ContentType.VIDEO, types.ContentType.ANIMATION])
async def wrapper(message: types.Message):
await media_handler(message, bot)
if __name__ == "__main__":
try:
asyncio.run(main())
dp.middleware.setup(LoggingMiddleware())
asyncio.run(dp.start_polling())
except KeyboardInterrupt:
logging.info("Боты остановлены")