bot
commited on
Commit
·
86f3c23
1
Parent(s):
007372a
fix
Browse files
main.py
CHANGED
@@ -247,11 +247,11 @@ async def tg_show_files(update: Update, context: CallbackContext):
|
|
247 |
[
|
248 |
InlineKeyboardButton(
|
249 |
f"查看📁: {file['name']}",
|
250 |
-
callback_data=f"
|
251 |
),
|
252 |
InlineKeyboardButton(
|
253 |
f"删除",
|
254 |
-
callback_data=f"
|
255 |
),
|
256 |
]
|
257 |
)
|
@@ -260,11 +260,11 @@ async def tg_show_files(update: Update, context: CallbackContext):
|
|
260 |
[
|
261 |
InlineKeyboardButton(
|
262 |
f"下载📄: {file['name']}",
|
263 |
-
callback_data=f"
|
264 |
),
|
265 |
InlineKeyboardButton(
|
266 |
f"删除",
|
267 |
-
callback_data=f"
|
268 |
),
|
269 |
]
|
270 |
)
|
@@ -284,7 +284,7 @@ async def handle_file_confirmation(update: Update, context: CallbackContext):
|
|
284 |
query.data.split(":")[2],
|
285 |
)
|
286 |
|
287 |
-
if action == "
|
288 |
await THUNDERX_CLIENT.delete_forever([file_id])
|
289 |
await query.edit_message_text(f"✅文件 {file_id} 已删除。")
|
290 |
|
@@ -315,19 +315,11 @@ async def handle_file_operation(update: Update, context: CallbackContext):
|
|
315 |
)
|
316 |
|
317 |
# 需要确认的操作
|
318 |
-
if action in ["
|
319 |
# 生成确认消息
|
320 |
keyboard = [
|
321 |
-
[
|
322 |
-
|
323 |
-
"确认", callback_data=f"yes_f_{action}:{file_id}:{parent_id}"
|
324 |
-
)
|
325 |
-
],
|
326 |
-
[
|
327 |
-
InlineKeyboardButton(
|
328 |
-
"取消", callback_data=f"no_file_{action}:{file_id}:{parent_id}"
|
329 |
-
)
|
330 |
-
],
|
331 |
]
|
332 |
reply_markup = InlineKeyboardMarkup(keyboard)
|
333 |
await query.edit_message_text(
|
@@ -342,7 +334,7 @@ async def perform_file_action(
|
|
342 |
update: Update, context: CallbackContext, action: str, file_id: str, parent_id: str
|
343 |
):
|
344 |
|
345 |
-
if action == "
|
346 |
files = await THUNDERX_CLIENT.file_list(100, file_id, "", {})
|
347 |
keyboard = []
|
348 |
|
@@ -353,7 +345,7 @@ async def perform_file_action(
|
|
353 |
[
|
354 |
InlineKeyboardButton(
|
355 |
f"↩️返回上级",
|
356 |
-
callback_data=f"
|
357 |
),
|
358 |
]
|
359 |
)
|
@@ -364,11 +356,11 @@ async def perform_file_action(
|
|
364 |
[
|
365 |
InlineKeyboardButton(
|
366 |
f"查看📁: {file['name']}",
|
367 |
-
callback_data=f"
|
368 |
),
|
369 |
InlineKeyboardButton(
|
370 |
f"删除",
|
371 |
-
callback_data=f"
|
372 |
),
|
373 |
]
|
374 |
)
|
@@ -377,11 +369,11 @@ async def perform_file_action(
|
|
377 |
[
|
378 |
InlineKeyboardButton(
|
379 |
f"下载📄: {file['name']}",
|
380 |
-
callback_data=f"
|
381 |
),
|
382 |
InlineKeyboardButton(
|
383 |
f"删除",
|
384 |
-
callback_data=f"
|
385 |
),
|
386 |
]
|
387 |
)
|
@@ -391,7 +383,7 @@ async def perform_file_action(
|
|
391 |
await update.callback_query.edit_message_text(
|
392 |
f"📋文件列表:", reply_markup=reply_markup
|
393 |
)
|
394 |
-
elif action == "
|
395 |
result = await THUNDERX_CLIENT.get_download_url(file_id)
|
396 |
download_url = result["web_content_link"]
|
397 |
for media in result["medias"]:
|
@@ -604,9 +596,7 @@ async def init_client():
|
|
604 |
########## 文件操作 ###############
|
605 |
|
606 |
TG_BOT_APPLICATION.add_handler(
|
607 |
-
CallbackQueryHandler(
|
608 |
-
handle_file_operation, pattern="^(del_file|ls_file|dw_file):"
|
609 |
-
)
|
610 |
)
|
611 |
# 处理取消任务操作
|
612 |
TG_BOT_APPLICATION.add_handler(
|
|
|
247 |
[
|
248 |
InlineKeyboardButton(
|
249 |
f"查看📁: {file['name']}",
|
250 |
+
callback_data=f"ls_f:{file['id']}:{file['parent_id']}",
|
251 |
),
|
252 |
InlineKeyboardButton(
|
253 |
f"删除",
|
254 |
+
callback_data=f"del_f:{file['id']}:{file['parent_id']}",
|
255 |
),
|
256 |
]
|
257 |
)
|
|
|
260 |
[
|
261 |
InlineKeyboardButton(
|
262 |
f"下载📄: {file['name']}",
|
263 |
+
callback_data=f"dw_f:{file['id']}:{file['parent_id']}",
|
264 |
),
|
265 |
InlineKeyboardButton(
|
266 |
f"删除",
|
267 |
+
callback_data=f"del_f:{file['id']}:{file['parent_id']}",
|
268 |
),
|
269 |
]
|
270 |
)
|
|
|
284 |
query.data.split(":")[2],
|
285 |
)
|
286 |
|
287 |
+
if action == "yes_f_del_f":
|
288 |
await THUNDERX_CLIENT.delete_forever([file_id])
|
289 |
await query.edit_message_text(f"✅文件 {file_id} 已删除。")
|
290 |
|
|
|
315 |
)
|
316 |
|
317 |
# 需要确认的操作
|
318 |
+
if action in ["del_f"]:
|
319 |
# 生成确认消息
|
320 |
keyboard = [
|
321 |
+
[InlineKeyboardButton("确认", callback_data=f"yes_f_{action}:{file_id}")],
|
322 |
+
[InlineKeyboardButton("取消", callback_data=f"no_f_{action}:{file_id}")],
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
323 |
]
|
324 |
reply_markup = InlineKeyboardMarkup(keyboard)
|
325 |
await query.edit_message_text(
|
|
|
334 |
update: Update, context: CallbackContext, action: str, file_id: str, parent_id: str
|
335 |
):
|
336 |
|
337 |
+
if action == "ls_f":
|
338 |
files = await THUNDERX_CLIENT.file_list(100, file_id, "", {})
|
339 |
keyboard = []
|
340 |
|
|
|
345 |
[
|
346 |
InlineKeyboardButton(
|
347 |
f"↩️返回上级",
|
348 |
+
callback_data=f"ls_f:{parent_id}:{parent_id}",
|
349 |
),
|
350 |
]
|
351 |
)
|
|
|
356 |
[
|
357 |
InlineKeyboardButton(
|
358 |
f"查看📁: {file['name']}",
|
359 |
+
callback_data=f"ls_f:{file['id']}:{file['parent_id']}",
|
360 |
),
|
361 |
InlineKeyboardButton(
|
362 |
f"删除",
|
363 |
+
callback_data=f"del_f:{file['id']}:{file['parent_id']}",
|
364 |
),
|
365 |
]
|
366 |
)
|
|
|
369 |
[
|
370 |
InlineKeyboardButton(
|
371 |
f"下载📄: {file['name']}",
|
372 |
+
callback_data=f"dw_f:{file['id']}:{file['parent_id']}",
|
373 |
),
|
374 |
InlineKeyboardButton(
|
375 |
f"删除",
|
376 |
+
callback_data=f"del_f:{file['id']}:{file['parent_id']}",
|
377 |
),
|
378 |
]
|
379 |
)
|
|
|
383 |
await update.callback_query.edit_message_text(
|
384 |
f"📋文件列表:", reply_markup=reply_markup
|
385 |
)
|
386 |
+
elif action == "dw_f":
|
387 |
result = await THUNDERX_CLIENT.get_download_url(file_id)
|
388 |
download_url = result["web_content_link"]
|
389 |
for media in result["medias"]:
|
|
|
596 |
########## 文件操作 ###############
|
597 |
|
598 |
TG_BOT_APPLICATION.add_handler(
|
599 |
+
CallbackQueryHandler(handle_file_operation, pattern="^(del_f|ls_f|dw_f):")
|
|
|
|
|
600 |
)
|
601 |
# 处理取消任务操作
|
602 |
TG_BOT_APPLICATION.add_handler(
|