Upload bots_manage.py
Browse files- akn/manage/bots_manage.py +74 -1
akn/manage/bots_manage.py
CHANGED
@@ -14,6 +14,79 @@ from akn.manage.settings_control import verify_bot_ownershipdl
|
|
14 |
from akn.utils.logger import LOGS
|
15 |
from config import PRIVATE_LOGS
|
16 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
@ren.on_callback_query(filters.regex("^my_bots$"))
|
18 |
async def show_user_bots(client: Client, callback: CallbackQuery):
|
19 |
user_id = callback.from_user.id
|
@@ -648,4 +721,4 @@ async def cancel_resubmit(client: Client, callback: CallbackQuery):
|
|
648 |
[InlineKeyboardButton("Β« Back", callback_data="my_bots")]
|
649 |
])
|
650 |
)
|
651 |
-
await callback.answer()
|
|
|
14 |
from akn.utils.logger import LOGS
|
15 |
from config import PRIVATE_LOGS
|
16 |
|
17 |
+
@Client.on_callback_query(filters.regex("^my_userbotub$"))
|
18 |
+
async def userbotdashboardub(client: Client, callback: CallbackQuery):
|
19 |
+
user_id = callback.from_user.id
|
20 |
+
|
21 |
+
user_data = await db_client.session.find_one({"user_id": user_id})
|
22 |
+
if not user_data or "user_client" not in user_data:
|
23 |
+
return await callback.answer("β No userbot found!", show_alert=True)
|
24 |
+
|
25 |
+
bot_data = user_data["user_client"][0]
|
26 |
+
status = bot_data.get("status", "pending")
|
27 |
+
|
28 |
+
status_icons = {
|
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 |
+
"""
|
47 |
+
|
48 |
+
buttons = []
|
49 |
+
if not bot_data.get("session_string"):
|
50 |
+
buttons.append(
|
51 |
+
[InlineKeyboardButton("β Set Session String", callback_data="set_sessionub")]
|
52 |
+
)
|
53 |
+
else:
|
54 |
+
buttons.append(
|
55 |
+
[InlineKeyboardButton("π Update Session", callback_data="update_sessionub")]
|
56 |
+
)
|
57 |
+
|
58 |
+
if status == "approved":
|
59 |
+
buttons.extend([
|
60 |
+
[InlineKeyboardButton("β‘ Start Userbot", callback_data="start_userbot")]
|
61 |
+
])
|
62 |
+
|
63 |
+
buttons.append(
|
64 |
+
[InlineKeyboardButton("βοΈ Settings", callback_data="ubsetting")]
|
65 |
+
)
|
66 |
+
|
67 |
+
await callback.message.edit_text(
|
68 |
+
text,
|
69 |
+
reply_markup=InlineKeyboardMarkup(buttons)
|
70 |
+
)
|
71 |
+
await callback.answer()
|
72 |
+
|
73 |
+
@Client.on_callback_query(filters.regex("^ubsetting$"))
|
74 |
+
async def userbotsettingsub(client: Client, callback: CallbackQuery):
|
75 |
+
user_id = callback.from_user.id
|
76 |
+
|
77 |
+
buttons = [
|
78 |
+
[InlineKeyboardButton("π Session Info", callback_data="session_infoub")],
|
79 |
+
[InlineKeyboardButton("π Delete Userbot", callback_data="delete_userbotub")],
|
80 |
+
[InlineKeyboardButton("π Back", callback_data="my_userbotub")]
|
81 |
+
]
|
82 |
+
|
83 |
+
await callback.message.edit_text(
|
84 |
+
"βοΈ **Userbot Settings**\n\n"
|
85 |
+
"Manage your userbot configuration:",
|
86 |
+
reply_markup=InlineKeyboardMarkup(buttons)
|
87 |
+
)
|
88 |
+
await callback.answer()
|
89 |
+
|
90 |
@ren.on_callback_query(filters.regex("^my_bots$"))
|
91 |
async def show_user_bots(client: Client, callback: CallbackQuery):
|
92 |
user_id = callback.from_user.id
|
|
|
721 |
[InlineKeyboardButton("Β« Back", callback_data="my_bots")]
|
722 |
])
|
723 |
)
|
724 |
+
await callback.answer()
|