Skip to content

feat: optional idle-leave-after-playback timeout#1

Closed
seitzbg wants to merge 8 commits into
deploy/docker8from
feat/idle-leave
Closed

feat: optional idle-leave-after-playback timeout#1
seitzbg wants to merge 8 commits into
deploy/docker8from
feat/idle-leave

Conversation

@seitzbg

@seitzbg seitzbg commented Jun 1, 2026

Copy link
Copy Markdown
Owner

Summary

  • Adds an optional, default-off IDLE_LEAVE_TIMEOUT (seconds). When playback ends — a video finishing on its own or !stop — and nothing new starts within the timeout, the bot leaves voice and posts a short note. Unset / empty / 0 keeps today's behavior (the bot stays put).
  • Per-guild asyncio timer armed from the playback-cleanup (finally) blocks in cogs/stream.py (covers both the camera and go-live paths). A fire-time guard re-checks the bot is genuinely idle (stream_tasks/live_connections empty, vc not playing, still connected) before disconnecting, so it never cuts off active or resumed playback.
  • Starting new playback re-arms (replacing any prior timer); !leave and auto-leave-on-empty cancel it. Timers are also cancelled on bot shutdown.

Implementation notes

  • New helpers in cogs/stream.py: _idle_leave_timeout, _format_idle, schedule_idle_leave, cancel_idle_leave, _idle_leave_after, _idle_leave_now.
  • SlopSoil gains idle_leave_tasks: dict[int, asyncio.Task] (cancelled in close()).
  • cogs/voice.py cancels the timer on !leave and auto-leave-on-empty.
  • Docs: IDLE_LEAVE_TIMEOUT added to .env.example and the README config table + features list.
  • Design spec and implementation plan included under docs/superpowers/.

Test Plan

  • pytest — full suite green (176 tests), including new tests/test_idle_leave.py (config parsing, duration formatting, schedule/re-arm/cancel, idle-guard no-ops, and !leave/auto-leave cancellation wiring).
  • Manual: set IDLE_LEAVE_TIMEOUT=30, play a short clip, let it finish → bot leaves after ~30s and posts "left after 30 sec idle".
  • Manual: !stop mid-clip → bot leaves after the timeout.
  • Manual: start a new video before the timeout → bot stays; !leave before the timeout → no spurious idle message.
  • Manual: unset/0 → bot never auto-leaves on idle (current behavior).

@seitzbg

seitzbg commented Jun 1, 2026

Copy link
Copy Markdown
Owner Author

Superseded by the upstream PR against dev-topsoil/slopsoil: dev-topsoil#16 (clean, idle-leave-only, based on upstream main).

@seitzbg seitzbg closed this Jun 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant