Add a live status line to the stats panel
Shows what's happening right now underneath the table (connecting, resolving the friend, discovering targets, fetching channel history, waiting out a jittered delay before reacting, sending a reaction, removing a reaction during --undo, etc). Status updates are cheap and DB-free, using the last fetched stats for re-rendering.
This commit is contained in:
11
bot/undo.py
11
bot/undo.py
@@ -24,6 +24,9 @@ async def undo_all_reactions(client: discord.Client, storage: Storage, display:
|
||||
emoji = row["emoji"]
|
||||
should_clear_log = True
|
||||
|
||||
if display is not None:
|
||||
display.set_status(f"Removing reaction from message {message_id} ({i}/{total})...")
|
||||
|
||||
try:
|
||||
channel = client.get_channel(channel_id) or await client.fetch_channel(channel_id)
|
||||
message = await channel.fetch_message(message_id)
|
||||
@@ -41,11 +44,17 @@ async def undo_all_reactions(client: discord.Client, storage: Storage, display:
|
||||
if display is not None:
|
||||
await display.refresh()
|
||||
|
||||
await asyncio.sleep(human_jitter())
|
||||
delay = human_jitter()
|
||||
if display is not None:
|
||||
display.set_status(f"Waiting {delay:.1f}s before next removal...")
|
||||
await asyncio.sleep(delay)
|
||||
|
||||
if display is not None:
|
||||
display.set_status("Clearing channel resume points and found-message log...")
|
||||
cleared = await asyncio.to_thread(storage.clear_scan_state)
|
||||
await asyncio.to_thread(storage.reset_message_counts)
|
||||
if display is not None:
|
||||
display.set_status("Undo complete.")
|
||||
await display.refresh()
|
||||
log.info(
|
||||
"Undo complete: removed %d/%d reaction(s), cleared %d channel resume point(s) — "
|
||||
|
||||
Reference in New Issue
Block a user