Update app.py
Browse files
app.py
CHANGED
|
@@ -15,6 +15,10 @@ from telethon import TelegramClient, events, Button
|
|
| 15 |
from telethon.sessions import StringSession
|
| 16 |
from telethon.tl import functions
|
| 17 |
import re
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
|
| 19 |
# βββββ Utils βββββ
|
| 20 |
adjectives = ["Silent", "Crazy", "Golden", "Hidden", "Brave", "Fierce", "Mysterious", "Savage", "Royal", "Witty", "Legendary", "Epic", "Noble", "Clever", "Loyal", "Wild", "Electric", "Fearless", "Crimson", "Frozen", "Charming", "Rebel", "Turbo", "Lone", "Radiant", "Raging", "Dusty", "Majestic", "Grumpy", "Shadow"]
|
|
@@ -257,14 +261,29 @@ async def help_cmd(event):
|
|
| 257 |
"These commands are available to the admin only."
|
| 258 |
)
|
| 259 |
|
| 260 |
-
@bot.on(events.NewMessage(pattern="/addacc"))
|
| 261 |
async def addacc_cmd(event):
|
| 262 |
-
|
| 263 |
-
|
| 264 |
-
|
| 265 |
-
await conv.
|
| 266 |
-
|
| 267 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 268 |
info = await start_userbot(session_str, event.sender_id)
|
| 269 |
if info:
|
| 270 |
await conv.send_message(f"β
Added: {info.first_name} (@{info.username or 'N/A'})")
|
|
|
|
| 15 |
from telethon.sessions import StringSession
|
| 16 |
from telethon.tl import functions
|
| 17 |
import re
|
| 18 |
+
from telethon.tl.custom import Conversation
|
| 19 |
+
from telethon import TelegramClient, events
|
| 20 |
+
from telethon.sessions import StringSession
|
| 21 |
+
from session_converter import SessionManager
|
| 22 |
|
| 23 |
# βββββ Utils βββββ
|
| 24 |
adjectives = ["Silent", "Crazy", "Golden", "Hidden", "Brave", "Fierce", "Mysterious", "Savage", "Royal", "Witty", "Legendary", "Epic", "Noble", "Clever", "Loyal", "Wild", "Electric", "Fearless", "Crimson", "Frozen", "Charming", "Rebel", "Turbo", "Lone", "Radiant", "Raging", "Dusty", "Majestic", "Grumpy", "Shadow"]
|
|
|
|
| 261 |
"These commands are available to the admin only."
|
| 262 |
)
|
| 263 |
|
| 264 |
+
@bot.on(events.NewMessage(pattern="/addacc", chats=ADMIN_ID))
|
| 265 |
async def addacc_cmd(event):
|
| 266 |
+
|
| 267 |
+
async with control_bot.conversation(event.chat_id, timeout=300) as conv:
|
| 268 |
+
await conv.send_message("π© Send your StringSession:")
|
| 269 |
+
msg = await conv.get_response()
|
| 270 |
+
session_str = msg.raw_text.strip()
|
| 271 |
+
|
| 272 |
+
# Step 1: Detect and convert Pyrogram β Telethon
|
| 273 |
+
try:
|
| 274 |
+
if not session_str.startswith(("1A", "1B")): # Likely Pyrogram
|
| 275 |
+
try:
|
| 276 |
+
session_manager = SessionManager.from_pyrogram_string_session(session_str)
|
| 277 |
+
session_str = session_manager.telethon_string_session()
|
| 278 |
+
await conv.send_message("π Converted Pyrogram session to Telethon.")
|
| 279 |
+
except Exception as e:
|
| 280 |
+
await conv.send_message(f"β Pyrogram conversion failed:\n`{e}`")
|
| 281 |
+
return
|
| 282 |
+
else:
|
| 283 |
+
await conv.send_message("β
Detected Telethon session.")
|
| 284 |
+
except Exception as e:
|
| 285 |
+
await conv.send_message(f"β Session detection failed:\n`{e}`")
|
| 286 |
+
return
|
| 287 |
info = await start_userbot(session_str, event.sender_id)
|
| 288 |
if info:
|
| 289 |
await conv.send_message(f"β
Added: {info.first_name} (@{info.username or 'N/A'})")
|