soxogvv commited on
Commit
280a76b
Β·
verified Β·
1 Parent(s): 9bbffa6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -7
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
- if event.sender_id != ADMIN_ID:
263
- return
264
- async with bot.conversation(event.chat_id, timeout=60) as conv:
265
- await conv.send_message("✍️ Send your String Session:")
266
- session_msg = await conv.get_response()
267
- session_str = session_msg.text.strip()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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'})")