|
7 | 7 |
|
8 | 8 | # enable logging |
9 | 9 | logging.basicConfig( |
10 | | - format="%(asctime)s - %(name)s - %(levelname)s - %(message)s", |
11 | | - level=logging.DEBUG) |
| 10 | + format="%(asctime)s - %(name)s - %(levelname)s - %(message)s", level=logging.DEBUG |
| 11 | +) |
12 | 12 |
|
13 | 13 | LOGGER = logging.getLogger(__name__) |
14 | 14 |
|
15 | 15 | # if version < 3.6, stop bot. |
16 | 16 | if sys.version_info[0] < 3 or sys.version_info[1] < 6: |
17 | | - LOGGER.error("You MUST have a python version of at least 3.6! Multiple features depend on this. Bot quitting.") |
| 17 | + LOGGER.error( |
| 18 | + "You MUST have a python version of at least 3.6! Multiple features depend on this. Bot quitting." |
| 19 | + ) |
18 | 20 | quit(1) |
19 | 21 |
|
20 | | -ENV = bool(os.environ.get('ENV', False)) |
| 22 | +ENV = bool(os.environ.get("ENV", False)) |
21 | 23 |
|
22 | 24 | if ENV: |
23 | | - TOKEN = os.environ.get('TOKEN', None) |
| 25 | + TOKEN = os.environ.get("TOKEN", None) |
24 | 26 | try: |
25 | | - OWNER_ID = int(os.environ.get('OWNER_ID', None)) |
| 27 | + OWNER_ID = int(os.environ.get("OWNER_ID", None)) |
26 | 28 | except ValueError: |
27 | 29 | raise Exception("Your OWNER_ID env variable is not a valid integer.") |
28 | 30 |
|
29 | | - MESSAGE_DUMP = os.environ.get('MESSAGE_DUMP', None) |
| 31 | + MESSAGE_DUMP = os.environ.get("MESSAGE_DUMP", None) |
30 | 32 | OWNER_USERNAME = os.environ.get("OWNER_USERNAME", None) |
31 | 33 |
|
32 | 34 | try: |
|
40 | 42 | raise Exception("Your support users list does not contain valid integers.") |
41 | 43 |
|
42 | 44 | try: |
43 | | - WHITELIST_USERS = set(int(x) for x in os.environ.get("WHITELIST_USERS", "").split()) |
| 45 | + WHITELIST_USERS = set( |
| 46 | + int(x) for x in os.environ.get("WHITELIST_USERS", "").split() |
| 47 | + ) |
44 | 48 | except ValueError: |
45 | 49 | raise Exception("Your whitelisted users list does not contain valid integers.") |
46 | 50 |
|
47 | | - WEBHOOK = bool(os.environ.get('WEBHOOK', False)) |
48 | | - URL = os.environ.get('URL', "") # Does not contain token |
49 | | - PORT = int(os.environ.get('PORT', 5000)) |
| 51 | + WEBHOOK = bool(os.environ.get("WEBHOOK", False)) |
| 52 | + URL = os.environ.get("URL", "") # Does not contain token |
| 53 | + PORT = int(os.environ.get("PORT", 5000)) |
50 | 54 | CERT_PATH = os.environ.get("CERT_PATH") |
51 | 55 |
|
52 | | - DB_URI = os.environ.get('DATABASE_URL') |
53 | | - DONATION_LINK = os.environ.get('DONATION_LINK') |
54 | | - LOAD = os.environ.get("LOAD", "").split(",") if "," in os.environ.get("LOAD", "") else os.environ.get("LOAD", "").split() |
| 56 | + DB_URI = os.environ.get("DATABASE_URL") |
| 57 | + DONATION_LINK = os.environ.get("DONATION_LINK") |
| 58 | + LOAD = ( |
| 59 | + os.environ.get("LOAD", "").split(",") |
| 60 | + if "," in os.environ.get("LOAD", "") |
| 61 | + else os.environ.get("LOAD", "").split() |
| 62 | + ) |
55 | 63 | NO_LOAD = os.environ.get("NO_LOAD", "translation").split(",") |
56 | | - DEL_CMDS = bool(os.environ.get('DEL_CMDS', False)) |
57 | | - STRICT_GBAN = bool(os.environ.get('STRICT_GBAN', False)) |
58 | | - WORKERS = int(os.environ.get('WORKERS', 8)) |
59 | | - BAN_STICKER = os.environ.get('BAN_STICKER', 'CAADAgADOwADPPEcAXkko5EB3YGYAg') |
60 | | - ALLOW_EXCL = os.environ.get('ALLOW_EXCL', False) |
61 | | - DEFAULT_CHAT_ID = os.environ.get('DEFAULT_CHAT_ID', None) |
| 64 | + DEL_CMDS = bool(os.environ.get("DEL_CMDS", False)) |
| 65 | + STRICT_GBAN = bool(os.environ.get("STRICT_GBAN", False)) |
| 66 | + WORKERS = int(os.environ.get("WORKERS", 8)) |
| 67 | + BAN_STICKER = os.environ.get("BAN_STICKER", "CAADAgADOwADPPEcAXkko5EB3YGYAg") |
| 68 | + ALLOW_EXCL = os.environ.get("ALLOW_EXCL", False) |
| 69 | + DEFAULT_CHAT_ID = os.environ.get("DEFAULT_CHAT_ID", None) |
62 | 70 | VERSION = __version__ |
63 | 71 |
|
64 | 72 | else: |
65 | 73 | from tg_bot.config import Development as Config |
| 74 | + |
66 | 75 | TOKEN = Config.API_KEY |
67 | 76 | try: |
68 | 77 | OWNER_ID = int(Config.OWNER_ID) |
|
117 | 126 | SUPPORT_USERS = list(SUPPORT_USERS) |
118 | 127 |
|
119 | 128 | # Load at end to ensure all prev variables have been set |
120 | | -from tg_bot.modules.helper_funcs.handlers import CustomCommandHandler, CustomRegexHandler |
| 129 | +from tg_bot.modules.helper_funcs.handlers import ( |
| 130 | + CustomCommandHandler, |
| 131 | + CustomRegexHandler, |
| 132 | +) |
121 | 133 |
|
122 | 134 | # make sure the regex handler can take extra kwargs |
123 | 135 | tg.RegexHandler = CustomRegexHandler |
|
0 commit comments