forked from vmilfe/gift-parser
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
38 lines (26 loc) · 810 Bytes
/
app.py
File metadata and controls
38 lines (26 loc) · 810 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
33
34
35
36
37
38
import asyncio
import os
from structlog import get_logger
from aiogram import Bot, Dispatcher
from aiogram.client.default import DefaultBotProperties
from src.handlers import router
from src.gifts import get_client
from config import BOT_TOKEN
async def try_load_session():
if 'main.session' not in os.listdir('session'):
await get_client()
async def startup_info(bot: Bot):
logger = get_logger()
me = await bot.get_me()
await logger.ainfo(f'start bot: @{me.username}')
async def main():
bot = Bot(token=BOT_TOKEN, default=DefaultBotProperties(
parse_mode='html'
))
dp = Dispatcher()
dp.include_router(router)
await try_load_session()
await startup_info(bot)
await dp.start_polling(bot)
if __name__ == '__main__':
asyncio.run(main())