fix: use ApplicationBuilder to avoid PTBUserWarning

This commit is contained in:
Macintxsh 2025-05-21 03:38:25 +03:00
parent 6141d674a9
commit 10c2d58efb
Signed by: mctaylors
GPG key ID: 4EEF4F949A266EE2

12
main.py
View file

@ -1,7 +1,7 @@
import logging
import os
from telegram.ext import Application, CommandHandler, InlineQueryHandler
from telegram.ext import CommandHandler, InlineQueryHandler, ApplicationBuilder
from config import *
@ -15,28 +15,32 @@ logger = logging.getLogger(__name__)
def main() -> None:
application = Application.builder().token(get_token()).build()
application = ApplicationBuilder().token(get_token()).build()
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))
application.add_handler(CommandHandler("info", commands.info_command))
from inline_query import inline_query
application.add_handler(InlineQueryHandler(inline_query))
application.run_polling(allowed_updates=commands.Update.ALL_TYPES)
def get_token() -> None:
def get_token() -> str:
if os.getenv("BOT_TOKEN") is not None:
return os.getenv("BOT_TOKEN")
if general.token != "":
return general.token
print("Set BOT_TOKEN environment variable or use General.Token in config.ini to set bot token.")
print(
"Set BOT_TOKEN environment variable or use General.Token in config.ini to set bot token."
)
exit(1)