feat: support relative volume adjustment (+N/-N)

!volume +10 increases by 10, !volume -5 decreases by 5.
Out-of-range results (below 0 or above 100) are rejected.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
user
2026-02-22 00:18:43 +01:00
parent f189cbd290
commit f899241d73
2 changed files with 44 additions and 4 deletions

View File

@@ -405,13 +405,14 @@ async def cmd_testtone(bot, message):
await bot.reply(message, "Test tone complete")
@command("volume", help="Music: !volume [0-100]")
@command("volume", help="Music: !volume [0-100|+N|-N]")
async def cmd_volume(bot, message):
"""Get or set playback volume.
Usage:
!volume Show current volume
!volume <0-100> Set volume (takes effect immediately)
!volume +N/-N Adjust volume relatively
"""
if not _is_mumble(bot):
return
@@ -422,12 +423,18 @@ async def cmd_volume(bot, message):
await bot.reply(message, f"Volume: {ps['volume']}%")
return
arg = parts[1].strip()
relative = arg.startswith("+") or (arg.startswith("-") and arg != "-")
try:
val = int(parts[1])
val = int(arg)
except ValueError:
await bot.reply(message, "Usage: !volume <0-100>")
await bot.reply(message, "Usage: !volume <0-100|+N|-N>")
return
if relative:
val = ps["volume"] + val
if val < 0 or val > 100:
await bot.reply(message, "Volume must be 0-100")
return