feat: add !resume to continue playback from last interruption

Tracks playback position via frame counting in stream_audio().
On stop/skip, saves URL + elapsed time to bot.state (SQLite).
!resume reloads the track and seeks to the saved position via
ffmpeg -ss. State persists across bot restarts.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
user
2026-02-22 00:15:39 +01:00
parent 9d58a5d073
commit f189cbd290
5 changed files with 227 additions and 9 deletions

View File

@@ -551,6 +551,7 @@ HTML stripped on receive, escaped on send. IRC-only commands are no-ops.
!play classical music # YouTube search, random pick from top 10
!stop # Stop playback, clear queue
!skip # Skip current track
!resume # Resume last stopped/skipped track
!queue # Show queue
!queue <url> # Add to queue (alias for !play)
!np # Now playing
@@ -561,6 +562,7 @@ HTML stripped on receive, escaped on send. IRC-only commands are no-ops.
Requires: `yt-dlp`, `ffmpeg`, `libopus` on the host.
Max 50 tracks in queue. Playlists auto-expand; excess truncated at limit.
Volume ramps smoothly over ~1s (no abrupt jumps mid-playback).
`!resume` restores position across restarts (persisted via `bot.state`).
Mumble-only: `!play` replies with error on other adapters, others silently no-op.
## Plugin Template

View File

@@ -1569,6 +1569,7 @@ and voice transmission.
!play <query> Search YouTube, play a random result
!stop Stop playback, clear queue
!skip Skip current track
!resume Resume last stopped/skipped track from saved position
!queue Show queue
!queue <url> Add to queue (alias for !play)
!np Now playing
@@ -1589,3 +1590,5 @@ and voice transmission.
other music commands silently no-op
- Playback runs as an asyncio background task; the bot remains responsive
to text commands during streaming
- `!resume` continues from where playback was interrupted (`!stop`/`!skip`);
position is persisted via `bot.state` and survives bot restarts