mirror of
https://github.com/ZHANGTIANYAO1/teamspeak-music-bot.git
synced 2026-10-02 04:52:50 +08:00
feat: persist volume, play mode and audio quality across restarts
Runtime playback settings were kept only in memory (AudioPlayer.volume, PlayQueue.mode, each provider's quality field), so restarting the bot reset them to defaults and users had to re-tune volume and quality every time (#125). Persist and restore them via the repo's existing storage: - Volume and play mode are per-bot, stored on new bot_instances columns (volume, play_mode) with a schema migration; restored when the instance is (re)built, written by cmdVol / cmdMode which every entry point (chat command, WebUI, REST) funnels through. Volume and mode are written independently so a transient !fm/!artist mode switch never overwrites the user's saved !mode. - Per-provider audio quality is global (shared providers), stored in a new config.json `audioQuality` block; applied to the providers at startup and re-snapshotted on POST /api/music/quality. Queue, current song, progress and FM/artist sessions stay ephemeral. Adds tests for config sanitize/round-trip, DB player-settings + migration, cmdVol/cmdMode persistence + construction-time restore, and quality persistence through the REST endpoint. Documents the behavior in the README. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
051171b019
commit
fbd94c424b
11 files changed
+618
-12
No files matched your search
@@ -100,6 +100,15 @@ async function main() {
|
||||
if (jellyfinAuth) jellyfinProvider.setCookie(jellyfinAuth);
|
||||
jellyfinProvider.setPersist((serialized) => cookieStore.save("jellyfin", serialized));
|
||||
|
||||
// Restore the persisted per-provider audio quality (#125) onto the shared,
|
||||
// process-wide providers so a restart keeps the user's choice. setQuality()
|
||||
// normalizes/ignores unknown values, so a stale entry can never break playback.
|
||||
neteaseProvider.setQuality(config.audioQuality.netease);
|
||||
qqProvider.setQuality(config.audioQuality.qq);
|
||||
bilibiliProvider.setQuality(config.audioQuality.bilibili);
|
||||
kugouProvider.setQuality(config.audioQuality.kugou);
|
||||
jellyfinProvider.setQuality(config.audioQuality.jellyfin);
|
||||
|
||||
const permissions = createPermissionStore(db.db);
|
||||
|
||||
// Single process-wide Spotify authorization (one Premium account for Stage 3).
|
||||
|
||||
Reference in new issue
Block a user