Update app.py
Browse files
app.py
CHANGED
|
@@ -295,7 +295,7 @@ async def do_upload_job(
|
|
| 295 |
last_update = [0]
|
| 296 |
download_start = time.time()
|
| 297 |
total_size = expected_size if expected_size and expected_size > 0 else 0
|
| 298 |
-
|
| 299 |
async def download_progress(current, total):
|
| 300 |
nonlocal total_size
|
| 301 |
now = time.time()
|
|
@@ -533,6 +533,7 @@ async def delete_all_user_files(chat_id, user_id, query: CallbackQuery):
|
|
| 533 |
|
| 534 |
|
| 535 |
async def refresh_file_list(chat_id: int, user_id: int, message: Message):
|
|
|
|
| 536 |
user_files = db_get_user_files(user_id)
|
| 537 |
if not user_files:
|
| 538 |
return await message.edit_text("You have no uploaded files.", reply_markup=None)
|
|
@@ -541,10 +542,9 @@ async def refresh_file_list(chat_id: int, user_id: int, message: Message):
|
|
| 541 |
for enc_path, orig_name, _ in user_files:
|
| 542 |
token = make_token()
|
| 543 |
file_callback_map[token] = enc_path
|
| 544 |
-
#
|
| 545 |
-
display_name = orig_name if len(orig_name) <= 60 else orig_name[:57] + "..."
|
| 546 |
buttons.append([
|
| 547 |
-
InlineKeyboardButton(f"๐ฅ {
|
| 548 |
InlineKeyboardButton("๐ Delete", callback_data=f"delete:{token}"),
|
| 549 |
])
|
| 550 |
buttons.append([InlineKeyboardButton("โ ๏ธ Delete All Files", callback_data=f"delete_all:{user_id}")])
|
|
@@ -587,8 +587,7 @@ async def process_album_group(media_group_id: str):
|
|
| 587 |
for msg_id, fname, fid in messages:
|
| 588 |
individual_token = make_token()
|
| 589 |
upload_prompt_map[individual_token] = [(user_id, msg_id, fname, fid)]
|
| 590 |
-
|
| 591 |
-
button_rows.append([InlineKeyboardButton(f"๐ค {display_name}", callback_data=f"upload:{individual_token}")])
|
| 592 |
button_rows.append([InlineKeyboardButton("โ Cancel", callback_data="cancel_upload:0")])
|
| 593 |
|
| 594 |
await app.send_message(chat_id,
|
|
@@ -712,9 +711,8 @@ async def cmd_files(_, message: Message):
|
|
| 712 |
for enc_path, orig_name, _ in user_files:
|
| 713 |
token = make_token()
|
| 714 |
file_callback_map[token] = enc_path
|
| 715 |
-
display_name = orig_name if len(orig_name) <= 60 else orig_name[:57] + "..."
|
| 716 |
buttons.append([
|
| 717 |
-
InlineKeyboardButton(f"๐ฅ {
|
| 718 |
InlineKeyboardButton("๐ Delete", callback_data=f"delete:{token}"),
|
| 719 |
])
|
| 720 |
buttons.append([InlineKeyboardButton("โ ๏ธ Delete All Files", callback_data=f"delete_all:{user_id}")])
|
|
|
|
| 295 |
last_update = [0]
|
| 296 |
download_start = time.time()
|
| 297 |
total_size = expected_size if expected_size and expected_size > 0 else 0
|
| 298 |
+
Upload images, audio, and videos by dragging in the text input, pasting, or clicking here.
|
| 299 |
async def download_progress(current, total):
|
| 300 |
nonlocal total_size
|
| 301 |
now = time.time()
|
|
|
|
| 533 |
|
| 534 |
|
| 535 |
async def refresh_file_list(chat_id: int, user_id: int, message: Message):
|
| 536 |
+
"""Reโfetch user files and edit the message with updated buttons."""
|
| 537 |
user_files = db_get_user_files(user_id)
|
| 538 |
if not user_files:
|
| 539 |
return await message.edit_text("You have no uploaded files.", reply_markup=None)
|
|
|
|
| 542 |
for enc_path, orig_name, _ in user_files:
|
| 543 |
token = make_token()
|
| 544 |
file_callback_map[token] = enc_path
|
| 545 |
+
# Exactly as original: truncate to 40 characters
|
|
|
|
| 546 |
buttons.append([
|
| 547 |
+
InlineKeyboardButton(f"๐ฅ {orig_name[:40]}", callback_data=f"get:{token}"),
|
| 548 |
InlineKeyboardButton("๐ Delete", callback_data=f"delete:{token}"),
|
| 549 |
])
|
| 550 |
buttons.append([InlineKeyboardButton("โ ๏ธ Delete All Files", callback_data=f"delete_all:{user_id}")])
|
|
|
|
| 587 |
for msg_id, fname, fid in messages:
|
| 588 |
individual_token = make_token()
|
| 589 |
upload_prompt_map[individual_token] = [(user_id, msg_id, fname, fid)]
|
| 590 |
+
button_rows.append([InlineKeyboardButton(f"๐ค {fname[:40]}", callback_data=f"upload:{individual_token}")])
|
|
|
|
| 591 |
button_rows.append([InlineKeyboardButton("โ Cancel", callback_data="cancel_upload:0")])
|
| 592 |
|
| 593 |
await app.send_message(chat_id,
|
|
|
|
| 711 |
for enc_path, orig_name, _ in user_files:
|
| 712 |
token = make_token()
|
| 713 |
file_callback_map[token] = enc_path
|
|
|
|
| 714 |
buttons.append([
|
| 715 |
+
InlineKeyboardButton(f"๐ฅ {orig_name[:40]}", callback_data=f"get:{token}"),
|
| 716 |
InlineKeyboardButton("๐ Delete", callback_data=f"delete:{token}"),
|
| 717 |
])
|
| 718 |
buttons.append([InlineKeyboardButton("โ ๏ธ Delete All Files", callback_data=f"delete_all:{user_id}")])
|