-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun_bot.py
34 lines (29 loc) · 954 Bytes
/
run_bot.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
import asyncio
import logging
from app import create_app
from app.bot.bot import CourseBot
# Настройка логирования
logging.basicConfig(
level=logging.INFO,
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s'
)
logger = logging.getLogger(__name__)
async def main():
"""Основная функция запуска бота"""
try:
# Создаем Flask приложение
app = create_app()
# Создаем и запускаем бота
bot = CourseBot(app)
logger.info("Bot instance created successfully")
await bot.start_polling()
except Exception as e:
logger.error(f"Failed to start bot: {e}")
raise
if __name__ == '__main__':
try:
asyncio.run(main())
except KeyboardInterrupt:
logger.info("Bot stopped by user")
except Exception as e:
logger.error(f"Critical error in bot execution: {e}")