randydev commited on
Commit
7fe4540
·
verified ·
1 Parent(s): 9e66966

Upload 2 files

Browse files
Files changed (2) hide show
  1. akn/__main__.py +1 -0
  2. akn/clientmulti_bot.py +50 -18
akn/__main__.py CHANGED
@@ -41,6 +41,7 @@ async def client_multi_bot():
41
  await start_user()
42
  await start_gemini_bot()
43
  await start_magic_bot()
 
44
  except Exception as e:
45
  LOGS.error(f"Error in client_multi_bot: {e}")
46
  traceback.print_exc()
 
41
  await start_user()
42
  await start_gemini_bot()
43
  await start_magic_bot()
44
+ await start_meta_bot()
45
  except Exception as e:
46
  LOGS.error(f"Error in client_multi_bot: {e}")
47
  traceback.print_exc()
akn/clientmulti_bot.py CHANGED
@@ -49,30 +49,12 @@ async def start_user() -> None:
49
  continue
50
  except AuthKeyDuplicated:
51
  continue
52
- """
53
- if await db.is_session(user_id):
54
- await db.rm_session(user_id=user_id)
55
- await app.send_message("@xtdevs", f"AuthKeyDuplicated {i + 1} | {user_id}")
56
- LOGS.info(f"AuthKeyDuplicated: {i + 1} | {user_id}")
57
- """
58
  except UserDeactivated:
59
  continue
60
  except AuthKeyUnregistered:
61
  continue
62
- """
63
- if await db.is_session(user_id):
64
- await db.rm_session(user_id=user_id)
65
- await app.send_message("@xtdevs", f"AuthKeyUnregistered {i + 1} | {user_id}")
66
- LOGS.info(f"AuthKeyUnregistered: {i + 1} | {user_id}")
67
- """
68
  except SessionRevoked:
69
  continue
70
- """
71
- if await db.is_session(user_id):
72
- await db.rm_session(user_id=user_id)
73
- await app.send_message("@xtdevs", f"SessionRevoked {i + 1} | {user_id}")
74
- LOGS.info(f"SessionRevoked: {i + 1} | {user_id}")
75
- """
76
  except Exception as e:
77
  traceback.print_exc()
78
  continue
@@ -127,6 +109,56 @@ async def start_magic_bot() -> None:
127
  if tasks:
128
  await asyncio.gather(*tasks)
129
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
130
  async def start_gemini_bot() -> None:
131
  sessions = await db.get_all_gemini_bot()
132
  for i, data in enumerate(sessions):
 
49
  continue
50
  except AuthKeyDuplicated:
51
  continue
 
 
 
 
 
 
52
  except UserDeactivated:
53
  continue
54
  except AuthKeyUnregistered:
55
  continue
 
 
 
 
 
 
56
  except SessionRevoked:
57
  continue
 
 
 
 
 
 
58
  except Exception as e:
59
  traceback.print_exc()
60
  continue
 
109
  if tasks:
110
  await asyncio.gather(*tasks)
111
 
112
+ async def start_meta_bot() -> None:
113
+ sessions = await db.get_all_meta_bot()
114
+ active_bots = []
115
+ for i, data in enumerate(sessions):
116
+ user_id = data.get("user_id") or 0
117
+ bot_token = data.get("bot_token")
118
+ if bot_token is None:
119
+ continue
120
+ get_user_exp = await db.get_expired_date(user_id)
121
+ to_obj = Box(get_user_exp or {})
122
+ if not to_obj:
123
+ continue
124
+ if not to_obj.get("user_client"):
125
+ continue
126
+ if to_obj.user_client.get("disconnected", False):
127
+ continue
128
+ try:
129
+ client = Client(
130
+ name=f"MetaAI#{i + 1}",
131
+ api_id=API_ID,
132
+ api_hash=API_HASH,
133
+ bot_token=bot_token,
134
+ app_version="latest",
135
+ device_model="Meta AI Bot",
136
+ system_version="Linux",
137
+ plugins=dict(root="akn.Meta"),
138
+ )
139
+ await client.start()
140
+ me = await client.get_me()
141
+ LOGS.info(f"Started Meta AI bot {i + 1}: {me.first_name} | {me.id}")
142
+ active_bots.append((client, user_id))
143
+
144
+ except AuthKeyDuplicated:
145
+ LOGS.warning(f"Duplicate auth key for bot {i + 1}. Skipping...")
146
+ continue
147
+ except AccessTokenExpired:
148
+ continue
149
+ except UserDeactivated:
150
+ LOGS.warning(f"Bot {i + 1} has been deactivated. Skipping...")
151
+ continue
152
+ except Exception as e:
153
+ LOGS.error(f"Error starting bot {i + 1}: {e}")
154
+ continue
155
+
156
+ tasks = []
157
+ for client, user_id in active_bots:
158
+ tasks.append(watch_do_time(user_id, client, assistant))
159
+ if tasks:
160
+ await asyncio.gather(*tasks)
161
+
162
  async def start_gemini_bot() -> None:
163
  sessions = await db.get_all_gemini_bot()
164
  for i, data in enumerate(sessions):