update
Browse files- 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("
|
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 |
-
{
|
117 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
118 |
)
|
119 |
-
await string_msg.reply(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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}"),
|