refactor: move imports in main.py

this change allows to avoid multiple and very specific imports in other python files

Signed-off-by: mctaylors <cantsendmails@mctaylors.ru>
This commit is contained in:
Macintxsh 2025-03-26 14:28:15 +03:00
parent d363fa9afd
commit 4fbdb198ae
Signed by: mctaylors
GPG key ID: 4EEF4F949A266EE2
3 changed files with 15 additions and 17 deletions

14
main.py
View file

@ -5,9 +5,6 @@ import os
import requests
from telegram.ext import Application, CommandHandler, InlineQueryHandler
from commands import *
from inline_query import inline_query
logging.basicConfig(
format="%(asctime)s - %(name)s - %(levelname)s - %(message)s", level=logging.INFO
)
@ -22,17 +19,20 @@ config.read("config.ini")
hostname = config.get('App', 'HostName')
hostname = hostname if hostname != "" else config.get('App', 'Host')
def main() -> None:
validate_config()
application = Application.builder().token(get_token()).build()
application.add_handler(CommandHandler("start", start_command))
application.add_handler(CommandHandler("help", help_command))
application.add_handler(CommandHandler("about", about_command))
import commands
application.add_handler(CommandHandler("start", commands.start_command))
application.add_handler(CommandHandler("help", commands.help_command))
application.add_handler(CommandHandler("about", commands.about_command))
from inline_query import inline_query
application.add_handler(InlineQueryHandler(inline_query))
application.run_polling(allowed_updates=Update.ALL_TYPES)
application.run_polling(allowed_updates=commands.Update.ALL_TYPES)
def validate_config() -> None: