Skip to content

Local Send Queue System #23

@luni

Description

@luni

Add per-target-bot send queues that throttle xdcc send messages and wait for active transfers to complete before sending the next request, with visibility via API/WebSocket and the web UI.

1. Core Queue Engine (dccbot/ircbot.py)

  • Route send commands into per-target queues (send_queues: dict[str, asyncio.Queue]) keyed by lowercase target nick.
  • Spawn a dedicated asyncio.Task per target (send_queue_tasks) that loops:
    1. Pop next queued message.
    2. Send it via privmsg.
    3. Wait a configurable minimum delay since the last send (send_queue_delay).
    4. Poll until no active transfers from that nick remain in current_transfers.
    5. Wait a post-transfer cooldown (send_queue_cooldown).
    6. Loop.
  • Keep the existing command_queue and process_command_queue() for join/part only.
  • Add a safety cap so the loop does not stall forever if a transfer never starts (send_queue_max_wait).

2. Configurable Timing (config.json)

Add three optional keys with sensible defaults:

  • send_queue_delay (default 15) — minimum seconds between sends to the same bot.
  • send_queue_cooldown (default 5) — extra seconds after a transfer finishes.
  • send_queue_max_wait (default 300) — max seconds to wait for a transfer to start/complete before proceeding.

3. API & WebSocket Exposure (dccbot/app.py)

  • Extend _build_info_payload() with a "queues" array: per-server, per-target list of pending message strings.
  • Broadcast {"type": "queues", "queues": [...]} over WebSocket alongside existing transfers broadcasts.
  • Add /queue WS command to list pending items.
  • Add /cancelqueue <server> <target> WS command to drop pending items for a target.

4. Web UI (static/index.html + static/ws.js)

  • Add a new "Send Queue" panel rendering queued items grouped by server → target bot.
  • Wire onQueues in ws.js and update the panel on each broadcast.

5. Tests

  • test_ircbot.py: per-target queuing, delay enforcement, transfer-aware progression, max-wait fallback.
  • test_api_endpoints.py: /info returns queue snapshot.
  • test_websocket.py: queue broadcasts and WS /queue / /cancelqueue commands.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions