feat: Enhance batch notification formatting and reduce delay
This commit is contained in:
12
app/app.py
12
app/app.py
@@ -213,13 +213,13 @@ async def send_batch_notification():
|
|||||||
file_list_str = ""
|
file_list_str = ""
|
||||||
if num_files > 0:
|
if num_files > 0:
|
||||||
filenames = [name or "file" for name, _ in batch_copy]
|
filenames = [name or "file" for name, _ in batch_copy]
|
||||||
if num_files > 20:
|
if num_files > 15:
|
||||||
file_list_str = "\n".join(f"- {name}" for name in filenames[:20])
|
file_list_str = "\n".join(f"{name}" for name in filenames[:15])
|
||||||
file_list_str += f"\n... and {num_files - 20} more."
|
file_list_str += f"\n... and {num_files - 15} more."
|
||||||
else:
|
else:
|
||||||
file_list_str = "\n".join(f"- {name}" for name in filenames)
|
file_list_str = "\n".join(f"{name}" for name in filenames)
|
||||||
|
|
||||||
msg = f"✅ Batch upload complete!\n\n- Files: {num_files}\n- Total size: {human_size(total_size)}\n\n{file_list_str}".strip()
|
msg = f"New files uploaded:\n\n- Files: {num_files}\n- Total size: {human_size(total_size)}\n\n```\n{file_list_str}\n```".strip()
|
||||||
await send_telegram_message(TELEGRAM_OWNER_ID, msg)
|
await send_telegram_message(TELEGRAM_OWNER_ID, msg)
|
||||||
|
|
||||||
def _schedule_batch_notification():
|
def _schedule_batch_notification():
|
||||||
@@ -236,7 +236,7 @@ async def reset_telegram_debounce():
|
|||||||
if _batch_complete_timer:
|
if _batch_complete_timer:
|
||||||
_batch_complete_timer.cancel()
|
_batch_complete_timer.cancel()
|
||||||
loop = asyncio.get_event_loop()
|
loop = asyncio.get_event_loop()
|
||||||
_batch_complete_timer = loop.call_later(30, _schedule_batch_notification)
|
_batch_complete_timer = loop.call_later(10, _schedule_batch_notification)
|
||||||
|
|
||||||
async def add_file_to_batch(filename: str, size: int):
|
async def add_file_to_batch(filename: str, size: int):
|
||||||
"""Adds a completed file to the batch list."""
|
"""Adds a completed file to the batch list."""
|
||||||
|
|||||||
Reference in New Issue
Block a user