kopia lustrzana https://github.com/J-Rios/TLG_JoinCaptchaBot
				
				
				
			Fix code style according to flake8
							rodzic
							
								
									62acab8d8a
								
							
						
					
					
						commit
						c0d99b6be2
					
				| 
						 | 
					@ -16,15 +16,18 @@ Version:
 | 
				
			||||||
'''
 | 
					'''
 | 
				
			||||||
 | 
					
 | 
				
			||||||
###############################################################################
 | 
					###############################################################################
 | 
				
			||||||
### Imported modules ###
 | 
					# Imported modules
 | 
				
			||||||
 | 
					###############################################################################
 | 
				
			||||||
 | 
					
 | 
				
			||||||
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 typing import Any
 | 
				
			||||||
from settings import SETTINGS
 | 
					from settings import SETTINGS
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					###############################################################################
 | 
				
			||||||
 | 
					# Constants
 | 
				
			||||||
###############################################################################
 | 
					###############################################################################
 | 
				
			||||||
### Constants ###
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Actual constants.py full path directory name
 | 
					# Actual constants.py full path directory name
 | 
				
			||||||
SCRIPT_PATH = os_path.dirname(os_path.realpath(__file__))
 | 
					SCRIPT_PATH = os_path.dirname(os_path.realpath(__file__))
 | 
				
			||||||
| 
						 | 
					@ -33,174 +36,174 @@ SCRIPT_PATH = os_path.dirname(os_path.realpath(__file__))
 | 
				
			||||||
CONST = {
 | 
					CONST = {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # Bot Public or Private
 | 
					    # Bot Public or Private
 | 
				
			||||||
    "BOT_PRIVATE": \
 | 
					    "BOT_PRIVATE":
 | 
				
			||||||
        bool(int(os_getenv("CAPTCHABOT_PRIVATE", \
 | 
					        bool(int(os_getenv("CAPTCHABOT_PRIVATE",
 | 
				
			||||||
                           SETTINGS["CAPTCHABOT_PRIVATE"]))),
 | 
					                           SETTINGS["CAPTCHABOT_PRIVATE"]))),
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # Bot Token (get it from @BotFather)
 | 
					    # Bot Token (get it from @BotFather)
 | 
				
			||||||
    "TOKEN": \
 | 
					    "TOKEN":
 | 
				
			||||||
        os_getenv("CAPTCHABOT_TOKEN", SETTINGS["CAPTCHABOT_TOKEN"]),
 | 
					        os_getenv("CAPTCHABOT_TOKEN", SETTINGS["CAPTCHABOT_TOKEN"]),
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # Bot Owner (i.e. "@JoseTLG" or "123456789")
 | 
					    # Bot Owner (i.e. "@JoseTLG" or "123456789")
 | 
				
			||||||
    "BOT_OWNER": \
 | 
					    "BOT_OWNER":
 | 
				
			||||||
        os_getenv("CAPTCHABOT_OWNER", SETTINGS["CAPTCHABOT_OWNER"]),
 | 
					        os_getenv("CAPTCHABOT_OWNER", SETTINGS["CAPTCHABOT_OWNER"]),
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # Bot Webhook Host addres (keep in None for Polling or set to a
 | 
					    # Bot Webhook Host addres (keep in None for Polling or set to a
 | 
				
			||||||
    # valid address for Webhook)
 | 
					    # valid address for Webhook)
 | 
				
			||||||
    "WEBHOOK_HOST": \
 | 
					    "WEBHOOK_HOST":
 | 
				
			||||||
        os_getenv("CAPTCHABOT_WEBHOOK_HOST", \
 | 
					        os_getenv("CAPTCHABOT_WEBHOOK_HOST",
 | 
				
			||||||
                  SETTINGS["CAPTCHABOT_WEBHOOK_HOST"]),
 | 
					                  SETTINGS["CAPTCHABOT_WEBHOOK_HOST"]),
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # Bot Webhook Host Port (this is not used if WEBHOOK_HOST is None)
 | 
					    # Bot Webhook Host Port (this is not used if WEBHOOK_HOST is None)
 | 
				
			||||||
    "WEBHOOK_PORT": \
 | 
					    "WEBHOOK_PORT":
 | 
				
			||||||
        int(os_getenv("CAPTCHABOT_WEBHOOK_PORT", \
 | 
					        int(os_getenv("CAPTCHABOT_WEBHOOK_PORT",
 | 
				
			||||||
                      SETTINGS["CAPTCHABOT_WEBHOOK_PORT"])),
 | 
					                      SETTINGS["CAPTCHABOT_WEBHOOK_PORT"])),
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # Bot Webhook Certificate file path (this is not used if
 | 
					    # Bot Webhook Certificate file path (this is not used if
 | 
				
			||||||
    # WEBHOOK_HOST is None)
 | 
					    # WEBHOOK_HOST is None)
 | 
				
			||||||
    "WEBHOOK_CERT": \
 | 
					    "WEBHOOK_CERT":
 | 
				
			||||||
        os_getenv("CAPTCHABOT_WEBHOOK_CERT", \
 | 
					        os_getenv("CAPTCHABOT_WEBHOOK_CERT",
 | 
				
			||||||
                  SETTINGS["CAPTCHABOT_WEBHOOK_CERT"]),
 | 
					                  SETTINGS["CAPTCHABOT_WEBHOOK_CERT"]),
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # Bot Webhook Certificate private key file path (this is not used
 | 
					    # Bot Webhook Certificate private key file path (this is not used
 | 
				
			||||||
    # if WEBHOOK_HOST is None)
 | 
					    # if WEBHOOK_HOST is None)
 | 
				
			||||||
    "WEBHOOK_CERT_PRIV_KEY": \
 | 
					    "WEBHOOK_CERT_PRIV_KEY":
 | 
				
			||||||
        os_getenv("CAPTCHABOT_WEBHOOK_CERT_PRIV_KEY", \
 | 
					        os_getenv("CAPTCHABOT_WEBHOOK_CERT_PRIV_KEY",
 | 
				
			||||||
                  SETTINGS["CAPTCHABOT_WEBHOOK_CERT_PRIV_KEY"]),
 | 
					                  SETTINGS["CAPTCHABOT_WEBHOOK_CERT_PRIV_KEY"]),
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # Bot Webhook Secret Token to verify request from Telegram Server
 | 
					    # Bot Webhook Secret Token to verify request from Telegram Server
 | 
				
			||||||
    # (don't use the Bot Token, for security reason it must be other)
 | 
					    # (don't use the Bot Token, for security reason it must be other)
 | 
				
			||||||
    "WEBHOOK_SECRET_TOKEN": \
 | 
					    "WEBHOOK_SECRET_TOKEN":
 | 
				
			||||||
        os_getenv("CAPTCHABOT_WEBHOOK_SECRET_TOKEN", \
 | 
					        os_getenv("CAPTCHABOT_WEBHOOK_SECRET_TOKEN",
 | 
				
			||||||
                  SETTINGS["CAPTCHABOT_WEBHOOK_SECRET_TOKEN"]),
 | 
					                  SETTINGS["CAPTCHABOT_WEBHOOK_SECRET_TOKEN"]),
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # Chats directory path
 | 
					    # Chats directory path
 | 
				
			||||||
    "CHATS_DIR": \
 | 
					    "CHATS_DIR":
 | 
				
			||||||
        os_getenv("CAPTCHABOT_CHATS_DIR", SETTINGS["CAPTCHABOT_CHATS_DIR"]),
 | 
					        os_getenv("CAPTCHABOT_CHATS_DIR", SETTINGS["CAPTCHABOT_CHATS_DIR"]),
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # Directory where create/generate temporary captchas
 | 
					    # Directory where create/generate temporary captchas
 | 
				
			||||||
    "CAPTCHAS_DIR": \
 | 
					    "CAPTCHAS_DIR":
 | 
				
			||||||
        os_getenv("CAPTCHABOT_CAPTCHAS_DIR", \
 | 
					        os_getenv("CAPTCHABOT_CAPTCHAS_DIR",
 | 
				
			||||||
                  SETTINGS["CAPTCHABOT_CAPTCHAS_DIR"]),
 | 
					                  SETTINGS["CAPTCHABOT_CAPTCHAS_DIR"]),
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # Global allowed users file path (i.e. to allow blind users)
 | 
					    # Global allowed users file path (i.e. to allow blind users)
 | 
				
			||||||
    "F_ALLOWED_USERS": \
 | 
					    "F_ALLOWED_USERS":
 | 
				
			||||||
        os_getenv("CAPTCHABOT_F_ALLOWED_USERS", \
 | 
					        os_getenv("CAPTCHABOT_F_ALLOWED_USERS",
 | 
				
			||||||
                  SETTINGS["CAPTCHABOT_F_ALLOWED_USERS"]),
 | 
					                  SETTINGS["CAPTCHABOT_F_ALLOWED_USERS"]),
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # Allowed groups to use the Bot when it is Private
 | 
					    # Allowed groups to use the Bot when it is Private
 | 
				
			||||||
    "F_ALLOWED_GROUPS": \
 | 
					    "F_ALLOWED_GROUPS":
 | 
				
			||||||
        os_getenv("CAPTCHABOT_F_ALLOWED_GROUPS", \
 | 
					        os_getenv("CAPTCHABOT_F_ALLOWED_GROUPS",
 | 
				
			||||||
                  SETTINGS["CAPTCHABOT_F_ALLOWED_GROUPS"]),
 | 
					                  SETTINGS["CAPTCHABOT_F_ALLOWED_GROUPS"]),
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # Blocked groups to deny Bot usage (i.e. bad groups that misuse Bot
 | 
					    # Blocked groups to deny Bot usage (i.e. bad groups that misuse Bot
 | 
				
			||||||
    # and cause overload)
 | 
					    # and cause overload)
 | 
				
			||||||
    "F_BAN_GROUPS": \
 | 
					    "F_BAN_GROUPS":
 | 
				
			||||||
        os_getenv("CAPTCHABOT_F_BAN_GROUPS", \
 | 
					        os_getenv("CAPTCHABOT_F_BAN_GROUPS",
 | 
				
			||||||
                  SETTINGS["CAPTCHABOT_F_BAN_GROUPS"]),
 | 
					                  SETTINGS["CAPTCHABOT_F_BAN_GROUPS"]),
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # Initial enable/disable status at Bot start
 | 
					    # Initial enable/disable status at Bot start
 | 
				
			||||||
    "INIT_ENABLE": \
 | 
					    "INIT_ENABLE":
 | 
				
			||||||
        bool(int(os_getenv("CAPTCHABOT_INIT_ENABLE", \
 | 
					        bool(int(os_getenv("CAPTCHABOT_INIT_ENABLE",
 | 
				
			||||||
                           SETTINGS["CAPTCHABOT_INIT_ENABLE"]))),
 | 
					                           SETTINGS["CAPTCHABOT_INIT_ENABLE"]))),
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # Initial users send URLs enable/disable at Bot start
 | 
					    # Initial users send URLs enable/disable at Bot start
 | 
				
			||||||
    "INIT_URL_ENABLE": \
 | 
					    "INIT_URL_ENABLE":
 | 
				
			||||||
        bool(int(os_getenv("CAPTCHABOT_INIT_URL_ENABLE", \
 | 
					        bool(int(os_getenv("CAPTCHABOT_INIT_URL_ENABLE",
 | 
				
			||||||
                           SETTINGS["CAPTCHABOT_INIT_URL_ENABLE"]))),
 | 
					                           SETTINGS["CAPTCHABOT_INIT_URL_ENABLE"]))),
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # Initial config regarding remove all messages sent by a user kicked
 | 
					    # Initial config regarding remove all messages sent by a user kicked
 | 
				
			||||||
    "INIT_RM_ALL_MSG": \
 | 
					    "INIT_RM_ALL_MSG":
 | 
				
			||||||
        bool(int(os_getenv("CAPTCHABOT_INIT_RM_ALL_MSG", \
 | 
					        bool(int(os_getenv("CAPTCHABOT_INIT_RM_ALL_MSG",
 | 
				
			||||||
                           SETTINGS["CAPTCHABOT_INIT_RM_ALL_MSG"]))),
 | 
					                           SETTINGS["CAPTCHABOT_INIT_RM_ALL_MSG"]))),
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # Initial captcha solve time
 | 
					    # Initial captcha solve time
 | 
				
			||||||
    "INIT_CAPTCHA_TIME": \
 | 
					    "INIT_CAPTCHA_TIME":
 | 
				
			||||||
        int(os_getenv("CAPTCHABOT_INIT_CAPTCHA_TIME_MIN", \
 | 
					        int(os_getenv("CAPTCHABOT_INIT_CAPTCHA_TIME_MIN",
 | 
				
			||||||
                      SETTINGS["CAPTCHABOT_INIT_CAPTCHA_TIME_MIN"])) * 60,
 | 
					                      SETTINGS["CAPTCHABOT_INIT_CAPTCHA_TIME_MIN"])) * 60,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # Initial captcha difficult level
 | 
					    # Initial captcha difficult level
 | 
				
			||||||
    "INIT_CAPTCHA_DIFFICULTY_LEVEL": \
 | 
					    "INIT_CAPTCHA_DIFFICULTY_LEVEL":
 | 
				
			||||||
        int(os_getenv("CAPTCHABOT_INIT_CAPTCHA_DIFFICULTY_LEVEL", \
 | 
					        int(os_getenv("CAPTCHABOT_INIT_CAPTCHA_DIFFICULTY_LEVEL",
 | 
				
			||||||
                      SETTINGS["CAPTCHABOT_INIT_CAPTCHA_DIFFICULTY_LEVEL"])),
 | 
					                      SETTINGS["CAPTCHABOT_INIT_CAPTCHA_DIFFICULTY_LEVEL"])),
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # Initial captcha characters mode (ascii, hex, nums, math or button)
 | 
					    # Initial captcha characters mode (ascii, hex, nums, math or button)
 | 
				
			||||||
    "INIT_CAPTCHA_CHARS_MODE": \
 | 
					    "INIT_CAPTCHA_CHARS_MODE":
 | 
				
			||||||
        os_getenv("CAPTCHABOT_INIT_CAPTCHA_CHARS_MODE", \
 | 
					        os_getenv("CAPTCHABOT_INIT_CAPTCHA_CHARS_MODE",
 | 
				
			||||||
                  SETTINGS["CAPTCHABOT_INIT_CAPTCHA_CHARS_MODE"]),
 | 
					                  SETTINGS["CAPTCHABOT_INIT_CAPTCHA_CHARS_MODE"]),
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # Maximum configurable captcha time
 | 
					    # Maximum configurable captcha time
 | 
				
			||||||
    "MAX_CONFIG_CAPTCHA_TIME": \
 | 
					    "MAX_CONFIG_CAPTCHA_TIME":
 | 
				
			||||||
        int(os_getenv("CAPTCHABOT_MAX_CONFIG_CAPTCHA_TIME", \
 | 
					        int(os_getenv("CAPTCHABOT_MAX_CONFIG_CAPTCHA_TIME",
 | 
				
			||||||
                      SETTINGS["CAPTCHABOT_MAX_CONFIG_CAPTCHA_TIME"])),
 | 
					                      SETTINGS["CAPTCHABOT_MAX_CONFIG_CAPTCHA_TIME"])),
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # Standard auto-remove messages sent by Bot timeout (in seconds)
 | 
					    # Standard auto-remove messages sent by Bot timeout (in seconds)
 | 
				
			||||||
    "T_DEL_MSG": \
 | 
					    "T_DEL_MSG":
 | 
				
			||||||
        int(os_getenv("CAPTCHABOT_T_DEL_MSG", \
 | 
					        int(os_getenv("CAPTCHABOT_T_DEL_MSG",
 | 
				
			||||||
                      SETTINGS["CAPTCHABOT_T_DEL_MSG"])),
 | 
					                      SETTINGS["CAPTCHABOT_T_DEL_MSG"])),
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # Fast auto-remove messages sent by Bot timeout (in seconds)
 | 
					    # Fast auto-remove messages sent by Bot timeout (in seconds)
 | 
				
			||||||
    "T_FAST_DEL_MSG": \
 | 
					    "T_FAST_DEL_MSG":
 | 
				
			||||||
        int(os_getenv("CAPTCHABOT_T_FAST_DEL_MSG", \
 | 
					        int(os_getenv("CAPTCHABOT_T_FAST_DEL_MSG",
 | 
				
			||||||
                      SETTINGS["CAPTCHABOT_T_FAST_DEL_MSG"])),
 | 
					                      SETTINGS["CAPTCHABOT_T_FAST_DEL_MSG"])),
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # Auto-remove custom welcome message timeout (in seconds)
 | 
					    # Auto-remove custom welcome message timeout (in seconds)
 | 
				
			||||||
    "T_DEL_WELCOME_MSG": \
 | 
					    "T_DEL_WELCOME_MSG":
 | 
				
			||||||
        int(os_getenv("CAPTCHABOT_T_DEL_WELCOME_MSG", \
 | 
					        int(os_getenv("CAPTCHABOT_T_DEL_WELCOME_MSG",
 | 
				
			||||||
                      SETTINGS["CAPTCHABOT_T_DEL_WELCOME_MSG"])),
 | 
					                      SETTINGS["CAPTCHABOT_T_DEL_WELCOME_MSG"])),
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # Maximum number of users allowed in each chat ignore list
 | 
					    # Maximum number of users allowed in each chat ignore list
 | 
				
			||||||
    "IGNORE_LIST_MAX": \
 | 
					    "IGNORE_LIST_MAX":
 | 
				
			||||||
        int(os_getenv("CAPTCHABOT_IGNORE_LIST_MAX", \
 | 
					        int(os_getenv("CAPTCHABOT_IGNORE_LIST_MAX",
 | 
				
			||||||
                      SETTINGS["CAPTCHABOT_IGNORE_LIST_MAX"])),
 | 
					                      SETTINGS["CAPTCHABOT_IGNORE_LIST_MAX"])),
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # Initial new users just allow to send text messages
 | 
					    # Initial new users just allow to send text messages
 | 
				
			||||||
    "INIT_RESTRICT_NON_TEXT_MSG": \
 | 
					    "INIT_RESTRICT_NON_TEXT_MSG":
 | 
				
			||||||
        int(os_getenv("CAPTCHABOT_INIT_RESTRICT_NON_TEXT_MSG", \
 | 
					        int(os_getenv("CAPTCHABOT_INIT_RESTRICT_NON_TEXT_MSG",
 | 
				
			||||||
                      SETTINGS["CAPTCHABOT_INIT_RESTRICT_NON_TEXT_MSG"])),
 | 
					                      SETTINGS["CAPTCHABOT_INIT_RESTRICT_NON_TEXT_MSG"])),
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # Custom Welcome message max length
 | 
					    # Custom Welcome message max length
 | 
				
			||||||
    "MAX_WELCOME_MSG_LENGTH": \
 | 
					    "MAX_WELCOME_MSG_LENGTH":
 | 
				
			||||||
        int(os_getenv("CAPTCHABOT_MAX_WELCOME_MSG_LENGTH", \
 | 
					        int(os_getenv("CAPTCHABOT_MAX_WELCOME_MSG_LENGTH",
 | 
				
			||||||
                      SETTINGS["CAPTCHABOT_MAX_WELCOME_MSG_LENGTH"])),
 | 
					                      SETTINGS["CAPTCHABOT_MAX_WELCOME_MSG_LENGTH"])),
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # Initial remove result messages cgroup onfiguration
 | 
					    # Initial remove result messages cgroup onfiguration
 | 
				
			||||||
    "INIT_RM_RESULT_MSG": \
 | 
					    "INIT_RM_RESULT_MSG":
 | 
				
			||||||
        bool(int(os_getenv("CAPTCHABOT_INIT_RM_RESULT_MSG", \
 | 
					        bool(int(os_getenv("CAPTCHABOT_INIT_RM_RESULT_MSG",
 | 
				
			||||||
                           SETTINGS["CAPTCHABOT_INIT_RM_RESULT_MSG"]))),
 | 
					                           SETTINGS["CAPTCHABOT_INIT_RM_RESULT_MSG"]))),
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # Initial remove welcome message group configuration
 | 
					    # Initial remove welcome message group configuration
 | 
				
			||||||
    "INIT_RM_WELCOME_MSG": \
 | 
					    "INIT_RM_WELCOME_MSG":
 | 
				
			||||||
        bool(int(os_getenv("CAPTCHABOT_INIT_RM_WELCOME_MSG", \
 | 
					        bool(int(os_getenv("CAPTCHABOT_INIT_RM_WELCOME_MSG",
 | 
				
			||||||
                           SETTINGS["CAPTCHABOT_INIT_RM_WELCOME_MSG"]))),
 | 
					                           SETTINGS["CAPTCHABOT_INIT_RM_WELCOME_MSG"]))),
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # Maximum number of allowed captcha Poll options
 | 
					    # Maximum number of allowed captcha Poll options
 | 
				
			||||||
    "MAX_POLL_OPTIONS": \
 | 
					    "MAX_POLL_OPTIONS":
 | 
				
			||||||
        int(os_getenv("CAPTCHABOT_MAX_POLL_OPTIONS", \
 | 
					        int(os_getenv("CAPTCHABOT_MAX_POLL_OPTIONS",
 | 
				
			||||||
                      SETTINGS["CAPTCHABOT_MAX_POLL_OPTIONS"])),
 | 
					                      SETTINGS["CAPTCHABOT_MAX_POLL_OPTIONS"])),
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # Poll captcha question max length
 | 
					    # Poll captcha question max length
 | 
				
			||||||
    "MAX_POLL_QUESTION_LENGTH": \
 | 
					    "MAX_POLL_QUESTION_LENGTH":
 | 
				
			||||||
        int(os_getenv("CAPTCHABOT_MAX_POLL_QUESTION_LENGTH", \
 | 
					        int(os_getenv("CAPTCHABOT_MAX_POLL_QUESTION_LENGTH",
 | 
				
			||||||
                      SETTINGS["CAPTCHABOT_MAX_POLL_QUESTION_LENGTH"])),
 | 
					                      SETTINGS["CAPTCHABOT_MAX_POLL_QUESTION_LENGTH"])),
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # Poll captcha question max length
 | 
					    # Poll captcha question max length
 | 
				
			||||||
    "MAX_POLL_OPTION_LENGTH": \
 | 
					    "MAX_POLL_OPTION_LENGTH":
 | 
				
			||||||
        int(os_getenv("CAPTCHABOT_MAX_POLL_OPTION_LENGTH", \
 | 
					        int(os_getenv("CAPTCHABOT_MAX_POLL_OPTION_LENGTH",
 | 
				
			||||||
                      SETTINGS["CAPTCHABOT_MAX_POLL_OPTION_LENGTH"])),
 | 
					                      SETTINGS["CAPTCHABOT_MAX_POLL_OPTION_LENGTH"])),
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # Maximum number of times a user joins a group and fail to solve the
 | 
					    # Maximum number of times a user joins a group and fail to solve the
 | 
				
			||||||
    # captcha. If a user don't solve the captcha after this, it will be
 | 
					    # captcha. If a user don't solve the captcha after this, it will be
 | 
				
			||||||
    # ban instead kick
 | 
					    # ban instead kick
 | 
				
			||||||
    "MAX_FAIL_BAN": \
 | 
					    "MAX_FAIL_BAN":
 | 
				
			||||||
        int(os_getenv("CAPTCHABOT_MAX_FAIL_BAN", \
 | 
					        int(os_getenv("CAPTCHABOT_MAX_FAIL_BAN",
 | 
				
			||||||
                      SETTINGS["CAPTCHABOT_MAX_FAIL_BAN"])),
 | 
					                      SETTINGS["CAPTCHABOT_MAX_FAIL_BAN"])),
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # Maximum number of times a user fail to solve a Poll captcha.
 | 
					    # Maximum number of times a user fail to solve a Poll captcha.
 | 
				
			||||||
    # If a user don't solve the captcha after this, it will be ban
 | 
					    # If a user don't solve the captcha after this, it will be ban
 | 
				
			||||||
    # instead kick
 | 
					    # instead kick
 | 
				
			||||||
    "MAX_FAIL_BAN_POLL": \
 | 
					    "MAX_FAIL_BAN_POLL":
 | 
				
			||||||
        int(os_getenv("CAPTCHABOT_MAX_FAIL_BAN_POLL", \
 | 
					        int(os_getenv("CAPTCHABOT_MAX_FAIL_BAN_POLL",
 | 
				
			||||||
                      SETTINGS["CAPTCHABOT_MAX_FAIL_BAN_POLL"])),
 | 
					                      SETTINGS["CAPTCHABOT_MAX_FAIL_BAN_POLL"])),
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # Last session restorable RAM data backup file path
 | 
					    # Last session restorable RAM data backup file path
 | 
				
			||||||
| 
						 | 
					@ -219,13 +222,12 @@ CONST = {
 | 
				
			||||||
    "INIT_LINK": "Unknown",
 | 
					    "INIT_LINK": "Unknown",
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # Initial language at Bot start
 | 
					    # Initial language at Bot start
 | 
				
			||||||
    "INIT_LANG": \
 | 
					    "INIT_LANG":
 | 
				
			||||||
        os_getenv("CAPTCHABOT_INIT_LANG", \
 | 
					        os_getenv("CAPTCHABOT_INIT_LANG", SETTINGS["CAPTCHABOT_INIT_LANG"]),
 | 
				
			||||||
            SETTINGS["CAPTCHABOT_INIT_LANG"]),
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # Time to restrict sending no-text messages
 | 
					    # Time to restrict sending no-text messages
 | 
				
			||||||
    "T_RESTRICT_NO_TEXT_MSG": \
 | 
					    "T_RESTRICT_NO_TEXT_MSG":
 | 
				
			||||||
        int(os_getenv("CAPTCHABOT_T_RESTRICT_NO_TEXT_MSG", \
 | 
					        int(os_getenv("CAPTCHABOT_T_RESTRICT_NO_TEXT_MSG",
 | 
				
			||||||
                      SETTINGS["CAPTCHABOT_T_RESTRICT_NO_TEXT_MSG"])),
 | 
					                      SETTINGS["CAPTCHABOT_T_RESTRICT_NO_TEXT_MSG"])),
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # Number of seconds in a minute
 | 
					    # Number of seconds in a minute
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -735,7 +735,8 @@ async def should_manage_captcha(update, bot):
 | 
				
			||||||
 | 
					
 | 
				
			||||||
async def restrict_user_mute(bot, chat_id, user_id, until_date=None):
 | 
					async def restrict_user_mute(bot, chat_id, user_id, until_date=None):
 | 
				
			||||||
    '''Restrict an user in order to deny it send any kind of message.'''
 | 
					    '''Restrict an user in order to deny it send any kind of message.'''
 | 
				
			||||||
    restrict_success = await tlg_restrict_user(bot, chat_id, user_id,
 | 
					    restrict_success = await tlg_restrict_user(
 | 
				
			||||||
 | 
					        bot, chat_id, user_id,
 | 
				
			||||||
        send_msg=False,
 | 
					        send_msg=False,
 | 
				
			||||||
        send_media=False,
 | 
					        send_media=False,
 | 
				
			||||||
        send_polls=False,
 | 
					        send_polls=False,
 | 
				
			||||||
| 
						 | 
					@ -751,7 +752,8 @@ async def restrict_user_mute(bot, chat_id, user_id, until_date=None):
 | 
				
			||||||
 | 
					
 | 
				
			||||||
async def restrict_user_media(bot, chat_id, user_id, until_date=None):
 | 
					async def restrict_user_media(bot, chat_id, user_id, until_date=None):
 | 
				
			||||||
    '''Restrict an user in order to deny it send media messages.'''
 | 
					    '''Restrict an user in order to deny it send media messages.'''
 | 
				
			||||||
    restrict_success = await tlg_restrict_user(bot, chat_id, user_id,
 | 
					    restrict_success = await tlg_restrict_user(
 | 
				
			||||||
 | 
					        bot, chat_id, user_id,
 | 
				
			||||||
        send_msg=True,
 | 
					        send_msg=True,
 | 
				
			||||||
        send_media=False,
 | 
					        send_media=False,
 | 
				
			||||||
        send_polls=False,
 | 
					        send_polls=False,
 | 
				
			||||||
| 
						 | 
					@ -3948,11 +3950,11 @@ async def tlg_app_exit(app: Application) -> None:
 | 
				
			||||||
    Global.force_exit = True
 | 
					    Global.force_exit = True
 | 
				
			||||||
    if Global.async_captcha_timeout is not None:
 | 
					    if Global.async_captcha_timeout is not None:
 | 
				
			||||||
        if not Global.async_captcha_timeout.done():
 | 
					        if not Global.async_captcha_timeout.done():
 | 
				
			||||||
            logger.info("Waiting end of coroutine: captcha_timeout()")
 | 
					            logger.info("Waiting coroutine end: captcha_timeout()")
 | 
				
			||||||
            await Global.async_captcha_timeout
 | 
					            await Global.async_captcha_timeout
 | 
				
			||||||
    if Global.async_auto_delete_messages is not None:
 | 
					    if Global.async_auto_delete_messages is not None:
 | 
				
			||||||
        if not Global.async_auto_delete_messages.done():
 | 
					        if not Global.async_auto_delete_messages.done():
 | 
				
			||||||
            logger.info("Waiting end of coroutine: async_auto_delete_messages()")
 | 
					            logger.info("Waiting coroutine end: async_auto_delete_messages()")
 | 
				
			||||||
            await Global.async_auto_delete_messages
 | 
					            await Global.async_auto_delete_messages
 | 
				
			||||||
    # Save current session data
 | 
					    # Save current session data
 | 
				
			||||||
    save_session()
 | 
					    save_session()
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -19,7 +19,8 @@ Version:
 | 
				
			||||||
'''
 | 
					'''
 | 
				
			||||||
 | 
					
 | 
				
			||||||
###############################################################################
 | 
					###############################################################################
 | 
				
			||||||
### Imported modules
 | 
					# Imported modules
 | 
				
			||||||
 | 
					###############################################################################
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# JSON Library
 | 
					# JSON Library
 | 
				
			||||||
import json
 | 
					import json
 | 
				
			||||||
| 
						 | 
					@ -33,8 +34,10 @@ from sys import exit as sys_exit
 | 
				
			||||||
# Local Constants Library
 | 
					# Local Constants Library
 | 
				
			||||||
from constants import CONST
 | 
					from constants import CONST
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					###############################################################################
 | 
				
			||||||
 | 
					# Auxiliary Functions
 | 
				
			||||||
###############################################################################
 | 
					###############################################################################
 | 
				
			||||||
### Auxiliary Functions
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
def is_valid(lang_name, lang_to_check, reference_lang):
 | 
					def is_valid(lang_name, lang_to_check, reference_lang):
 | 
				
			||||||
    '''
 | 
					    '''
 | 
				
			||||||
| 
						 | 
					@ -62,8 +65,10 @@ def is_valid(lang_name, lang_to_check, reference_lang):
 | 
				
			||||||
    print(f"{lang_name} - OK")
 | 
					    print(f"{lang_name} - OK")
 | 
				
			||||||
    return True
 | 
					    return True
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					###############################################################################
 | 
				
			||||||
 | 
					# Main Function
 | 
				
			||||||
###############################################################################
 | 
					###############################################################################
 | 
				
			||||||
### Main Function
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
def main():
 | 
					def main():
 | 
				
			||||||
    '''Main Function.'''
 | 
					    '''Main Function.'''
 | 
				
			||||||
| 
						 | 
					@ -92,7 +97,8 @@ def main():
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
###############################################################################
 | 
					###############################################################################
 | 
				
			||||||
### Runnable Main Script Detection
 | 
					# Runnable Main Script Detection
 | 
				
			||||||
 | 
					###############################################################################
 | 
				
			||||||
 | 
					
 | 
				
			||||||
if __name__ == "__main__":
 | 
					if __name__ == "__main__":
 | 
				
			||||||
    sys_exit(main())
 | 
					    sys_exit(main())
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -20,7 +20,7 @@ Version:
 | 
				
			||||||
###############################################################################
 | 
					###############################################################################
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from os import path as os_path
 | 
					from os import path as os_path
 | 
				
			||||||
from os import environ as os_environ
 | 
					# from os import environ as os_environ
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Actual settings.py full path directory name
 | 
					# Actual settings.py full path directory name
 | 
				
			||||||
SCRIPT_PATH = os_path.dirname(os_path.realpath(__file__))
 | 
					SCRIPT_PATH = os_path.dirname(os_path.realpath(__file__))
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Ładowanie…
	
		Reference in New Issue