fix: use ApplicationBuilder to avoid PTBUserWarning
This commit is contained in:
parent
6141d674a9
commit
10c2d58efb
1 changed files with 8 additions and 4 deletions
12
main.py
12
main.py
|
@ -1,7 +1,7 @@
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
|
|
||||||
from telegram.ext import Application, CommandHandler, InlineQueryHandler
|
from telegram.ext import CommandHandler, InlineQueryHandler, ApplicationBuilder
|
||||||
|
|
||||||
from config import *
|
from config import *
|
||||||
|
|
||||||
|
@ -15,28 +15,32 @@ logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
def main() -> None:
|
def main() -> None:
|
||||||
application = Application.builder().token(get_token()).build()
|
application = ApplicationBuilder().token(get_token()).build()
|
||||||
|
|
||||||
import commands
|
import commands
|
||||||
|
|
||||||
application.add_handler(CommandHandler("start", commands.start_command))
|
application.add_handler(CommandHandler("start", commands.start_command))
|
||||||
application.add_handler(CommandHandler("help", commands.help_command))
|
application.add_handler(CommandHandler("help", commands.help_command))
|
||||||
application.add_handler(CommandHandler("about", commands.about_command))
|
application.add_handler(CommandHandler("about", commands.about_command))
|
||||||
application.add_handler(CommandHandler("info", commands.info_command))
|
application.add_handler(CommandHandler("info", commands.info_command))
|
||||||
|
|
||||||
from inline_query import inline_query
|
from inline_query import inline_query
|
||||||
|
|
||||||
application.add_handler(InlineQueryHandler(inline_query))
|
application.add_handler(InlineQueryHandler(inline_query))
|
||||||
|
|
||||||
application.run_polling(allowed_updates=commands.Update.ALL_TYPES)
|
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:
|
if os.getenv("BOT_TOKEN") is not None:
|
||||||
return os.getenv("BOT_TOKEN")
|
return os.getenv("BOT_TOKEN")
|
||||||
|
|
||||||
if general.token != "":
|
if general.token != "":
|
||||||
return 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)
|
exit(1)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue