-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfirst_setup.py
More file actions
293 lines (259 loc) · 12.8 KB
/
Copy pathfirst_setup.py
File metadata and controls
293 lines (259 loc) · 12.8 KB
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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
import os
from configparser import ConfigParser
import time
import telebot
from colorama import Fore, Style
from Utils.cardinal_tools import check_proxy, validate_proxy, hash_password, obfuscate_data
from Utils.telegram_proxy import (check_telegram_proxy, mask_telegram_proxy,
normalize_telegram_proxy, telegram_proxy_mapping,
verify_telegram_bot)
default_config = {
"FunPay": {
"golden_key": "",
"user_agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36",
"autoRaise": "0",
"autoResponse": "0",
"autoDelivery": "0",
"multiDelivery": "0",
"autoRestore": "0",
"autoDisable": "0",
"oldMsgGetMode": "0",
"locale": "ru"
},
"Telegram": {
"enabled": "0",
"token": "",
"secretKeyHash": "ХешСекретногоПароля",
"blockLogin": "0",
"proxy": ""
},
"BlockList": {
"blockDelivery": "0",
"blockResponse": "0",
"blockNewMessageNotification": "0",
"blockNewOrderNotification": "0",
"blockCommandNotification": "0"
},
"NewMessageView": {
"includeMyMessages": "1",
"includeFPMessages": "1",
"includeBotMessages": "0",
"notifyOnlyMyMessages": "0",
"notifyOnlyFPMessages": "0",
"notifyOnlyBotMessages": "0",
"showImageName": "1"
},
"Greetings": {
"ignoreSystemMessages": "0",
"onlyNewChats": "0",
"sendGreetings": "0",
"greetingsText": "Привет, $chat_name!",
"greetingsCooldown": "2"
},
"OrderConfirm": {
"watermark": "1",
"sendReply": "0",
"replyText": "$username, спасибо за подтверждение заказа $order_id!\nЕсли не сложно, оставь, пожалуйста, отзыв!"
},
"ReviewReply": {
"star1Reply": "0",
"star2Reply": "0",
"star3Reply": "0",
"star4Reply": "0",
"star5Reply": "0",
"star1ReplyText": "",
"star2ReplyText": "",
"star3ReplyText": "",
"star4ReplyText": "",
"star5ReplyText": "",
},
"Proxy": {
"enable": "0",
"ip": "",
"port": "",
"login": "",
"password": "",
"type": "HTTP",
"check": "0"
},
"Schedule": {
"enabled": "0",
"workHoursStart": "09:00",
"workHoursEnd": "23:00",
"disableAutoResponse": "1",
"disableAutoDelivery": "0",
"offlineMessage": ""
},
"AutoDiscount": {
"enabled": "0",
"command": "!скидка",
"discountPercent": "5",
"durationMinutes": "10",
"cooldownMinutes": "30"
},
"Other": {
"watermark": "🐦",
"requestsDelay": "4",
"language": "ru",
"timezone": ""
}
}
def create_configs():
if not os.path.exists("configs/auto_response.cfg"):
with open("configs/auto_response.cfg", "w", encoding="utf-8"):
...
if not os.path.exists("configs/auto_response.cfg"):
with open("configs/auto_delivery.cfg", "w", encoding="utf-8"):
...
def create_config_obj(settings) -> ConfigParser:
config = ConfigParser(delimiters=(":",), interpolation=None)
config.optionxform = str
config.read_dict(settings)
return config
def contains_russian(text: str) -> bool:
for char in text:
if 'А' <= char <= 'я' or char in 'Ёё':
return True
return False
def input_proxy(set_telebot_proxy: bool = False) -> str | None:
"""Cardinal-compatible interactive proxy input helper."""
while True:
proxy_input = input(f"{Fore.MAGENTA}{Style.BRIGHT}└───> {Style.RESET_ALL}").strip()
if not proxy_input:
if set_telebot_proxy:
telebot.apihelper.proxy = None
return None
try:
proxy = normalize_telegram_proxy(proxy_input)
if not check_proxy({"http": proxy, "https": proxy}):
print("\nНевалидный прокси. Попробуй еще раз!")
continue
if set_telebot_proxy:
telebot.apihelper.proxy = telegram_proxy_mapping(proxy)
return proxy
except Exception as exc:
print(f"\nНеверный формат прокси: {exc}. Попробуй еще раз!")
def setup_telegram_proxy():
"""Проверяет и сохраняет прокси Telegram в существующем конфиге."""
from Utils.config_loader import load_main_config, save_config
config = load_main_config("configs/_main.cfg")
current = config["Telegram"].get("proxy", "")
print(f"\nТекущий Telegram-прокси: {mask_telegram_proxy(current)}")
print("Укажи новый proxy URL или нажми Enter, чтобы отключить Telegram-прокси.")
while True:
proxy = input_proxy(set_telebot_proxy=True)
if proxy:
success, details = check_telegram_proxy(proxy, config["Telegram"]["token"])
if not success:
print(f"\nНе удалось подключиться к Telegram через этот прокси: {details}")
continue
print(f"\nПодключение к Telegram успешно: {details}")
config.set("Telegram", "proxy", proxy or "")
save_config(config, "configs/_main.cfg")
print("Telegram-прокси сохранён. Перезапусти Sigma для гарантированного применения.")
return
def first_setup():
config = create_config_obj(default_config)
sleep_time = 1
print(f"{Fore.CYAN}{Style.BRIGHT}Привет! {Fore.RED}(`-`)/{Style.RESET_ALL}")
time.sleep(sleep_time)
print(f"\n{Fore.CYAN}{Style.BRIGHT}Не могу найти основной конфиг... {Fore.RED}(-_-;). . .{Style.RESET_ALL}")
time.sleep(sleep_time)
print(f"\n{Fore.CYAN}{Style.BRIGHT}Давай ка проведем первичную настройку! {Fore.RED}°++°{Style.RESET_ALL}")
time.sleep(sleep_time)
while True:
print(f"\n{Fore.MAGENTA}{Style.BRIGHT}┌── {Fore.CYAN}"
f"Для начала введи токен (golden_key) твоего FunPay аккаунта (посмотреть его можно в расширении EditThisCookie) {Fore.RED}(._.){Style.RESET_ALL}")
golden_key = input(f"{Fore.MAGENTA}{Style.BRIGHT}└───> {Style.RESET_ALL}").strip()
if len(golden_key) != 32:
print(
f"\n{Fore.CYAN}{Style.BRIGHT}Неверный формат токена. Попробуй еще раз! {Fore.RED}\\(!!˚0˚)/{Style.RESET_ALL}")
continue
config.set("FunPay", "golden_key", f"b64:{obfuscate_data(golden_key)}")
break
while True:
print(f"\n{Fore.MAGENTA}{Style.BRIGHT}┌── {Fore.CYAN}"
f"Если хочешь, ты можешь указать свой User-agent (введи в Google \"my user agent\"). Или можешь просто нажать Enter. "
f"{Fore.RED}¯\\(°_o)/¯{Style.RESET_ALL}")
user_agent = input(f"{Fore.MAGENTA}{Style.BRIGHT}└───> {Style.RESET_ALL}").strip()
if contains_russian(user_agent):
print(
f"\n{Fore.CYAN}{Style.BRIGHT}Ты не знаешь, что такое Google? {Fore.RED}\\(!!˚0˚)/{Style.RESET_ALL}")
continue
if user_agent:
config.set("FunPay", "user_agent", user_agent)
break
print(f"\n{Fore.MAGENTA}{Style.BRIGHT}┌── {Fore.CYAN}"
f"Если Telegram недоступен напрямую, укажи отдельный прокси для Telegram Bot API. "
f"Форматы: http://login:password@ip:port, socks5://ip:port или socks5h://ip:port. "
f"Чтобы подключаться напрямую, просто нажми Enter. {Fore.RED}(* ^ ω ^){Style.RESET_ALL}")
telegram_proxy = input_proxy(set_telebot_proxy=True)
if telegram_proxy:
config.set("Telegram", "proxy", f"b64:{obfuscate_data(telegram_proxy)}")
while True:
print(
f"\n{Fore.MAGENTA}{Style.BRIGHT}┌── {Fore.CYAN}Введи API-токен Telegram-бота (получить его можно у @BotFather). "
f"{Fore.RED}(._.){Style.RESET_ALL}")
token = input(f"{Fore.MAGENTA}{Style.BRIGHT}└───> {Style.RESET_ALL}").strip()
bot_id, separator, bot_secret = token.partition(":")
if not separator or not bot_id.isdigit() or not bot_secret:
print(f"\n{Fore.CYAN}{Style.BRIGHT}Неправильный формат токена. Попробуй еще раз! "
f"{Fore.RED}\\(!!˚0˚)/{Style.RESET_ALL}")
continue
token_valid, details = verify_telegram_bot(token, telegram_proxy)
if token_valid is False:
print(f"\n{Fore.CYAN}{Style.BRIGHT}Telegram отклонил токен: {details}. Попробуй еще раз! "
f"{Fore.RED}\\(!!˚0˚)/{Style.RESET_ALL}")
continue
if token_valid is None:
print(f"\n{Fore.YELLOW}{Style.BRIGHT}Telegram Bot API сейчас недоступен: {details}. "
"Токен сохранится без онлайн-проверки. Настроить прокси позже можно через "
f"SetupTelegramProxy.bat.{Style.RESET_ALL}")
else:
print(f"\n{Fore.GREEN}{Style.BRIGHT}Telegram-бот найден: {details}.{Style.RESET_ALL}")
break
while True:
print(
f"\n{Fore.MAGENTA}{Style.BRIGHT}┌── {Fore.CYAN}Придумай пароль (его потребует Telegram-бот). Пароль должен содержать более 8 символов, заглавные, строчные буквы и хотя бы одну цифру "
f" {Fore.RED}ᴖ̮ ̮ᴖ{Style.RESET_ALL}")
password = input(f"{Fore.MAGENTA}{Style.BRIGHT}└───> {Style.RESET_ALL}").strip()
if len(password) < 8 or password.lower() == password or password.upper() == password or not any(
[i.isdigit() for i in password]):
print(
f"\n{Fore.CYAN}{Style.BRIGHT}Это плохой пароль. Попробуй еще раз! {Fore.RED}\\(!!˚0˚)/{Style.RESET_ALL}")
continue
break
config.set("Telegram", "enabled", "1")
config.set("Telegram", "token", f"b64:{obfuscate_data(token)}")
config.set("Telegram", "secretKeyHash", hash_password(password))
while True:
print(f"\n{Fore.MAGENTA}{Style.BRIGHT}┌── {Fore.CYAN}"
f"Если хочешь использовать IPv4 прокси – укажи их в формате login:password@ip:port или ip:port. Если ты не знаешь, "
f"что это такое или они тебе не нужны - просто нажми Enter. "
f"{Fore.RED}(* ^ ω ^){Style.RESET_ALL}")
proxy = input(f"{Fore.MAGENTA}{Style.BRIGHT}└───> {Style.RESET_ALL}").strip()
if proxy:
try:
scheme, login, password, ip, port = validate_proxy(proxy)
config.set("Proxy", "enable", "1")
config.set("Proxy", "check", "1")
config.set("Proxy", "type", "SOCKS5" if scheme.startswith("socks5") else "HTTP")
config.set("Proxy", "login", f"b64:{obfuscate_data(login)}")
config.set("Proxy", "password", f"b64:{obfuscate_data(password)}")
config.set("Proxy", "ip", f"b64:{obfuscate_data(ip)}")
config.set("Proxy", "port", f"b64:{obfuscate_data(port)}")
break
except:
print(
f"\n{Fore.CYAN}{Style.BRIGHT}Неверный формат прокси. Попробуй еще раз! {Fore.RED}(o-_-o){Style.RESET_ALL}")
continue
else:
break
print(f"\n{Fore.CYAN}{Style.BRIGHT}Готово! Сейчас я сохраню конфиг и завершу программу! "
f"{Fore.RED}ʘ>ʘ{Style.RESET_ALL}")
print(f"{Fore.CYAN}{Style.BRIGHT}Запусти меня снова и напиши своему Telegram-боту. "
f"Все остальное ты сможешь настроить через него. {Fore.RED}ʕ•ᴥ•ʔ{Style.RESET_ALL}")
print(f"{Fore.CYAN}{Style.BRIGHT}Репозиторий: https://github.com/qorexdevs/FunPaySigma{Style.RESET_ALL}")
with open("configs/_main.cfg", "w", encoding="utf-8") as f:
config.write(f)
time.sleep(10)