kopia lustrzana https://github.com/J-Rios/TLG_JoinCaptchaBot
Some mypy hints
rodzic
5d03779db2
commit
62acab8d8a
|
@ -20,6 +20,7 @@ Version:
|
||||||
|
|
||||||
from os import path as os_path
|
from os import path as os_path
|
||||||
from os import getenv as os_getenv
|
from os import getenv as os_getenv
|
||||||
|
from typing import Any
|
||||||
from settings import SETTINGS
|
from settings import SETTINGS
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
@ -346,7 +347,7 @@ TEXT: dict = {
|
||||||
}
|
}
|
||||||
|
|
||||||
# Bot Commands
|
# Bot Commands
|
||||||
CMD = {
|
CMD : dict[str, Any] = {
|
||||||
"START": { "KEY": "start" },
|
"START": { "KEY": "start" },
|
||||||
"HELP": { "KEY": "help" },
|
"HELP": { "KEY": "help" },
|
||||||
"COMMANDS": { "KEY": "commands" },
|
"COMMANDS": { "KEY": "commands" },
|
||||||
|
|
|
@ -946,6 +946,8 @@ async def chat_bot_status_change(
|
||||||
bot = context.bot
|
bot = context.bot
|
||||||
chat = update.effective_chat
|
chat = update.effective_chat
|
||||||
caused_by_user = update.effective_user
|
caused_by_user = update.effective_user
|
||||||
|
if chat is None:
|
||||||
|
return
|
||||||
# Private Chat
|
# Private Chat
|
||||||
if chat.type == Chat.PRIVATE:
|
if chat.type == Chat.PRIVATE:
|
||||||
return
|
return
|
||||||
|
@ -2612,7 +2614,7 @@ async def cmd_captcha_poll(update: Update, context: ContextTypes.DEFAULT_TYPE):
|
||||||
CONST["MAX_POLL_OPTION_LENGTH"],
|
CONST["MAX_POLL_OPTION_LENGTH"],
|
||||||
CONST["MAX_POLL_OPTIONS"])
|
CONST["MAX_POLL_OPTIONS"])
|
||||||
# Check if no argument was provided with the command
|
# Check if no argument was provided with the command
|
||||||
if len(args) < 2:
|
if (args is None) or (len(args) < 2):
|
||||||
await tlg_send_msg_type_chat(
|
await tlg_send_msg_type_chat(
|
||||||
bot, chat_type, chat_id, text_cmd_usage,
|
bot, chat_type, chat_id, text_cmd_usage,
|
||||||
topic_id=tlg_get_msg_topic(update_msg))
|
topic_id=tlg_get_msg_topic(update_msg))
|
||||||
|
@ -3944,12 +3946,14 @@ async def tlg_app_exit(app: Application) -> None:
|
||||||
# Request to exit and wait to end coroutines
|
# Request to exit and wait to end coroutines
|
||||||
logger.info("Bot stopped. Releasing resources...")
|
logger.info("Bot stopped. Releasing resources...")
|
||||||
Global.force_exit = True
|
Global.force_exit = True
|
||||||
if not Global.async_captcha_timeout.done():
|
if Global.async_captcha_timeout is not None:
|
||||||
logger.info("Waiting end of coroutine: captcha_timeout()")
|
if not Global.async_captcha_timeout.done():
|
||||||
await Global.async_captcha_timeout
|
logger.info("Waiting end of coroutine: captcha_timeout()")
|
||||||
if not Global.async_auto_delete_messages.done():
|
await Global.async_captcha_timeout
|
||||||
logger.info("Waiting end of coroutine: async_auto_delete_messages()")
|
if Global.async_auto_delete_messages is not None:
|
||||||
await Global.async_auto_delete_messages
|
if not Global.async_auto_delete_messages.done():
|
||||||
|
logger.info("Waiting end of coroutine: async_auto_delete_messages()")
|
||||||
|
await Global.async_auto_delete_messages
|
||||||
# Save current session data
|
# Save current session data
|
||||||
save_session()
|
save_session()
|
||||||
# Close the program
|
# Close the program
|
||||||
|
|
Ładowanie…
Reference in New Issue