init, .gitignore
This commit is contained in:
commit
32aac89fdf
164 files changed
+18090
No files matched your search
@@ -0,0 +1,42 @@
|
||||
import logging
|
||||
from telegram import Update
|
||||
from telegram.ext import Application, CommandHandler
|
||||
import config
|
||||
from handlers import start, help_command, check_homework, check_webinar, error_handler
|
||||
|
||||
# Настройка логирования
|
||||
logging.basicConfig(
|
||||
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
|
||||
level=logging.INFO
|
||||
)
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def main():
|
||||
"""Запуск бота"""
|
||||
if not config.BOT_TOKEN:
|
||||
logger.error("LESSONS_BOT_TOKEN not set!")
|
||||
return
|
||||
|
||||
# Создаем приложение
|
||||
application = Application.builder().token(config.BOT_TOKEN).build()
|
||||
|
||||
# Регистрируем обработчики команд
|
||||
application.add_handler(CommandHandler("start", start))
|
||||
application.add_handler(CommandHandler("help", help_command))
|
||||
application.add_handler(CommandHandler("check", check_homework))
|
||||
application.add_handler(CommandHandler("webinar", check_webinar))
|
||||
|
||||
# Регистрируем обработчик ошибок
|
||||
application.add_error_handler(error_handler)
|
||||
|
||||
# Запускаем бота
|
||||
logger.info("Lessons Bot started!")
|
||||
logger.info(f"PHPSESSID Bot URL: {config.PHPSESSID_BOT_URL}")
|
||||
logger.info(f"n8n Webhook URL: {config.N8N_WEBHOOK_URL}")
|
||||
|
||||
application.run_polling(allowed_updates=Update.ALL_TYPES)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
Reference in new issue
Block a user