bot
commited on
Commit
·
5c25912
1
Parent(s):
35212e7
Fix
Browse files
main.py
CHANGED
@@ -238,17 +238,15 @@ async def tg_show_shares(update: Update, context: CallbackContext):
|
|
238 |
shares = await THUNDERX_CLIENT.get_share_list("")
|
239 |
keyboard = []
|
240 |
|
241 |
-
if shares["
|
242 |
await update.message.reply_text("❌未找到文件!!")
|
243 |
else:
|
244 |
# 为每个文件创建按钮和操作选项
|
245 |
-
for share in shares["
|
246 |
keyboard.append(
|
247 |
[
|
248 |
-
InlineKeyboardButton(
|
249 |
-
|
250 |
-
callback_data=f"ls_f:{share['id']}",
|
251 |
-
),
|
252 |
InlineKeyboardButton(
|
253 |
f"取消",
|
254 |
callback_data=f"del_s:{share['id']}",
|
@@ -259,6 +257,45 @@ async def tg_show_shares(update: Update, context: CallbackContext):
|
|
259 |
await update.message.reply_text(f"📋分享列表:", reply_markup=reply_markup)
|
260 |
|
261 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
262 |
#################### 文件操作 #############################
|
263 |
|
264 |
|
@@ -641,6 +678,19 @@ async def init_client():
|
|
641 |
CallbackQueryHandler(handle_task_confirmation, pattern="^confirm_task")
|
642 |
)
|
643 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
644 |
########## 文件操作 ###############
|
645 |
|
646 |
TG_BOT_APPLICATION.add_handler(
|
|
|
238 |
shares = await THUNDERX_CLIENT.get_share_list("")
|
239 |
keyboard = []
|
240 |
|
241 |
+
if shares["data"] is None:
|
242 |
await update.message.reply_text("❌未找到文件!!")
|
243 |
else:
|
244 |
# 为每个文件创建按钮和操作选项
|
245 |
+
for share in shares["data"]:
|
246 |
keyboard.append(
|
247 |
[
|
248 |
+
InlineKeyboardButton(f"{share['title']}"),
|
249 |
+
InlineKeyboardButton(f"{share['share_id']}"),
|
|
|
|
|
250 |
InlineKeyboardButton(
|
251 |
f"取消",
|
252 |
callback_data=f"del_s:{share['id']}",
|
|
|
257 |
await update.message.reply_text(f"📋分享列表:", reply_markup=reply_markup)
|
258 |
|
259 |
|
260 |
+
# 处理任务操作的回调
|
261 |
+
async def handle_share_operation(update: Update, context: CallbackContext):
|
262 |
+
query = update.callback_query
|
263 |
+
await query.answer()
|
264 |
+
|
265 |
+
# 获取操作类型和文件 ID
|
266 |
+
action, share_id = (query.data.split(":")[0], query.data.split(":")[1])
|
267 |
+
|
268 |
+
# 需要确认的操作
|
269 |
+
if action in ["del_s"]:
|
270 |
+
# 生成确认消息
|
271 |
+
keyboard = [
|
272 |
+
[InlineKeyboardButton("确认", callback_data=f"yes_s_{action}:{share_id}")],
|
273 |
+
[InlineKeyboardButton("取消", callback_data=f"no_s_{action}:{share_id}")],
|
274 |
+
]
|
275 |
+
reply_markup = InlineKeyboardMarkup(keyboard)
|
276 |
+
await query.edit_message_text(
|
277 |
+
f"你确定要{action}分享 {share_id} 吗?", reply_markup=reply_markup
|
278 |
+
)
|
279 |
+
|
280 |
+
|
281 |
+
async def handle_share_confirmation(update: Update, context: CallbackContext):
|
282 |
+
query = update.callback_query
|
283 |
+
await query.answer()
|
284 |
+
|
285 |
+
# 获取确认操作的类型和文件 ID
|
286 |
+
action, share_id = (query.data.split(":")[0], query.data.split(":")[1])
|
287 |
+
|
288 |
+
if action == "yes_s_del_s":
|
289 |
+
await THUNDERX_CLIENT.delete_forever([share_id])
|
290 |
+
await query.edit_message_text(f"✅分享 {share_id} 已取消。")
|
291 |
+
|
292 |
+
|
293 |
+
async def handle_share_cancel(update: Update, context: CallbackContext):
|
294 |
+
query = update.callback_query
|
295 |
+
await query.answer()
|
296 |
+
await query.edit_message_text(f"操作已取消")
|
297 |
+
|
298 |
+
|
299 |
#################### 文件操作 #############################
|
300 |
|
301 |
|
|
|
678 |
CallbackQueryHandler(handle_task_confirmation, pattern="^confirm_task")
|
679 |
)
|
680 |
|
681 |
+
########## 分享操作 ###############
|
682 |
+
TG_BOT_APPLICATION.add_handler(
|
683 |
+
CallbackQueryHandler(handle_share_operation, pattern="^del_s:")
|
684 |
+
)
|
685 |
+
# 处理取消任务操作
|
686 |
+
TG_BOT_APPLICATION.add_handler(
|
687 |
+
CallbackQueryHandler(handle_share_cancel, pattern="^no_s")
|
688 |
+
)
|
689 |
+
# 处理确认操作(确认删除、复制等)
|
690 |
+
TG_BOT_APPLICATION.add_handler(
|
691 |
+
CallbackQueryHandler(handle_share_confirmation, pattern="^yes_s")
|
692 |
+
)
|
693 |
+
|
694 |
########## 文件操作 ###############
|
695 |
|
696 |
TG_BOT_APPLICATION.add_handler(
|