feat: add 'clear_when_stop_in_oneshot' option in config for azlux

This commit is contained in:
Terry Geng 2020-03-20 10:49:44 +08:00
parent 4e287d6b1b
commit 1d1ff50a59
4 changed files with 13 additions and 2 deletions

View File

@ -565,7 +565,11 @@ def cmd_help(bot, user, text, command, parameter):
def cmd_stop(bot, user, text, command, parameter):
global log
bot.stop()
if var.config.getboolean("bot", "clear_when_stop_in_oneshot", fallback=False) \
and var.playlist.mode == 'one-shot':
cmd_clear(bot, user, text, command, parameter)
else:
bot.stop()
bot.send_msg(constants.strings('stopped'), text)

View File

@ -34,6 +34,7 @@ volume = 0.1
# playback mode should be one of "one-shot", "loop", "random", "autoplay"
playback_mode = one-shot
autoplay_length = 5
clear_when_stop_in_oneshot = False
# target version, stable or testing (testing need to bot installed with git)
target_version = stable

View File

@ -33,8 +33,10 @@ port = 64738
# or "random" (randomize the playlist), "autoplay" (randomly grab something from the music library).
# This option will be overridden by value in the database.
# 'autoplay_length': how many songs the autoplay mode fills the playlist
# 'clear_when_stop_in_oneshot': clear the playlist when stop the bot in one-shot mode.
#playback_mode = one-shot
#autoplay_length = 5
#clear_when_stop_in_oneshot = False
# target version, stable or testing (testing need to bot installed with git)
# stable will use simple bash with curl command to get releases, testing will follow github master branch with git commands

View File

@ -334,7 +334,11 @@ def post():
var.cache.build_dir_cache(var.bot)
log.info("web: Local file cache refreshed.")
elif action == "stop":
var.bot.stop()
if var.config.getboolean("bot", "clear_when_stop_in_oneshot", fallback=False) \
and var.playlist.mode == 'one-shot':
var.bot.clear()
else:
var.bot.stop()
elif action == "pause":
var.bot.pause()
elif action == "resume":