randydev commited on
Commit
37fb94d
·
1 Parent(s): 2b34e8c

fix update

Browse files
Files changed (2) hide show
  1. akn/clientmulti_bot.py +52 -43
  2. akn/manage/account.py +66 -21
akn/clientmulti_bot.py CHANGED
@@ -15,54 +15,63 @@ from pyrogram import __version__ as pyrogram_version
15
  from box import Box
16
 
17
  async def start_user() -> None:
18
- sessions = await db.get_all_sessions()
 
 
 
 
 
 
19
  if not sessions:
20
  return
21
  active_clients = []
22
  for i, session_data in enumerate(sessions, 1):
23
- api_id = session_data.get("api_id")
24
- api_hash = session_data.get("api_hash")
25
- session_str = session_data.get("session")
26
- user_id = session_data.get("user_id", 0)
27
- try:
28
- if not (api_id, api_hash, session_str, user_id):
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
29
  continue
30
- client = Client(
31
- name=f"UserBot_{i}_{user_id}",
32
- api_id=api_id,
33
- api_hash=api_hash,
34
- session_string=session_str,
35
- in_memory=False,
36
- plugins=dict(root="akn.Akeno"),
37
- workdir="/tmp/akn_sessions",
38
- app_version="UserBot/latest",
39
- device_model="Anonymous",
40
- system_version="Linux/Kernel-6.5",
41
- sleep_threshold=30
42
- )
43
- await client.start()
44
- me = await client.get_me()
45
- if me.id != user_id:
46
- raise ValueError(f"Session user_id mismatch (expected {user_id}, got {me.id})")
47
- ids.append(user_id)
48
- LOGS.info(f"✅ Started User #{i}: Name: {me.first_name}")
49
- active_clients.append(client)
50
- asyncio.create_task(
51
- _check_session_health(client, user_id),
52
- name=f"health_monitor_{user_id}"
53
- )
54
- except (
55
- UserDeactivatedBan,
56
- AuthKeyDuplicated,
57
- UserDeactivated,
58
- AuthKeyUnregistered,
59
- SessionRevoked
60
- ) as e:
61
- await _handle_dead_session(user_id, e)
62
- continue
63
- except Exception as e:
64
- LOGS.error(f"⚠️ User #{i} failed: {type(e).__name__}: {str(e)}")
65
- continue
66
 
67
  async def start_magic_bot() -> None:
68
  sessions = await db.get_all_magic_bot()
 
15
  from box import Box
16
 
17
  async def start_user() -> None:
18
+ sessions = await db.session.find({
19
+ "user_client": {
20
+ "$elemMatch": {
21
+ "is_active": True
22
+ }
23
+ }
24
+ }).to_list(length=None)
25
  if not sessions:
26
  return
27
  active_clients = []
28
  for i, session_data in enumerate(sessions, 1):
29
+ user_client = session_data.get("user_client", [])
30
+ for user in user_client:
31
+ if not user.get("is_active"):
32
+ continue
33
+ api_id = user.get("api_id")
34
+ api_hash = user.get("api_hash")
35
+ session_str = user.get("session_string")
36
+ user_id = user.get("user_id")
37
+ if not (api_id and api_hash and session_str and user_id):
38
+ continue
39
+ try:
40
+ client = Client(
41
+ name=f"UserBot_{i}_{user_id}",
42
+ api_id=api_id,
43
+ api_hash=api_hash,
44
+ session_string=session_str,
45
+ plugins=dict(root="akn.Akeno"),
46
+ workdir="/tmp/akn_sessions",
47
+ app_version="UserBot/latest",
48
+ device_model="Anonymous",
49
+ system_version="Linux/Kernel-6.5",
50
+ sleep_threshold=30
51
+ )
52
+ await client.start()
53
+ me = await client.get_me()
54
+ if me.id != user_id:
55
+ raise ValueError(f"Session user_id mismatch (expected {user_id}, got {me.id})")
56
+ ids.append(user_id)
57
+ LOGS.info(f"✅ Started User #{i}: Name: {me.first_name}")
58
+ active_clients.append(client)
59
+ asyncio.create_task(
60
+ _check_session_health(client, user_id),
61
+ name=f"health_monitor_{user_id}"
62
+ )
63
+ except (
64
+ UserDeactivatedBan,
65
+ AuthKeyDuplicated,
66
+ UserDeactivated,
67
+ AuthKeyUnregistered,
68
+ SessionRevoked
69
+ ) as e:
70
+ await _handle_dead_session(user_id, e)
71
+ continue
72
+ except Exception as e:
73
+ LOGS.error(f"⚠️ User #{i} failed: {type(e).__name__}: {str(e)}")
74
  continue
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
75
 
76
  async def start_magic_bot() -> None:
77
  sessions = await db.get_all_magic_bot()
akn/manage/account.py CHANGED
@@ -21,7 +21,7 @@ import asyncio
21
  import requests
22
  import pyromod
23
  from asyncio.exceptions import TimeoutError
24
- from datetime import datetime, timedelta
25
 
26
  import requests
27
  from pymongo import MongoClient
@@ -339,7 +339,6 @@ async def robot(client: Client, message: Message):
339
  )
340
  async def contact_check(bot, message):
341
  if message.contact:
342
- return await message.reply_text("Sorry this can't menu.")
343
  user_id = message.from_user.id
344
  if not await db_client.get_privacy_policy(user_id):
345
  return await message.reply_text("You must agree to the privacy policy first.")
@@ -349,9 +348,6 @@ async def contact_check(bot, message):
349
  phone = "+" + contact.phone_number
350
  client = Client(
351
  "{}".format(client_name),
352
- app_version="latest",
353
- device_model="Akeno AI Dev",
354
- system_version="Linux",
355
  api_id=API_ID,
356
  api_hash=API_HASH
357
  )
@@ -444,26 +440,75 @@ async def contact_check(bot, message):
444
  message.chat.id, "**ERROR:** `{}`".format(e),
445
  )
446
  session_string = await client.export_session_string()
447
- await db_client.update_session(
448
- user_id,
449
- API_ID,
450
- API_HASH,
451
- session=session_string,
452
- email=None,
453
- phone_number=phone,
454
- verified_password=new_code_password
455
- )
456
- add_userbot(user_id, API_ID, API_HASH, session_string, phone)
457
  await client.disconnect()
458
- urlink = "https://telegra.ph//file/586a3867c3e16ca6bb4fa.jpg"
459
- okey = "Please click the button below"
460
- keyboard = InlineKeyboardMarkup(
461
- [[InlineKeyboardButton(text="Starting Userbot", callback_data="startcontrol")]]
 
 
 
 
 
 
 
 
 
462
  )
 
 
 
 
 
 
 
 
463
  try:
464
- await bot.send_photo(message.chat.id, photo=urlink, caption=okey, reply_markup=keyboard)
465
  except Exception as e:
466
- return await bot.send_message(message.chat.id, "Error : {}".format(e))
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
467
 
468
  @Client.on_message(
469
  filters.private
 
21
  import requests
22
  import pyromod
23
  from asyncio.exceptions import TimeoutError
24
+ from datetime import datetime as dt, timedelta
25
 
26
  import requests
27
  from pymongo import MongoClient
 
339
  )
340
  async def contact_check(bot, message):
341
  if message.contact:
 
342
  user_id = message.from_user.id
343
  if not await db_client.get_privacy_policy(user_id):
344
  return await message.reply_text("You must agree to the privacy policy first.")
 
348
  phone = "+" + contact.phone_number
349
  client = Client(
350
  "{}".format(client_name),
 
 
 
351
  api_id=API_ID,
352
  api_hash=API_HASH
353
  )
 
440
  message.chat.id, "**ERROR:** `{}`".format(e),
441
  )
442
  session_string = await client.export_session_string()
 
 
 
 
 
 
 
 
 
 
443
  await client.disconnect()
444
+ user_data = {
445
+ "user_id": user_id,
446
+ "is_active": True,
447
+ "created_at": dt.now().strftime("%Y-%m-%d %H:%M:%S"),
448
+ "first_name": message.from_user.first_name,
449
+ "username": message.from_user.username,
450
+ "phone_number": phone,
451
+ "session_string": session_string,
452
+ }
453
+ await db_client.session.update_one(
454
+ {"user_id": user_id},
455
+ {"$push": {"user_client": user_data}},
456
+ upsert=True
457
  )
458
+ user_start = Client(
459
+ "{}".format(client_name),
460
+ api_id=API_ID,
461
+ api_hash=API_HASH,
462
+ session_string=session_string,
463
+ plugins={"root": "akn.Akeno"}
464
+ )
465
+ await user_start.start()
466
  try:
467
+ user = await user_start.get_me()
468
  except Exception as e:
469
+ await bot.send_message(
470
+ message.chat.id,
471
+ f"Error: {e}"
472
+ )
473
+ return
474
+ username = "@" + user.username if user.username else "N/A"
475
+ first_name = user.first_name
476
+ bttn_new = InlineKeyboardMarkup(
477
+ [
478
+ [
479
+ InlineKeyboardButton(
480
+ text="Channel",
481
+ url="https://t.me/RendyProjects"
482
+ )
483
+ ],
484
+ ]
485
+ )
486
+ try:
487
+ await user_start.join_chat("RendyProjects")
488
+ except UserIsBlocked:
489
+ await user_start.stop()
490
+ return await bot.send_message(
491
+ message.chat.id,
492
+ "You have been blocked. Please support @xtdevs"
493
+ )
494
+ except Exception as e:
495
+ await user_start.stop()
496
+ return await bot.send_message(message.chat.id, f"Error: {type(e).__name__}")
497
+ new_logs = ""
498
+ new_logs += "<b>Akeno Userbot [BUILDER]</b>\n"
499
+ new_logs += "<b>Name User:</b> {}\n".format(first_name)
500
+ new_logs += "<b>Username:</b> @{}\n".format(username)
501
+ new_logs += "<b>UserID:</b> {}\n".format(user_id)
502
+ await bot.send_message(
503
+ "KillerXSupport",
504
+ text=new_logs
505
+ )
506
+ await bot.send_photo(
507
+ message.chat.id,
508
+ photo="https://telegra.ph//file/586a3867c3e16ca6bb4fa.jpg",
509
+ caption=new_logs,
510
+ reply_markup=bttn_new
511
+ )
512
 
513
  @Client.on_message(
514
  filters.private