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:
2026-08-01 18:53:48 +02:00
parent ab0afa149a
commit 7b3c358b05
5 changed files with 57 additions and 11 deletions

View File

@@ -42,6 +42,10 @@ async def scan_channel_backlog(
channel_id = getattr(channel, "id", None)
if channel_id is None:
return
chan_label = getattr(channel, "name", None) or target.name
if display is not None:
display.set_status(f"Checking {chan_label} for previously found, unreacted message(s)...")
found_messages = []
pending_ids = await asyncio.to_thread(storage.get_pending_found_message_ids, channel_id, emoji)
@@ -57,6 +61,9 @@ async def scan_channel_backlog(
newest_id_seen = int(state["newest_id_seen"]) if state and state.get("newest_id_seen") else None
after = discord.Object(id=newest_id_seen) if newest_id_seen else cutoff
if display is not None:
display.set_status(f"Fetching message history for {chan_label}...")
try:
async for message in channel.history(after=after, oldest_first=True, limit=None):
if newest_id_seen is None or message.id > newest_id_seen:
@@ -68,6 +75,7 @@ async def scan_channel_backlog(
storage.record_message_found, message.id, channel_id, target.target_id, friend_id
)
if display is not None:
display.set_status(f"Scanning {chan_label}{len(found_messages)} found so far...")
await display.refresh()
await asyncio.to_thread(storage.set_scan_state, channel_id, target.target_id, newest_id_seen, True)
@@ -78,5 +86,7 @@ async def scan_channel_backlog(
log.exception("HTTP error scanning channel %s", channel_id)
return
for message in found_messages:
for i, message in enumerate(found_messages, start=1):
if display is not None:
display.set_status(f"Reacting to message {i}/{len(found_messages)} in {chan_label}...")
await react_fn(message, target)