randydev commited on
Commit
bbbca4c
Β·
verified Β·
1 Parent(s): 918bd1b
Files changed (1) hide show
  1. akn/manage/bots_manage.py +82 -6
akn/manage/bots_manage.py CHANGED
@@ -29,18 +29,20 @@ async def userbotdashboardub(client: Client, callback: CallbackQuery):
29
  "approved": "βœ…",
30
  "rejected": "❌",
31
  "pending": "⏳",
 
32
  "error": "⚠️"
33
  }
34
  start = time.time()
35
  await client.get_me()
36
  end = time.time()
37
  latency = (end - start) * 1000
 
38
  text = f"""
39
  πŸ”§ **Your Userbot Dashboard**
40
 
41
  πŸ†” **User ID:** `{user_id}`
42
  πŸ“› **Status:** {status_icons.get(status, "οΏ½")} {status.capitalize()}
43
- ⏰ **Last Active:** {bot_data.get("last_active", "Never")}
44
  βœ” **Pong:** `{latency:.2f} ms`
45
  πŸ”— **Session:** {'Set' if bot_data.get("session_string") else 'Not Set'}
46
  """
@@ -89,8 +91,35 @@ async def userbotsettingsub(client: Client, callback: CallbackQuery):
89
  )
90
  await callback.answer()
91
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
92
  @Client.on_callback_query(filters.regex("^(set_sessionub|update_sessionub)$"))
93
  async def asksessionstringub(client: Client, callback: CallbackQuery):
 
 
 
 
 
 
 
 
94
  await callback.message.edit_text(
95
  "πŸ”‘ **Session String Setup: @sessiondevbot**\n\n"
96
  "Please send your session string in this format:\n\n"
@@ -111,16 +140,51 @@ async def asksessionstringub(client: Client, callback: CallbackQuery):
111
  return
112
 
113
  string_update = string_msg.text.strip()
114
-
 
 
 
 
 
 
 
115
  await db_client.session.update_one(
116
- {"user_id": callback.from_user.id},
117
- {"$set": {"user_client.$.session_string": string_update}}
 
 
 
 
 
 
 
118
  )
119
- await string_msg.reply("βœ… Session string updated successfully!")
 
 
 
 
 
 
 
 
 
 
 
 
 
120
  except TimeoutError:
121
  await callback.message.reply_text("βŒ› Session setup timed out")
122
  except Exception as e:
123
- await callback.message.reply_text(f"❌ Error: {str(e)}")
 
 
 
 
 
 
 
 
124
 
125
  @ren.on_callback_query(filters.regex("^my_bots$"))
126
  async def show_user_bots(client: Client, callback: CallbackQuery):
@@ -736,6 +800,18 @@ async def confirm_resubmission(client: Client, callback: CallbackQuery):
736
  f"🧠 Error: <code>{str(e)}</code>"
737
  )
738
 
 
 
 
 
 
 
 
 
 
 
 
 
739
  async def notify_admins(client, message, user_id, bots_uuid):
740
  admin_buttons = InlineKeyboardMarkup([
741
  [InlineKeyboardButton("βœ… Approve", callback_data=f"approved_alldl_{user_id}_{bots_uuid}"),
 
29
  "approved": "βœ…",
30
  "rejected": "❌",
31
  "pending": "⏳",
32
+ "stopped": "πŸ›‘",
33
  "error": "⚠️"
34
  }
35
  start = time.time()
36
  await client.get_me()
37
  end = time.time()
38
  latency = (end - start) * 1000
39
+
40
  text = f"""
41
  πŸ”§ **Your Userbot Dashboard**
42
 
43
  πŸ†” **User ID:** `{user_id}`
44
  πŸ“› **Status:** {status_icons.get(status, "οΏ½")} {status.capitalize()}
45
+ ⏰ **Last Active:** {bot_data.get("timestamp", "Never")}
46
  βœ” **Pong:** `{latency:.2f} ms`
47
  πŸ”— **Session:** {'Set' if bot_data.get("session_string") else 'Not Set'}
48
  """
 
91
  )
92
  await callback.answer()
93
 
94
+ @Client.on_callback_query(filters.regex("^session_infoub$"))
95
+ async def infosessionstringub(client: Client, callback: CallbackQuery):
96
+ user_data = await db_client.session.find_one({"user_id": user_id})
97
+ if not user_data or not user_data.get("user_client"):
98
+ return await callback.answer(
99
+ "❌ You don't have any Userbot deployed yet!",
100
+ show_alert=True
101
+ )
102
+ user = user_data["user_client"][0]
103
+ await callback.message.edit_text(
104
+ "πŸ”’ <b>Session String Secure</b>\n\n"
105
+ f"Copy: `{user.get('session_string', 'Nothing')}`\n\n"
106
+ "Important: <b>Never share your session string with anyone</b>",
107
+ reply_markup=ikb([
108
+ [("Β« Back", "ubsetting")]
109
+ ])
110
+ )
111
+ await callback.answer()
112
+
113
  @Client.on_callback_query(filters.regex("^(set_sessionub|update_sessionub)$"))
114
  async def asksessionstringub(client: Client, callback: CallbackQuery):
115
+ user_data = await db_client.session.find_one({"user_id": user_id})
116
+ if not user_data or not user_data.get("user_client"):
117
+ return await callback.answer(
118
+ "❌ You don't have any Userbot deployed yet!",
119
+ show_alert=True
120
+ )
121
+ _user_string = user_data.get("user_client")[0]
122
+ user_mention = callback.from_user.mention
123
  await callback.message.edit_text(
124
  "πŸ”‘ **Session String Setup: @sessiondevbot**\n\n"
125
  "Please send your session string in this format:\n\n"
 
140
  return
141
 
142
  string_update = string_msg.text.strip()
143
+ if string_update == _user_string.get("session_string"):
144
+ return await string_msg.reply(
145
+ "❌ Error Session string same use different!",
146
+ reply_markup=ikb([
147
+ [("Β« Back", "my_userbotub")]
148
+
149
+ ])
150
+ )
151
  await db_client.session.update_one(
152
+ {
153
+ "user_id": callback.from_user.id,
154
+ "user_client.user_id": callback.from_user.id
155
+ },
156
+ {
157
+ "$set": {
158
+ "user_client.$.session_string": string_update
159
+ }
160
+ }
161
  )
162
+ await string_msg.reply(
163
+ "βœ… Session string updated successfully!",
164
+ reply_markup=ikb([
165
+ [("Β« Back", "my_userbotub")]
166
+ ])
167
+ )
168
+ await notify_admins_user(
169
+ client=client,
170
+ message=f"πŸ’¬ <b>Update Session</b>\n\n"
171
+ f"πŸ‘€ User: {user_mention} ({callback.from_user.id})",
172
+ user_id=user_id,
173
+ is_button=True
174
+ )
175
+ return
176
  except TimeoutError:
177
  await callback.message.reply_text("βŒ› Session setup timed out")
178
  except Exception as e:
179
+ await callback.message.reply_text(f"❌ Error: Please try again later.")
180
+ await notify_admins_user(
181
+ client=client,
182
+ message=f"🚨 <b>Error in asksessionstringub handler</b>\n\n"
183
+ f"πŸ‘€ User: {user_mention} ({callback.from_user.id})\n"
184
+ f"🧠 Error: <code>{str(e)}</code>",
185
+ user_id=user_id,
186
+ is_button=False
187
+ )
188
 
189
  @ren.on_callback_query(filters.regex("^my_bots$"))
190
  async def show_user_bots(client: Client, callback: CallbackQuery):
 
800
  f"🧠 Error: <code>{str(e)}</code>"
801
  )
802
 
803
+ async def notify_admins_user(client, message, user_id, is_button=False):
804
+ admin_buttons = InlineKeyboardMarkup([
805
+ [InlineKeyboardButton("βœ… Approve", callback_data=f"approved_ub_{user_id}"),
806
+ InlineKeyboardButton("❌ Reject", callback_data=f"rejected_ub_{user_id}")],
807
+ [InlineKeyboardButton("πŸ‘€ View User", url=f"tg://user?id={user_id}")]
808
+ ])
809
+ return await client.send_message(
810
+ PRIVATE_LOGS,
811
+ text=message,
812
+ reply_markup=admin_buttons if is_button else None
813
+ )
814
+
815
  async def notify_admins(client, message, user_id, bots_uuid):
816
  admin_buttons = InlineKeyboardMarkup([
817
  [InlineKeyboardButton("βœ… Approve", callback_data=f"approved_alldl_{user_id}_{bots_uuid}"),