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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import requests, os, sys, jwt, json, binascii, time, urllib3, xKEys, base64, datetime, re, socket, threading
|
| 2 |
+
from flask import Flask, request, abort
|
| 3 |
+
import psutil
|
| 4 |
+
from protobuf_decoder.protobuf_decoder import Parser
|
| 5 |
+
from byte import *
|
| 6 |
+
from byte import xSendTeamMsg, xSEndMsg
|
| 7 |
+
from byte import Auth_Chat
|
| 8 |
+
from xHeaders import *
|
| 9 |
+
from datetime import datetime
|
| 10 |
+
from google.protobuf.timestamp_pb2 import Timestamp
|
| 11 |
+
from concurrent.futures import ThreadPoolExecutor
|
| 12 |
+
from threading import Thread
|
| 13 |
+
from black9 import openroom, spmroom
|
| 14 |
+
import telebot
|
| 15 |
+
from telebot import types
|
| 16 |
+
import logging
|
| 17 |
+
|
| 18 |
+
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
|
| 19 |
+
|
| 20 |
+
TOKEN = "8263073239:AAFAHKIy2-aFgXkFfgfFA8_aBXrYVdxGam0"
|
| 21 |
+
ADMIN_IDS = [8368309157]
|
| 22 |
+
|
| 23 |
+
from telebot import apihelper
|
| 24 |
+
import socket
|
| 25 |
+
import ssl
|
| 26 |
+
|
| 27 |
+
def resolve_via_doh(hostname):
|
| 28 |
+
"""Resolve hostname using Cloudflare DNS over HTTPS to bypass HF DNS block"""
|
| 29 |
+
try:
|
| 30 |
+
import urllib.request
|
| 31 |
+
import json
|
| 32 |
+
url = f"https://cloudflare-dns.com/dns-query?name={hostname}&type=A"
|
| 33 |
+
req = urllib.request.Request(url, headers={"accept": "application/dns-json"})
|
| 34 |
+
with urllib.request.urlopen(req, timeout=10) as resp:
|
| 35 |
+
data = json.loads(resp.read())
|
| 36 |
+
answers = data.get("Answer", [])
|
| 37 |
+
for ans in answers:
|
| 38 |
+
if ans.get("type") == 1: # A record
|
| 39 |
+
return ans["data"]
|
| 40 |
+
except Exception as e:
|
| 41 |
+
print(f"DoH resolution failed: {e}")
|
| 42 |
+
return None
|
| 43 |
+
|
| 44 |
+
|
| 45 |
+
_original_getaddrinfo = socket.getaddrinfo
|
| 46 |
+
def _patched_getaddrinfo(host, port, *args, **kwargs):
|
| 47 |
+
if host == 'api.telegram.org':
|
| 48 |
+
ip = resolve_via_doh(host)
|
| 49 |
+
if ip:
|
| 50 |
+
return _original_getaddrinfo(ip, port, *args, **kwargs)
|
| 51 |
+
return _original_getaddrinfo(host, port, *args, **kwargs)
|
| 52 |
+
socket.getaddrinfo = _patched_getaddrinfo
|
| 53 |
+
print("DNS patch applied: api.telegram.org will be resolved via Cloudflare DoH")
|
| 54 |
+
|
| 55 |
+
|
| 56 |
+
WEBHOOK_URL = os.environ.get('WEBHOOK_URL', '')
|
| 57 |
+
|
| 58 |
+
bot = telebot.TeleBot(TOKEN, parse_mode="HTML")
|
| 59 |
+
app = Flask(__name__)
|
| 60 |
+
|
| 61 |
+
connected_clients = {}
|
| 62 |
+
connected_clients_lock = threading.Lock()
|
| 63 |
+
|
| 64 |
+
active_spam_targets = {}
|
| 65 |
+
active_room_spam_targets = {}
|
| 66 |
+
active_spam_lock = threading.Lock()
|
| 67 |
+
|
| 68 |
+
spam_initiators = {}
|
| 69 |
+
spam_initiators_lock = threading.Lock()
|
| 70 |
+
|
| 71 |
+
spam_start_times = {}
|
| 72 |
+
spam_start_times_lock = threading.Lock()
|
| 73 |
+
|
| 74 |
+
logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - %(message)s', level=logging.INFO)
|
| 75 |
+
logger = logging.getLogger(__name__)
|
| 76 |
+
|
| 77 |
+
@bot.message_handler(commands=['start'])
|
| 78 |
+
def start(message):
|
| 79 |
+
user_id = message.from_user.id
|
| 80 |
+
is_admin = user_id in ADMIN_IDS
|
| 81 |
+
chat_type = message.chat.type
|
| 82 |
+
|
| 83 |
+
if chat_type != 'private':
|
| 84 |
+
msg = (
|
| 85 |
+
"<b>🎮 Spam Bot Commands</b>\n\n"
|
| 86 |
+
"<b>📝 Available Commands:</b>\n"
|
| 87 |
+
"• <code>/spam {id} {hours}</code> - Start normal spam\n"
|
| 88 |
+
"• <code>/room {id} {hours}</code> - Start room spam\n"
|
| 89 |
+
"• <code>/status {id}</code> - Check spam status\n"
|
| 90 |
+
"• <code>/stop_spam {id}</code> - Stop normal spam\n"
|
| 91 |
+
"• <code>/stop_room {id}</code> - Stop room spam\n\n"
|
| 92 |
+
"<b>⏰ Note:</b> Maximum 24 hours\n\n"
|
| 93 |
+
"<b>📞 Support:</b> @AlliFF_BOT"
|
| 94 |
+
)
|
| 95 |
+
else:
|
| 96 |
+
if is_admin:
|
| 97 |
+
msg = (
|
| 98 |
+
"<b>👑 Welcome Admin</b>\n\n"
|
| 99 |
+
"<b>📝 Available Commands:</b>\n"
|
| 100 |
+
"• <code>/spam {id} {hours/d}</code> - Start normal spam (use d for days)\n"
|
| 101 |
+
"• <code>/room {id} {hours/d}</code> - Start room spam (use d for days)\n"
|
| 102 |
+
"• <code>/status {id}</code> - Check spam status\n"
|
| 103 |
+
"• <code>/stop_spam {id}</code> - Stop normal spam\n"
|
| 104 |
+
"• <code>/stop_room {id}</code> - Stop room spam\n"
|
| 105 |
+
"• <code>/restart</code> - Restart accounts (Admin only)\n\n"
|
| 106 |
+
"<b>📞 Support:</b> @AlliFF_BOT"
|
| 107 |
+
)
|
| 108 |
+
else:
|
| 109 |
+
msg = "🗿"
|
| 110 |
+
|
| 111 |
+
bot.reply_to(message, msg)
|
| 112 |
+
|
| 113 |
+
@bot.message_handler(func=lambda message: message.chat.type == 'private' and message.from_user.id not in ADMIN_IDS and not message.text.startswith('/'))
|
| 114 |
+
def handle_private(message):
|
| 115 |
+
bot.reply_to(message, "🗿")
|
| 116 |
+
|
| 117 |
+
@bot.message_handler(commands=['spam'])
|
| 118 |
+
def spam_command(message):
|
| 119 |
+
user_id = message.from_user.id
|
| 120 |
+
args = message.text.split()
|
| 121 |
+
|
| 122 |
+
try:
|
| 123 |
+
if len(args) != 3:
|
| 124 |
+
bot.reply_to(message, "<b>❌ Wrong Format</b>\nUse: <code>/spam {id} {hours}</code>")
|
| 125 |
+
return
|
| 126 |
+
|
| 127 |
+
target_id = args[1]
|
| 128 |
+
|
| 129 |
+
if user_id in ADMIN_IDS:
|
| 130 |
+
time_value = args[2]
|
| 131 |
+
if 'd' in time_value:
|
| 132 |
+
days = int(time_value.replace('d', ''))
|
| 133 |
+
hours = days * 24
|
| 134 |
+
else:
|
| 135 |
+
hours = int(time_value)
|
| 136 |
+
else:
|
| 137 |
+
hours = int(args[2])
|
| 138 |
+
|
| 139 |
+
if hours <= 0 or hours > 720:
|
| 140 |
+
bot.reply_to(message, "<b>❌ Error</b>\nMaximum 30 days (720 hours)")
|
| 141 |
+
return
|
| 142 |
+
|
| 143 |
+
if not ChEck_Commande(target_id):
|
| 144 |
+
bot.reply_to(message, "<b>❌ Error</b>\nInvalid user_id")
|
| 145 |
+
return
|
| 146 |
+
|
| 147 |
+
with active_spam_lock:
|
| 148 |
+
if target_id in active_spam_targets:
|
| 149 |
+
bot.reply_to(message, f"<b>⚠️ This account is already in spam</b>")
|
| 150 |
+
return
|
| 151 |
+
|
| 152 |
+
active_spam_targets[target_id] = {
|
| 153 |
+
'active': True,
|
| 154 |
+
'start_time': datetime.now(),
|
| 155 |
+
'duration': hours,
|
| 156 |
+
'type': 'normal',
|
| 157 |
+
'initiator': user_id
|
| 158 |
+
}
|
| 159 |
+
|
| 160 |
+
with spam_start_times_lock:
|
| 161 |
+
spam_start_times[target_id] = datetime.now()
|
| 162 |
+
|
| 163 |
+
with spam_initiators_lock:
|
| 164 |
+
spam_initiators[target_id] = user_id
|
| 165 |
+
|
| 166 |
+
threading.Thread(target=normal_spam_worker, args=(target_id, hours), daemon=True).start()
|
| 167 |
+
|
| 168 |
+
time_text = "days" if hours >= 24 else "hours"
|
| 169 |
+
time_value = hours // 24 if hours >= 24 else hours
|
| 170 |
+
|
| 171 |
+
bot.reply_to(
|
| 172 |
+
message,
|
| 173 |
+
f"<b>✅ Successfully started spam for ID <code>{target_id}</code> for {time_value} {time_text}</b>"
|
| 174 |
+
)
|
| 175 |
+
|
| 176 |
+
except ValueError:
|
| 177 |
+
bot.reply_to(message, "<b>❌ Error</b>\nPlease enter a valid number")
|
| 178 |
+
except Exception as e:
|
| 179 |
+
bot.reply_to(message, f"<b>❌ Error:</b> {str(e)}")
|
| 180 |
+
|
| 181 |
+
@bot.message_handler(commands=['room'])
|
| 182 |
+
def room_command(message):
|
| 183 |
+
user_id = message.from_user.id
|
| 184 |
+
args = message.text.split()
|
| 185 |
+
|
| 186 |
+
try:
|
| 187 |
+
if len(args) != 3:
|
| 188 |
+
bot.reply_to(message, "<b>❌ Wrong Format</b>\nUse: <code>/room {id} {hours}</code>")
|
| 189 |
+
return
|
| 190 |
+
|
| 191 |
+
target_id = args[1]
|
| 192 |
+
|
| 193 |
+
if user_id in ADMIN_IDS:
|
| 194 |
+
time_value = args[2]
|
| 195 |
+
if 'd' in time_value:
|
| 196 |
+
days = int(time_value.replace('d', ''))
|
| 197 |
+
hours = days * 24
|
| 198 |
+
else:
|
| 199 |
+
hours = int(time_value)
|
| 200 |
+
else:
|
| 201 |
+
hours = int(args[2])
|
| 202 |
+
|
| 203 |
+
if hours <= 0 or hours > 720:
|
| 204 |
+
bot.reply_to(message, "<b>❌ Error</b>\nMaximum 30 days (720 hours)")
|
| 205 |
+
return
|
| 206 |
+
|
| 207 |
+
if not ChEck_Commande(target_id):
|
| 208 |
+
bot.reply_to(message, "<b>❌ Error</b>\nInvalid user_id")
|
| 209 |
+
return
|
| 210 |
+
|
| 211 |
+
with active_spam_lock:
|
| 212 |
+
if target_id in active_room_spam_targets:
|
| 213 |
+
bot.reply_to(message, f"<b>⚠️ This account is already in room spam</b>")
|
| 214 |
+
return
|
| 215 |
+
|
| 216 |
+
active_room_spam_targets[target_id] = {
|
| 217 |
+
'active': True,
|
| 218 |
+
'start_time': datetime.now(),
|
| 219 |
+
'duration': hours,
|
| 220 |
+
'type': 'room',
|
| 221 |
+
'initiator': user_id
|
| 222 |
+
}
|
| 223 |
+
|
| 224 |
+
with spam_start_times_lock:
|
| 225 |
+
spam_start_times[f"room_{target_id}"] = datetime.now()
|
| 226 |
+
|
| 227 |
+
with spam_initiators_lock:
|
| 228 |
+
spam_initiators[f"room_{target_id}"] = user_id
|
| 229 |
+
|
| 230 |
+
threading.Thread(target=room_spam_worker, args=(target_id, hours), daemon=True).start()
|
| 231 |
+
|
| 232 |
+
time_text = "days" if hours >= 24 else "hours"
|
| 233 |
+
time_value = hours // 24 if hours >= 24 else hours
|
| 234 |
+
|
| 235 |
+
bot.reply_to(
|
| 236 |
+
message,
|
| 237 |
+
f"<b>✅ Successfully started room spam for ID <code>{target_id}</code> for {time_value} {time_text}</b>"
|
| 238 |
+
)
|
| 239 |
+
|
| 240 |
+
except ValueError:
|
| 241 |
+
bot.reply_to(message, "<b>❌ Error</b>\nPlease enter a valid number")
|
| 242 |
+
except Exception as e:
|
| 243 |
+
bot.reply_to(message, f"<b>❌ Error:</b> {str(e)}")
|
| 244 |
+
|
| 245 |
+
@bot.message_handler(commands=['status'])
|
| 246 |
+
def status_command(message):
|
| 247 |
+
user_id = message.from_user.id
|
| 248 |
+
args = message.text.split()
|
| 249 |
+
|
| 250 |
+
try:
|
| 251 |
+
if len(args) != 2:
|
| 252 |
+
bot.reply_to(message, "<b>❌ Wrong Format</b>\nUse: <code>/status {id}</code>")
|
| 253 |
+
return
|
| 254 |
+
|
| 255 |
+
target_id = args[1]
|
| 256 |
+
found = False
|
| 257 |
+
|
| 258 |
+
with active_spam_lock:
|
| 259 |
+
if target_id in active_spam_targets:
|
| 260 |
+
with spam_start_times_lock:
|
| 261 |
+
if target_id in spam_start_times:
|
| 262 |
+
start_time = spam_start_times[target_id]
|
| 263 |
+
elapsed = datetime.now() - start_time
|
| 264 |
+
total_seconds = int(elapsed.total_seconds())
|
| 265 |
+
duration = active_spam_targets[target_id]['duration'] * 3600
|
| 266 |
+
remaining = duration - total_seconds
|
| 267 |
+
|
| 268 |
+
if remaining > 0:
|
| 269 |
+
days = remaining // 86400
|
| 270 |
+
hours = (remaining % 86400) // 3600
|
| 271 |
+
minutes = (remaining % 3600) // 60
|
| 272 |
+
seconds = remaining % 60
|
| 273 |
+
|
| 274 |
+
time_parts = []
|
| 275 |
+
if days > 0:
|
| 276 |
+
time_parts.append(f"{days}d")
|
| 277 |
+
if hours > 0:
|
| 278 |
+
time_parts.append(f"{hours}h")
|
| 279 |
+
if minutes > 0:
|
| 280 |
+
time_parts.append(f"{minutes}m")
|
| 281 |
+
if seconds > 0:
|
| 282 |
+
time_parts.append(f"{seconds}s")
|
| 283 |
+
|
| 284 |
+
time_left = " ".join(time_parts)
|
| 285 |
+
|
| 286 |
+
bot.reply_to(
|
| 287 |
+
message,
|
| 288 |
+
f"<b>📊 Spam Status</b>\n\n"
|
| 289 |
+
f"<b>Target:</b> <code>{target_id}</code>\n"
|
| 290 |
+
f"<b>Type:</b> Normal Spam\n"
|
| 291 |
+
f"<b>Time Left:</b> {time_left}\n"
|
| 292 |
+
f"<b>Started By:</b> <code>{active_spam_targets[target_id]['initiator']}</code>"
|
| 293 |
+
)
|
| 294 |
+
found = True
|
| 295 |
+
|
| 296 |
+
if not found:
|
| 297 |
+
with active_spam_lock:
|
| 298 |
+
if target_id in active_room_spam_targets:
|
| 299 |
+
with spam_start_times_lock:
|
| 300 |
+
room_key = f"room_{target_id}"
|
| 301 |
+
if room_key in spam_start_times:
|
| 302 |
+
start_time = spam_start_times[room_key]
|
| 303 |
+
elapsed = datetime.now() - start_time
|
| 304 |
+
total_seconds = int(elapsed.total_seconds())
|
| 305 |
+
duration = active_room_spam_targets[target_id]['duration'] * 3600
|
| 306 |
+
remaining = duration - total_seconds
|
| 307 |
+
|
| 308 |
+
if remaining > 0:
|
| 309 |
+
days = remaining // 86400
|
| 310 |
+
hours = (remaining % 86400) // 3600
|
| 311 |
+
minutes = (remaining % 3600) // 60
|
| 312 |
+
seconds = remaining % 60
|
| 313 |
+
|
| 314 |
+
time_parts = []
|
| 315 |
+
if days > 0:
|
| 316 |
+
time_parts.append(f"{days}d")
|
| 317 |
+
if hours > 0:
|
| 318 |
+
time_parts.append(f"{hours}h")
|
| 319 |
+
if minutes > 0:
|
| 320 |
+
time_parts.append(f"{minutes}m")
|
| 321 |
+
if seconds > 0:
|
| 322 |
+
time_parts.append(f"{seconds}s")
|
| 323 |
+
|
| 324 |
+
time_left = " ".join(time_parts)
|
| 325 |
+
|
| 326 |
+
bot.reply_to(
|
| 327 |
+
message,
|
| 328 |
+
f"<b>📊 Spam Status</b>\n\n"
|
| 329 |
+
f"<b>Target:</b> <code>{target_id}</code>\n"
|
| 330 |
+
f"<b>Type:</b> Room Spam\n"
|
| 331 |
+
f"<b>Time Left:</b> {time_left}\n"
|
| 332 |
+
f"<b>Started By:</b> <code>{active_room_spam_targets[target_id]['initiator']}</code>"
|
| 333 |
+
)
|
| 334 |
+
found = True
|
| 335 |
+
|
| 336 |
+
if not found:
|
| 337 |
+
bot.reply_to(message, f"<b>❌ No active spam found for ID <code>{target_id}</code></b>")
|
| 338 |
+
|
| 339 |
+
except Exception as e:
|
| 340 |
+
bot.reply_to(message, f"<b>❌ Error:</b> {str(e)}")
|
| 341 |
+
|
| 342 |
+
@bot.message_handler(commands=['stop_spam'])
|
| 343 |
+
def stop_spam_command(message):
|
| 344 |
+
user_id = message.from_user.id
|
| 345 |
+
args = message.text.split()
|
| 346 |
+
|
| 347 |
+
try:
|
| 348 |
+
if len(args) != 2:
|
| 349 |
+
bot.reply_to(message, "<b>❌ Wrong Format</b>\nUse: <code>/stop_spam {id}</code>")
|
| 350 |
+
return
|
| 351 |
+
|
| 352 |
+
target_id = args[1]
|
| 353 |
+
|
| 354 |
+
with active_spam_lock:
|
| 355 |
+
if target_id not in active_spam_targets:
|
| 356 |
+
bot.reply_to(message, f"<b>❌ No active spam found for ID <code>{target_id}</code></b>")
|
| 357 |
+
return
|
| 358 |
+
|
| 359 |
+
with spam_initiators_lock:
|
| 360 |
+
initiator = spam_initiators.get(target_id)
|
| 361 |
+
if initiator != user_id and user_id not in ADMIN_IDS:
|
| 362 |
+
bot.reply_to(
|
| 363 |
+
message,
|
| 364 |
+
"<b>⛔ Sorry, you cannot stop this spam. Only the person who added the ID can stop it.</b>"
|
| 365 |
+
)
|
| 366 |
+
return
|
| 367 |
+
|
| 368 |
+
if target_id in spam_initiators:
|
| 369 |
+
del spam_initiators[target_id]
|
| 370 |
+
|
| 371 |
+
with spam_start_times_lock:
|
| 372 |
+
if target_id in spam_start_times:
|
| 373 |
+
del spam_start_times[target_id]
|
| 374 |
+
|
| 375 |
+
del active_spam_targets[target_id]
|
| 376 |
+
|
| 377 |
+
bot.reply_to(
|
| 378 |
+
message,
|
| 379 |
+
f"<b>✅ Successfully stopped spam for target ID <code>{target_id}</code></b>"
|
| 380 |
+
)
|
| 381 |
+
|
| 382 |
+
except Exception as e:
|
| 383 |
+
bot.reply_to(message, f"<b>❌ Error:</b> {str(e)}")
|
| 384 |
+
|
| 385 |
+
@bot.message_handler(commands=['stop_room'])
|
| 386 |
+
def stop_room_command(message):
|
| 387 |
+
user_id = message.from_user.id
|
| 388 |
+
args = message.text.split()
|
| 389 |
+
|
| 390 |
+
try:
|
| 391 |
+
if len(args) != 2:
|
| 392 |
+
bot.reply_to(message, "<b>❌ Wrong Format</b>\nUse: <code>/stop_room {id}</code>")
|
| 393 |
+
return
|
| 394 |
+
|
| 395 |
+
target_id = args[1]
|
| 396 |
+
room_key = f"room_{target_id}"
|
| 397 |
+
|
| 398 |
+
with active_spam_lock:
|
| 399 |
+
if target_id not in active_room_spam_targets:
|
| 400 |
+
bot.reply_to(message, f"<b>❌ No active room spam found for ID <code>{target_id}</code></b>")
|
| 401 |
+
return
|
| 402 |
+
|
| 403 |
+
with spam_initiators_lock:
|
| 404 |
+
initiator = spam_initiators.get(room_key)
|
| 405 |
+
if initiator != user_id and user_id not in ADMIN_IDS:
|
| 406 |
+
bot.reply_to(
|
| 407 |
+
message,
|
| 408 |
+
"<b>⛔ Sorry, you cannot stop this spam. Only the person who added the ID can stop it.</b>"
|
| 409 |
+
)
|
| 410 |
+
return
|
| 411 |
+
|
| 412 |
+
if room_key in spam_initiators:
|
| 413 |
+
del spam_initiators[room_key]
|
| 414 |
+
|
| 415 |
+
with spam_start_times_lock:
|
| 416 |
+
if room_key in spam_start_times:
|
| 417 |
+
del spam_start_times[room_key]
|
| 418 |
+
|
| 419 |
+
del active_room_spam_targets[target_id]
|
| 420 |
+
|
| 421 |
+
bot.reply_to(
|
| 422 |
+
message,
|
| 423 |
+
f"<b>✅ Successfully stopped room spam for target ID <code>{target_id}</code></b>"
|
| 424 |
+
)
|
| 425 |
+
|
| 426 |
+
except Exception as e:
|
| 427 |
+
bot.reply_to(message, f"<b>❌ Error:</b> {str(e)}")
|
| 428 |
+
|
| 429 |
+
@bot.message_handler(commands=['restart'])
|
| 430 |
+
def restart_command(message):
|
| 431 |
+
user_id = message.from_user.id
|
| 432 |
+
|
| 433 |
+
if user_id not in ADMIN_IDS:
|
| 434 |
+
bot.reply_to(message, "<b>❌ This command is for admins only</b>")
|
| 435 |
+
return
|
| 436 |
+
|
| 437 |
+
bot.reply_to(message, "<b>🔄 Restarting accounts...</b>")
|
| 438 |
+
threading.Thread(target=restart_accounts, daemon=True).start()
|
| 439 |
+
|
| 440 |
+
def restart_accounts():
|
| 441 |
+
time.sleep(2)
|
| 442 |
+
ResTarT_BoT()
|
| 443 |
+
|
| 444 |
+
def AuTo_ResTartinG():
|
| 445 |
+
time.sleep(6 * 60 * 60)
|
| 446 |
+
print(' - AuTo ResTartinG The BoT ... ! ')
|
| 447 |
+
p = psutil.Process(os.getpid())
|
| 448 |
+
for handler in p.open_files():
|
| 449 |
+
try:
|
| 450 |
+
os.close(handler.fd)
|
| 451 |
+
except Exception as e:
|
| 452 |
+
print(f" - Error CLose Files : {e}")
|
| 453 |
+
for conn in p.net_connections():
|
| 454 |
+
try:
|
| 455 |
+
if hasattr(conn, 'fd'):
|
| 456 |
+
os.close(conn.fd)
|
| 457 |
+
except Exception as e:
|
| 458 |
+
print(f" - Error CLose Connection : {e}")
|
| 459 |
+
sys.path.append(os.path.dirname(os.path.abspath(sys.argv[0])))
|
| 460 |
+
python = sys.executable
|
| 461 |
+
os.execl(python, python, *sys.argv)
|
| 462 |
+
|
| 463 |
+
def ResTarT_BoT():
|
| 464 |
+
print(' - ResTartinG The BoT ... ! ')
|
| 465 |
+
p = psutil.Process(os.getpid())
|
| 466 |
+
open_files = p.open_files()
|
| 467 |
+
connections = p.net_connections()
|
| 468 |
+
for handler in open_files:
|
| 469 |
+
try:
|
| 470 |
+
os.close(handler.fd)
|
| 471 |
+
except Exception:
|
| 472 |
+
pass
|
| 473 |
+
for conn in connections:
|
| 474 |
+
try:
|
| 475 |
+
conn.close()
|
| 476 |
+
except Exception:
|
| 477 |
+
pass
|
| 478 |
+
sys.path.append(os.path.dirname(os.path.abspath(sys.argv[0])))
|
| 479 |
+
python = sys.executable
|
| 480 |
+
os.execl(python, python, *sys.argv)
|
| 481 |
+
|
| 482 |
+
def GeT_Time(timestamp):
|
| 483 |
+
last_login = datetime.fromtimestamp(timestamp)
|
| 484 |
+
now = datetime.now()
|
| 485 |
+
diff = now - last_login
|
| 486 |
+
d = diff.days
|
| 487 |
+
h , rem = divmod(diff.seconds, 3600)
|
| 488 |
+
m , s = divmod(rem, 60)
|
| 489 |
+
return d, h, m, s
|
| 490 |
+
|
| 491 |
+
def Time_En_Ar(t):
|
| 492 |
+
return ' '.join(t.replace("Day","Day").replace("Hour","Hour").replace("Min","Min").replace("Sec","Sec").split(" - "))
|
| 493 |
+
|
| 494 |
+
Thread(target = AuTo_ResTartinG , daemon = True).start()
|
| 495 |
+
|
| 496 |
+
ACCOUNTS = []
|
| 497 |
+
|
| 498 |
+
def load_accounts_from_file(filename="accs.json"):
|
| 499 |
+
accounts = []
|
| 500 |
+
try:
|
| 501 |
+
with open(filename, "r", encoding="utf-8") as file:
|
| 502 |
+
data = json.load(file)
|
| 503 |
+
|
| 504 |
+
if isinstance(data, list):
|
| 505 |
+
for account in data:
|
| 506 |
+
if isinstance(account, dict):
|
| 507 |
+
account_id = account.get('uid', '')
|
| 508 |
+
password = account.get('password', '')
|
| 509 |
+
|
| 510 |
+
if account_id:
|
| 511 |
+
accounts.append({
|
| 512 |
+
'id': str(account_id),
|
| 513 |
+
'password': password
|
| 514 |
+
})
|
| 515 |
+
|
| 516 |
+
print(f"Loaded {len(accounts)} accounts from {filename}")
|
| 517 |
+
|
| 518 |
+
except FileNotFoundError:
|
| 519 |
+
print(f"File {filename} not found!")
|
| 520 |
+
except json.JSONDecodeError:
|
| 521 |
+
print(f"JSON format error in file {filename}!")
|
| 522 |
+
except Exception as e:
|
| 523 |
+
print(f"Error reading file: {e}")
|
| 524 |
+
|
| 525 |
+
return accounts
|
| 526 |
+
|
| 527 |
+
ACCOUNTS = load_accounts_from_file()
|
| 528 |
+
|
| 529 |
+
def normal_spam_worker(target_id, duration_hours=None):
|
| 530 |
+
print(f"Starting normal spam on target: {target_id}" + (f" for {duration_hours} hours" if duration_hours else ""))
|
| 531 |
+
|
| 532 |
+
start_time = datetime.now()
|
| 533 |
+
|
| 534 |
+
while True:
|
| 535 |
+
with active_spam_lock:
|
| 536 |
+
if target_id not in active_spam_targets:
|
| 537 |
+
print(f"Normal spam stopped on target: {target_id}")
|
| 538 |
+
break
|
| 539 |
+
|
| 540 |
+
if duration_hours:
|
| 541 |
+
elapsed = datetime.now() - start_time
|
| 542 |
+
if elapsed.total_seconds() >= duration_hours * 3600:
|
| 543 |
+
print(f"Normal spam duration ended for target: {target_id}")
|
| 544 |
+
with spam_initiators_lock:
|
| 545 |
+
if target_id in spam_initiators:
|
| 546 |
+
del spam_initiators[target_id]
|
| 547 |
+
with spam_start_times_lock:
|
| 548 |
+
if target_id in spam_start_times:
|
| 549 |
+
del spam_start_times[target_id]
|
| 550 |
+
del active_spam_targets[target_id]
|
| 551 |
+
break
|
| 552 |
+
|
| 553 |
+
try:
|
| 554 |
+
send_normal_spam_from_all_accounts(target_id)
|
| 555 |
+
time.sleep(0.1)
|
| 556 |
+
except Exception as e:
|
| 557 |
+
print(f"Error in normal spam on {target_id}: {e}")
|
| 558 |
+
time.sleep(1)
|
| 559 |
+
|
| 560 |
+
def room_spam_worker(target_id, duration_hours=None):
|
| 561 |
+
print(f"Starting room spam on target: {target_id}" + (f" for {duration_hours} hours" if duration_hours else ""))
|
| 562 |
+
|
| 563 |
+
start_time = datetime.now()
|
| 564 |
+
|
| 565 |
+
while True:
|
| 566 |
+
with active_spam_lock:
|
| 567 |
+
if target_id not in active_room_spam_targets:
|
| 568 |
+
print(f"Room spam stopped on target: {target_id}")
|
| 569 |
+
break
|
| 570 |
+
|
| 571 |
+
if duration_hours:
|
| 572 |
+
elapsed = datetime.now() - start_time
|
| 573 |
+
if elapsed.total_seconds() >= duration_hours * 3600:
|
| 574 |
+
print(f"Room spam duration ended for target: {target_id}")
|
| 575 |
+
with spam_initiators_lock:
|
| 576 |
+
room_key = f"room_{target_id}"
|
| 577 |
+
if room_key in spam_initiators:
|
| 578 |
+
del spam_initiators[room_key]
|
| 579 |
+
with spam_start_times_lock:
|
| 580 |
+
if room_key in spam_start_times:
|
| 581 |
+
del spam_start_times[room_key]
|
| 582 |
+
del active_room_spam_targets[target_id]
|
| 583 |
+
break
|
| 584 |
+
|
| 585 |
+
try:
|
| 586 |
+
send_room_spam_from_all_accounts(target_id)
|
| 587 |
+
time.sleep(0.1)
|
| 588 |
+
except Exception as e:
|
| 589 |
+
print(f"Error in room spam on {target_id}: {e}")
|
| 590 |
+
time.sleep(1)
|
| 591 |
+
|
| 592 |
+
def send_normal_spam_from_all_accounts(target_id):
|
| 593 |
+
with connected_clients_lock:
|
| 594 |
+
for account_id, client in connected_clients.items():
|
| 595 |
+
try:
|
| 596 |
+
if (hasattr(client, 'CliEnts2') and client.CliEnts2 and
|
| 597 |
+
hasattr(client, 'key') and client.key and
|
| 598 |
+
hasattr(client, 'iv') and client.iv):
|
| 599 |
+
|
| 600 |
+
for i in range(10):
|
| 601 |
+
try:
|
| 602 |
+
client.CliEnts2.send(SEnd_InV(1, target_id, client.key, client.iv))
|
| 603 |
+
client.CliEnts2.send(OpEnSq(client.key, client.iv))
|
| 604 |
+
client.CliEnts2.send(SPamSq(target_id, client.key, client.iv))
|
| 605 |
+
except (BrokenPipeError, ConnectionResetError, OSError) as e:
|
| 606 |
+
print(f"Connection error for account {account_id}: {e}")
|
| 607 |
+
break
|
| 608 |
+
except Exception as e:
|
| 609 |
+
print(f"Error sending from account {account_id}: {e}")
|
| 610 |
+
break
|
| 611 |
+
else:
|
| 612 |
+
print(f"Account {account_id} connection is inactive")
|
| 613 |
+
except Exception as e:
|
| 614 |
+
print(f"Error sending normal spam from account {account_id}: {e}")
|
| 615 |
+
|
| 616 |
+
def send_room_spam_from_all_accounts(target_id):
|
| 617 |
+
with connected_clients_lock:
|
| 618 |
+
for account_id, client in connected_clients.items():
|
| 619 |
+
try:
|
| 620 |
+
if (hasattr(client, 'CliEnts2') and client.CliEnts2 and
|
| 621 |
+
hasattr(client, 'key') and client.key and
|
| 622 |
+
hasattr(client, 'iv') and client.iv):
|
| 623 |
+
|
| 624 |
+
try:
|
| 625 |
+
client.CliEnts2.send(openroom(client.key, client.iv))
|
| 626 |
+
except Exception as e:
|
| 627 |
+
print(f"Error opening room from account {account_id}: {e}")
|
| 628 |
+
|
| 629 |
+
for i in range(10):
|
| 630 |
+
try:
|
| 631 |
+
client.CliEnts2.send(spmroom(client.key, client.iv, target_id))
|
| 632 |
+
except (BrokenPipeError, ConnectionResetError, OSError) as e:
|
| 633 |
+
print(f"Connection error for account {account_id}: {e}")
|
| 634 |
+
break
|
| 635 |
+
except Exception as e:
|
| 636 |
+
print(f"Error sending from account {account_id}: {e}")
|
| 637 |
+
break
|
| 638 |
+
else:
|
| 639 |
+
print(f"Account {account_id} connection is inactive")
|
| 640 |
+
except Exception as e:
|
| 641 |
+
print(f"Error sending room spam from account {account_id}: {e}")
|
| 642 |
+
|
| 643 |
+
class FF_CLient():
|
| 644 |
+
|
| 645 |
+
def __init__(self, id, password):
|
| 646 |
+
self.id = id
|
| 647 |
+
self.password = password
|
| 648 |
+
self.key = None
|
| 649 |
+
self.iv = None
|
| 650 |
+
self.connection_active = True
|
| 651 |
+
self.Get_FiNal_ToKen_0115()
|
| 652 |
+
|
| 653 |
+
def Connect_SerVer_OnLine(self , Token , tok , host , port , key , iv , host2 , port2):
|
| 654 |
+
try:
|
| 655 |
+
self.AutH_ToKen_0115 = tok
|
| 656 |
+
self.CliEnts2 = socket.create_connection((host2 , int(port2)))
|
| 657 |
+
self.CliEnts2.send(bytes.fromhex(self.AutH_ToKen_0115))
|
| 658 |
+
except:pass
|
| 659 |
+
while self.connection_active:
|
| 660 |
+
try:
|
| 661 |
+
self.DaTa2 = self.CliEnts2.recv(99999)
|
| 662 |
+
if '0500' in self.DaTa2.hex()[0:4] and len(self.DaTa2.hex()) > 30:
|
| 663 |
+
self.packet = json.loads(DeCode_PackEt(f'08{self.DaTa2.hex().split("08", 1)[1]}'))
|
| 664 |
+
self.AutH = self.packet['5']['data']['7']['data']
|
| 665 |
+
except:pass
|
| 666 |
+
|
| 667 |
+
def Connect_SerVer(self , Token , tok , host , port , key , iv , host2 , port2):
|
| 668 |
+
self.AutH_ToKen_0115 = tok
|
| 669 |
+
self.CliEnts = socket.create_connection((host , int(port)))
|
| 670 |
+
self.CliEnts.send(bytes.fromhex(self.AutH_ToKen_0115))
|
| 671 |
+
self.DaTa = self.CliEnts.recv(1024)
|
| 672 |
+
threading.Thread(target=self.Connect_SerVer_OnLine, args=(Token , tok , host , port , key , iv , host2 , port2)).start()
|
| 673 |
+
self.Exemple = xMsGFixinG('12345678')
|
| 674 |
+
|
| 675 |
+
self.key = key
|
| 676 |
+
self.iv = iv
|
| 677 |
+
|
| 678 |
+
with connected_clients_lock:
|
| 679 |
+
connected_clients[self.id] = self
|
| 680 |
+
print(f"Account {self.id} registered, total accounts: {len(connected_clients)}")
|
| 681 |
+
|
| 682 |
+
while True:
|
| 683 |
+
try:
|
| 684 |
+
self.DaTa = self.CliEnts.recv(1024)
|
| 685 |
+
if len(self.DaTa) == 0 or (hasattr(self, 'DaTa2') and len(self.DaTa2) == 0):
|
| 686 |
+
print(f"Connection lost for account {self.id}, reconnecting...")
|
| 687 |
+
try:
|
| 688 |
+
self.CliEnts.close()
|
| 689 |
+
if hasattr(self, 'CliEnts2'):
|
| 690 |
+
self.CliEnts2.close()
|
| 691 |
+
|
| 692 |
+
time.sleep(3)
|
| 693 |
+
self.Connect_SerVer(Token , tok , host , port , key , iv , host2 , port2)
|
| 694 |
+
except:
|
| 695 |
+
print(f"Failed to reconnect account {self.id}")
|
| 696 |
+
with connected_clients_lock:
|
| 697 |
+
if self.id in connected_clients:
|
| 698 |
+
del connected_clients[self.id]
|
| 699 |
+
break
|
| 700 |
+
|
| 701 |
+
if '/pp/' in self.input_msg[:4]:
|
| 702 |
+
self.target_id = self.input_msg[4:]
|
| 703 |
+
self.Zx = ChEck_Commande(self.target_id)
|
| 704 |
+
if True == self.Zx:
|
| 705 |
+
threading.Thread(target=send_normal_spam_from_all_accounts, args=(self.target_id,)).start()
|
| 706 |
+
time.sleep(2.5)
|
| 707 |
+
self.CliEnts.send(xSEndMsg(f'\n[b][c][{ArA_CoLor()}] SuccEss Spam To {xMsGFixinG(self.target_id)} From All Accounts\n', 2 , self.DeCode_CliEnt_Uid , self.DeCode_CliEnt_Uid , key , iv))
|
| 708 |
+
time.sleep(1.3)
|
| 709 |
+
self.CliEnts.close()
|
| 710 |
+
if hasattr(self, 'CliEnts2'):
|
| 711 |
+
self.CliEnts2.close()
|
| 712 |
+
self.Connect_SerVer(Token , tok , host , port , key , iv , host2 , port2)
|
| 713 |
+
elif False == self.Zx:
|
| 714 |
+
self.CliEnts.send(xSEndMsg(f'\n[b][c][{ArA_CoLor()}] - PLease Use /pp/<id>\n - Ex : /pp/{self.Exemple}\n', 2 , self.DeCode_CliEnt_Uid , self.DeCode_CliEnt_Uid , key , iv))
|
| 715 |
+
time.sleep(1.1)
|
| 716 |
+
self.CliEnts.close()
|
| 717 |
+
if hasattr(self, 'CliEnts2'):
|
| 718 |
+
self.CliEnts2.close()
|
| 719 |
+
self.Connect_SerVer(Token , tok , host , port , key , iv , host2 , port2)
|
| 720 |
+
|
| 721 |
+
except Exception as e:
|
| 722 |
+
print(f"Error in Connect_SerVer: {e}")
|
| 723 |
+
try:
|
| 724 |
+
self.CliEnts.close()
|
| 725 |
+
if hasattr(self, 'CliEnts2'):
|
| 726 |
+
self.CliEnts2.close()
|
| 727 |
+
except:
|
| 728 |
+
pass
|
| 729 |
+
time.sleep(5)
|
| 730 |
+
try:
|
| 731 |
+
self.Connect_SerVer(Token , tok , host , port , key , iv , host2 , port2)
|
| 732 |
+
except:
|
| 733 |
+
print(f"Final reconnection failed for account {self.id}")
|
| 734 |
+
with connected_clients_lock:
|
| 735 |
+
if self.id in connected_clients:
|
| 736 |
+
del connected_clients[self.id]
|
| 737 |
+
break
|
| 738 |
+
|
| 739 |
+
def GeT_Key_Iv(self , serialized_data):
|
| 740 |
+
my_message = xKEys.MyMessage()
|
| 741 |
+
my_message.ParseFromString(serialized_data)
|
| 742 |
+
timestamp , key , iv = my_message.field21 , my_message.field22 , my_message.field23
|
| 743 |
+
timestamp_obj = Timestamp()
|
| 744 |
+
timestamp_obj.FromNanoseconds(timestamp)
|
| 745 |
+
timestamp_seconds = timestamp_obj.seconds
|
| 746 |
+
timestamp_nanos = timestamp_obj.nanos
|
| 747 |
+
combined_timestamp = timestamp_seconds * 1_000_000_000 + timestamp_nanos
|
| 748 |
+
return combined_timestamp , key , iv
|
| 749 |
+
|
| 750 |
+
def Guest_GeneRaTe(self , uid , password):
|
| 751 |
+
self.url = "https://100067.connect.garena.com/oauth/guest/token/grant"
|
| 752 |
+
self.headers = {"Host": "100067.connect.garena.com","User-Agent": "GarenaMSDK/4.0.19P4(G011A ;Android 9;en;US;)","Content-Type": "application/x-www-form-urlencoded","Accept-Encoding": "gzip, deflate, br","Connection": "close",}
|
| 753 |
+
self.dataa = {"uid": f"{uid}","password": f"{password}","response_type": "token","client_type": "2","client_secret": "2ee44819e9b4598845141067b281621874d0d5d7af9d8f7e00c1e54715b7d1e3","client_id": "100067",}
|
| 754 |
+
try:
|
| 755 |
+
self.response = requests.post(self.url, headers=self.headers, data=self.dataa).json()
|
| 756 |
+
self.Access_ToKen = self.response.get('access_token')
|
| 757 |
+
self.Access_Uid = self.response.get('open_id')
|
| 758 |
+
|
| 759 |
+
if not self.Access_ToKen or not self.Access_Uid:
|
| 760 |
+
print(f"Login failed or missing token for UID: {uid}")
|
| 761 |
+
return None
|
| 762 |
+
|
| 763 |
+
time.sleep(0.2)
|
| 764 |
+
return self.ToKen_GeneRaTe(self.Access_ToKen , self.Access_Uid)
|
| 765 |
+
except Exception as e:
|
| 766 |
+
print(f"Error in Guest_GeneRaTe: {e}")
|
| 767 |
+
time.sleep(10)
|
| 768 |
+
return None
|
| 769 |
+
|
| 770 |
+
def GeT_LoGin_PorTs(self , JwT_ToKen , PayLoad):
|
| 771 |
+
self.UrL = 'https://clientbp.ggwhitehawk.com/GetLoginData'
|
| 772 |
+
self.HeadErs = {
|
| 773 |
+
'Expect': '100-continue',
|
| 774 |
+
'Authorization': f'Bearer {JwT_ToKen}',
|
| 775 |
+
'X-Unity-Version': '2022.3.47f1',
|
| 776 |
+
'X-GA': 'v1 1',
|
| 777 |
+
'ReleaseVersion': 'OB52',
|
| 778 |
+
'Content-Type': 'application/x-www-form-urlencoded',
|
| 779 |
+
'User-Agent': 'UnityPlayer/2022.3.47f1 (UnityWebRequest/1.0, libcurl/8.5.0-DEV)',
|
| 780 |
+
'Host': 'clientbp.ggwhitehawk.com',
|
| 781 |
+
'Connection': 'close',
|
| 782 |
+
'Accept-Encoding': 'deflate, gzip',}
|
| 783 |
+
try:
|
| 784 |
+
self.Res = requests.post(self.UrL , headers=self.HeadErs , data=PayLoad , verify=False)
|
| 785 |
+
self.BesTo_data = json.loads(DeCode_PackEt(self.Res.content.hex()))
|
| 786 |
+
address , address2 = self.BesTo_data['32']['data'] , self.BesTo_data['14']['data']
|
| 787 |
+
ip , ip2 = address[:len(address) - 6] , address2[:len(address2) - 6]
|
| 788 |
+
port , port2 = address[len(address) - 5:] , address2[len(address2) - 5:]
|
| 789 |
+
return ip , port , ip2 , port2
|
| 790 |
+
except requests.RequestException as e:
|
| 791 |
+
print(f" - Bad Requests !")
|
| 792 |
+
print(" - Failed To GeT PorTs !")
|
| 793 |
+
return None, None, None, None
|
| 794 |
+
|
| 795 |
+
def ToKen_GeneRaTe(self , Access_ToKen , Access_Uid):
|
| 796 |
+
self.UrL = "https://loginbp.ggwhitehawk.com/MajorLogin"
|
| 797 |
+
self.HeadErs = {
|
| 798 |
+
'X-Unity-Version': '2022.3.47f1',
|
| 799 |
+
'ReleaseVersion': 'OB52',
|
| 800 |
+
'Content-Type': 'application/x-www-form-urlencoded',
|
| 801 |
+
'X-GA': 'v1 1',
|
| 802 |
+
'Content-Length': '928',
|
| 803 |
+
'User-Agent': 'UnityPlayer/2022.3.47f1 (UnityWebRequest/1.0, libcurl/8.5.0-DEV)',
|
| 804 |
+
'Host': 'loginbp.ggwhitehawk.com',
|
| 805 |
+
'Connection': 'Keep-Alive',
|
| 806 |
+
'Accept-Encoding': 'deflate, gzip'}
|
| 807 |
+
|
| 808 |
+
self.dT = bytes.fromhex('1a13323032362d30312d31342031323a31393a3032220966726565206669726528013a07312e3132302e324232416e64726f6964204f532039202f204150492d3238202850492f72656c2e636a772e32303232303531382e313134313333294a0848616e6468656c64520c4d544e2f537061636574656c5a045749464960800a68d00572033234307a2d7838362d3634205353453320535345342e3120535345342e32204156582041565832207c2032343030207c20348001e61e8a010f416472656e6f2028544d292036343092010d4f70656e474c20455320332e329a012b476f6f676c657c36323566373136662d393161372d343935622d396631362d303866653964336336353333a2010d3137362e32382e3134352e3239aa01026172b201203931333263366662373263616363666463383132306439656332636330366238ba010134c2010848616e6468656c64ca010d4f6e65506c7573204135313030d201025347ea014033646661396162396432353237306661663433326637623532383536346265396563343739306263373434613465626137303232353230373432376430633430f00101ca020c4d544e2f537061636574656cd2020457494649ca03203161633462383065636630343738613434323033626638666163363132306635e003b5ee02e803c28302f003af13f80384078004cf92028804b5ee029004cf92029804b5ee02b00404c80403d20433d2f646174612f6170702f636f6d2e6474732e667265656669726574682d49316855713474347641365f516f34432d58676165513d3d2f6c69622f61726de00401ea045f65363261623933353464386662356662303831646233333861636233333439317c2f646174612f6170702f636f6d2e6474732e667265656669726574682d49316855713474347641365f516f34432d58676165513d3d2f626173652e61706bf00406f804018a050233329a050a32303139313139363234b205094f70656e474c455332b805ff01c00504e005edb402ea05093372645f7061727479f2055c4b7173485438512b6c73302b4464496c2f4f617652726f7670795a596377676e51485151636d57776a476d587642514b4f4d63747870796f7054515754487653354a714d6967476b534c434c423651387839544161764d666c6a6f3d8806019006019a060134a2060134b206224006474f56540a011a5d0e115e00170d4b6e085709510a685a02586800096f000161')
|
| 809 |
+
|
| 810 |
+
self.dT = self.dT.replace(b'2026-01-14 12:19:02' , str(datetime.now())[:-7].encode())
|
| 811 |
+
self.dT = self.dT.replace(b'3dfa9ab9d25270faf432f7b528564be9ec4790bc744a4eba70225207427d0c40' , Access_ToKen.encode())
|
| 812 |
+
self.dT = self.dT.replace(b'9132c6fb72caccfdc8120d9ec2cc06b8' , Access_Uid.encode())
|
| 813 |
+
|
| 814 |
+
try:
|
| 815 |
+
hex_data = self.dT.hex()
|
| 816 |
+
encoded_data = EnC_AEs(hex_data)
|
| 817 |
+
|
| 818 |
+
if not all(c in '0123456789abcdefABCDEF' for c in encoded_data):
|
| 819 |
+
print("Invalid hex output from EnC_AEs, using alternative encoding")
|
| 820 |
+
encoded_data = hex_data
|
| 821 |
+
|
| 822 |
+
self.PaYload = bytes.fromhex(encoded_data)
|
| 823 |
+
except Exception as e:
|
| 824 |
+
print(f"Error in encoding: {e}")
|
| 825 |
+
self.PaYload = self.dT
|
| 826 |
+
|
| 827 |
+
self.ResPonse = requests.post(self.UrL, headers = self.HeadErs , data = self.PaYload , verify=False)
|
| 828 |
+
if self.ResPonse.status_code == 200 and len(self.ResPonse.text) > 10:
|
| 829 |
+
try:
|
| 830 |
+
self.BesTo_data = json.loads(DeCode_PackEt(self.ResPonse.content.hex()))
|
| 831 |
+
self.JwT_ToKen = self.BesTo_data['8']['data']
|
| 832 |
+
self.combined_timestamp , self.key , self.iv = self.GeT_Key_Iv(self.ResPonse.content)
|
| 833 |
+
ip , port , ip2 , port2 = self.GeT_LoGin_PorTs(self.JwT_ToKen , self.PaYload)
|
| 834 |
+
return self.JwT_ToKen , self.key , self.iv, self.combined_timestamp , ip , port , ip2 , port2
|
| 835 |
+
except Exception as e:
|
| 836 |
+
print(f"Error parsing response: {e}")
|
| 837 |
+
time.sleep(5)
|
| 838 |
+
return self.ToKen_GeneRaTe(Access_ToKen, Access_Uid)
|
| 839 |
+
else:
|
| 840 |
+
print(f"Error in ToKen_GeneRaTe, status: {self.ResPonse.status_code}")
|
| 841 |
+
time.sleep(5)
|
| 842 |
+
return self.ToKen_GeneRaTe(Access_ToKen, Access_Uid)
|
| 843 |
+
|
| 844 |
+
def Get_FiNal_ToKen_0115(self):
|
| 845 |
+
try:
|
| 846 |
+
result = self.Guest_GeneRaTe(self.id , self.password)
|
| 847 |
+
if not result:
|
| 848 |
+
print("Failed to get tokens, retrying...")
|
| 849 |
+
time.sleep(5)
|
| 850 |
+
return self.Get_FiNal_ToKen_0115()
|
| 851 |
+
|
| 852 |
+
token , key , iv , Timestamp , ip , port , ip2 , port2 = result
|
| 853 |
+
|
| 854 |
+
if not all([ip, port, ip2, port2]):
|
| 855 |
+
print("Failed to get ports, retrying...")
|
| 856 |
+
time.sleep(5)
|
| 857 |
+
return self.Get_FiNal_ToKen_0115()
|
| 858 |
+
|
| 859 |
+
self.JwT_ToKen = token
|
| 860 |
+
try:
|
| 861 |
+
self.AfTer_DeC_JwT = jwt.decode(token, options={"verify_signature": False})
|
| 862 |
+
self.AccounT_Uid = self.AfTer_DeC_JwT.get('account_id')
|
| 863 |
+
self.EncoDed_AccounT = hex(self.AccounT_Uid)[2:]
|
| 864 |
+
self.HeX_VaLue = DecodE_HeX(Timestamp)
|
| 865 |
+
self.TimE_HEx = self.HeX_VaLue
|
| 866 |
+
self.JwT_ToKen_ = token.encode().hex()
|
| 867 |
+
print(f'ProxCed Uid : {self.AccounT_Uid}')
|
| 868 |
+
except Exception as e:
|
| 869 |
+
print(f"Error In ToKen : {e}")
|
| 870 |
+
time.sleep(5)
|
| 871 |
+
return self.Get_FiNal_ToKen_0115()
|
| 872 |
+
|
| 873 |
+
try:
|
| 874 |
+
self.Header = hex(len(EnC_PacKeT(self.JwT_ToKen_, key, iv)) // 2)[2:]
|
| 875 |
+
length = len(self.EncoDed_AccounT)
|
| 876 |
+
self.__ = '00000000'
|
| 877 |
+
if length == 9: self.__ = '0000000'
|
| 878 |
+
elif length == 8: self.__ = '00000000'
|
| 879 |
+
elif length == 10: self.__ = '000000'
|
| 880 |
+
elif length == 7: self.__ = '000000000'
|
| 881 |
+
else:
|
| 882 |
+
print('Unexpected length encountered')
|
| 883 |
+
self.Header = f'0115{self.__}{self.EncoDed_AccounT}{self.TimE_HEx}00000{self.Header}'
|
| 884 |
+
self.FiNal_ToKen_0115 = self.Header + EnC_PacKeT(self.JwT_ToKen_ , key , iv)
|
| 885 |
+
except Exception as e:
|
| 886 |
+
print(f"Error In Final Token : {e}")
|
| 887 |
+
time.sleep(5)
|
| 888 |
+
return self.Get_FiNal_ToKen_0115()
|
| 889 |
+
|
| 890 |
+
self.AutH_ToKen = self.FiNal_ToKen_0115
|
| 891 |
+
self.Connect_SerVer(self.JwT_ToKen , self.AutH_ToKen , ip , port , key , iv , ip2 , port2)
|
| 892 |
+
return self.AutH_ToKen , key , iv
|
| 893 |
+
|
| 894 |
+
except Exception as e:
|
| 895 |
+
print(f"Error in Get_FiNal_ToKen_0115: {e}")
|
| 896 |
+
time.sleep(10)
|
| 897 |
+
return self.Get_FiNal_ToKen_0115()
|
| 898 |
+
|
| 899 |
+
def start_account(account):
|
| 900 |
+
try:
|
| 901 |
+
print(f"Starting account: {account['id']}")
|
| 902 |
+
FF_CLient(account['id'], account['password'])
|
| 903 |
+
except Exception as e:
|
| 904 |
+
print(f"Error starting account {account['id']}: {e}")
|
| 905 |
+
time.sleep(5)
|
| 906 |
+
start_account(account)
|
| 907 |
+
|
| 908 |
+
def run_bot():
|
| 909 |
+
print("Bot started...")
|
| 910 |
+
if WEBHOOK_URL:
|
| 911 |
+
try:
|
| 912 |
+
bot.remove_webhook()
|
| 913 |
+
time.sleep(1)
|
| 914 |
+
webhook_full_url = WEBHOOK_URL.rstrip('/') + '/' + TOKEN
|
| 915 |
+
bot.set_webhook(url=webhook_full_url)
|
| 916 |
+
print(f"Webhook set successfully to: {webhook_full_url}")
|
| 917 |
+
except Exception as e:
|
| 918 |
+
print(f"Failed to set webhook (will still receive updates if pre-configured): {e}")
|
| 919 |
+
else:
|
| 920 |
+
print("No WEBHOOK_URL set, running in passive webhook mode")
|
| 921 |
+
print("Bot is ready to receive webhook updates via Flask")
|
| 922 |
+
|
| 923 |
+
@app.route('/' + TOKEN, methods=['POST'])
|
| 924 |
+
def webhook():
|
| 925 |
+
if request.headers.get('content-type') == 'application/json':
|
| 926 |
+
json_string = request.get_data().decode('utf-8')
|
| 927 |
+
update = telebot.types.Update.de_json(json_string)
|
| 928 |
+
bot.process_new_updates([update])
|
| 929 |
+
return ''
|
| 930 |
+
else:
|
| 931 |
+
abort(403)
|
| 932 |
+
|
| 933 |
+
@app.route('/')
|
| 934 |
+
def index():
|
| 935 |
+
return 'Bot is running!'
|
| 936 |
+
|
| 937 |
+
def StarT_SerVer():
|
| 938 |
+
threads = []
|
| 939 |
+
|
| 940 |
+
for account in ACCOUNTS:
|
| 941 |
+
thread = threading.Thread(target=start_account, args=(account,))
|
| 942 |
+
thread.daemon = True
|
| 943 |
+
threads.append(thread)
|
| 944 |
+
thread.start()
|
| 945 |
+
time.sleep(1)
|
| 946 |
+
|
| 947 |
+
for thread in threads:
|
| 948 |
+
thread.join()
|
| 949 |
+
|
| 950 |
+
if __name__ == "__main__":
|
| 951 |
+
bot_thread = threading.Thread(target=run_bot, daemon=True)
|
| 952 |
+
bot_thread.start()
|
| 953 |
+
accounts_thread = threading.Thread(target=StarT_SerVer, daemon=True)
|
| 954 |
+
accounts_thread.start()
|
| 955 |
+
print("Starting Flask server for webhook...")
|
| 956 |
+
app.run(host='0.0.0.0', port=7860)
|