Update akn/manage/builderclone_bots.py
Browse files
akn/manage/builderclone_bots.py
CHANGED
@@ -10,6 +10,52 @@ from akn.utils.database import db as db_client
|
|
10 |
from config import PRIVATE_LOGS
|
11 |
from akn.utils.logger import LOGS
|
12 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
@ren.on_callback_query(filters.regex("^alldl_bot$"))
|
14 |
async def new_alldlbot_clone(bot: Client, cb: CallbackQuery):
|
15 |
user_id = cb.from_user.id
|
@@ -63,13 +109,15 @@ async def new_alldlbot_clone(bot: Client, cb: CallbackQuery):
|
|
63 |
{"bots.bot_token": bot_token}
|
64 |
)
|
65 |
if token_exists:
|
|
|
66 |
await bot.send_message(
|
67 |
chat_id,
|
68 |
"β οΈ This bot token is already registered in our system!\n\n"
|
69 |
"Please create a new bot via @BotFather if you want to deploy another instance.",
|
70 |
reply_markup=InlineKeyboardMarkup([
|
71 |
[InlineKeyboardButton("π Create New Bot", url="https://t.me/BotFather")],
|
72 |
-
[InlineKeyboardButton("π Try Again", callback_data="alldl_bot")
|
|
|
73 |
[InlineKeyboardButton("β Cancel", callback_data="customzie_bot")]
|
74 |
])
|
75 |
)
|
|
|
10 |
from config import PRIVATE_LOGS
|
11 |
from akn.utils.logger import LOGS
|
12 |
|
13 |
+
from typing import Dict
|
14 |
+
|
15 |
+
storage_rm_token: Dict[int, str] = {}
|
16 |
+
|
17 |
+
@ren.on_callback_query(filters.regex("^rmdeploybots$"))
|
18 |
+
async def bot_token_removal(bot: Client, cb: CallbackQuery):
|
19 |
+
user_id = cb.from_user.id
|
20 |
+
|
21 |
+
try:
|
22 |
+
if user_id not in storage_rm_token:
|
23 |
+
await cb.answer("β No token found. Please restart the removal process.", show_alert=True)
|
24 |
+
return
|
25 |
+
|
26 |
+
bot_token = storage_rm_token[user_id]
|
27 |
+
|
28 |
+
token_exists = await db_client.alldl_bot.find_one(
|
29 |
+
{"user_id": user_id, "bots.bot_token": bot_token}
|
30 |
+
)
|
31 |
+
|
32 |
+
if not token_exists:
|
33 |
+
await cb.answer("β οΈ Token not found in your registered bots", show_alert=True)
|
34 |
+
return
|
35 |
+
|
36 |
+
result = await db_client.alldl_bot.update_one(
|
37 |
+
{"user_id": user_id},
|
38 |
+
{"$pull": {"bots": {"bot_token": bot_token}}}
|
39 |
+
)
|
40 |
+
|
41 |
+
if result.modified_count > 0:
|
42 |
+
storage_rm_token.pop(user_id, None)
|
43 |
+
|
44 |
+
await cb.message.edit_text(
|
45 |
+
"β
Bot token successfully removed from your account.\n\n"
|
46 |
+
"For security reasons:\n"
|
47 |
+
"1. Revoke the token via @BotFather\n"
|
48 |
+
"2. Delete any remaining session files"
|
49 |
+
)
|
50 |
+
else:
|
51 |
+
await cb.answer("β οΈ No changes made. Token may have been already removed.", show_alert=True)
|
52 |
+
|
53 |
+
except FloodWait as e:
|
54 |
+
await cb.answer(f"β³ Please wait {e.value} seconds before trying again", show_alert=True)
|
55 |
+
except Exception as e:
|
56 |
+
LOGS.error(f"Token removal failed for {user_id}: {str(e)}")
|
57 |
+
await cb.answer("π¨ Server error during removal. Contact support.", show_alert=True)
|
58 |
+
|
59 |
@ren.on_callback_query(filters.regex("^alldl_bot$"))
|
60 |
async def new_alldlbot_clone(bot: Client, cb: CallbackQuery):
|
61 |
user_id = cb.from_user.id
|
|
|
109 |
{"bots.bot_token": bot_token}
|
110 |
)
|
111 |
if token_exists:
|
112 |
+
storage_rm_token[user_id] = bot_token
|
113 |
await bot.send_message(
|
114 |
chat_id,
|
115 |
"β οΈ This bot token is already registered in our system!\n\n"
|
116 |
"Please create a new bot via @BotFather if you want to deploy another instance.",
|
117 |
reply_markup=InlineKeyboardMarkup([
|
118 |
[InlineKeyboardButton("π Create New Bot", url="https://t.me/BotFather")],
|
119 |
+
[InlineKeyboardButton("π Try Again", callback_data="alldl_bot"),
|
120 |
+
InlineKeyboardButton("β οΈ Delete Token", callback_data="rmdeploybots")],
|
121 |
[InlineKeyboardButton("β Cancel", callback_data="customzie_bot")]
|
122 |
])
|
123 |
)
|