diff --git a/command.py b/command.py index b46d213..66c4984 100644 --- a/command.py +++ b/command.py @@ -614,7 +614,11 @@ def cmd_mode(bot, user, text, command, parameter): if not parameter in ["one-shot", "loop", "random"]: bot.send_msg(constants.strings('unknown_mode', mode=parameter), text) else: + var.db.set('playlist', 'playback_mode', parameter) var.playlist.set_mode(parameter) + logging.info("command: playback mode changed to %s." % parameter) + bot.send_msg(constants.strings("change_mode", mode=var.playlist.mode, + user=bot.mumble.users[text.actor]['name']), text) if parameter == "random": bot.stop() var.playlist.randomize() diff --git a/configuration.default.ini b/configuration.default.ini index e71393d..813c3a9 100644 --- a/configuration.default.ini +++ b/configuration.default.ini @@ -31,6 +31,8 @@ username = botamusique comment = Hi, I'm here to play radio, local music or youtube/soundcloud music. Have fun! # default volume from 0 to 1. volume = 0.1 +# playback mode should be one of "one-shot", "loop", "random" +playback_mode = one-shot # Users allowed to kill the bot, or ban URLs. admin = User1;User2; @@ -148,20 +150,20 @@ ducking_volume = duckv drop_database = dropdatabase [strings] -current_volume = Current volume: {volume} -current_ducking_volume = Volume on ducking: {volume} -change_volume = Volume set to {volume} by {user} -change_ducking_volume = Volume on ducking set to {volume} by {user} -bad_command = {command}: command not found -bad_parameter = {command}: invalid parameter +current_volume = Current volume: {volume}. +current_ducking_volume = Volume on ducking: {volume}. +change_volume = Volume set to {volume} by {user}. +change_ducking_volume = Volume on ducking set to {volume} by {user}. +bad_command = {command}: command not found. +bad_parameter = {command}: invalid parameter. error_executing_command = {command}: Command failed with error: {error}. not_admin = You are not an admin! -not_playing = Nothing is playing right now -no_file = File not found -wrong_pattern = Invalid regex: {error} -file_added = Added: {item} +not_playing = Nothing is playing right now. +no_file = File not found. +wrong_pattern = Invalid regex: {error}. +file_added = Added: {item}. multiple_file_added = Multiple files added: -bad_url = Bad URL requested +bad_url = Bad URL requested. preconfigurated_radio = Preconfigurated Radio available: unable_download = Error while downloading music... which_command = Do you mean
{commands} @@ -172,8 +174,8 @@ now_playing = Now playing {item}
{thumb} not_in_my_channel = You're not in my channel, command refused! pm_not_allowed = Private message aren't allowed. too_long = This music is too long, skip! -download_in_progress = Download of {item} in progress -removing_item = Removed entry {item} from playlist +download_in_progress = Download of {item} in progress... +removing_item = Removed entry {item} from playlist. user_ban = You are banned, not allowed to do that! url_ban = This url is banned! rb_query_result = This is the result of your query, send !rbplay 'ID' to play a station: @@ -187,6 +189,7 @@ start_updating = Start updating... file_missed = Music file '{file}' missed! This item has been removed from the playlist. unknown_mode = Unknown playback mode '{mode}'. It should be one of one-shot, loop, random. current_mode = Current playback mode is {mode}. +change_mode = Playback mode set to {mode} by {user}. help =

Commands

Control diff --git a/configuration.example.ini b/configuration.example.ini index 863ee4d..b592cef 100644 --- a/configuration.example.ini +++ b/configuration.example.ini @@ -8,6 +8,7 @@ # ======================================================== # [server] section tells the bot how to connect to your murmur server. +# This section will be overridden by command line arguments. [server] host = 127.0.0.1 port = 64738 @@ -24,14 +25,26 @@ port = 64738 #comment = Hi, I'm here to play radio, local music or youtube/soundcloud music. Have fun! # 'volume' is default volume from 0 to 1. +# This option will be overridden by value in the database. #volume = 0.1 +# 'playback_mode' defined the playback mode of the bot. +# it should be one of "one-shot" (play the playlist once), "loop" (looping through the playlist), +# or "random" (randomize the playlist). +# This option will be overridden by value in the database. +#playback_mode = one-shot + # 'admin': Users allowed to kill the bot, or ban URLs. Separated by ';' #admin = User1;User2; # 'music_folder': Folder that stores your local songs. #music_folder = music_folder/ +# 'database_path': The path of the database. The database will store things like your volume +# set by command !volume, your playback mode and your playlist, etc. +# This option will be overridden by command line arguments. +#database_path = database.db + # 'tmp_folder': Folder that stores the downloaded music. # 'tmp_folder_max_size': in MB, 0 for no cache, -1 for unlimited size # 'ignored_folders', 'ignored_files': files and folders that would be ignored during scanning. diff --git a/media/playlist.py b/media/playlist.py index 7e569f7..40dfa97 100644 --- a/media/playlist.py +++ b/media/playlist.py @@ -16,7 +16,6 @@ class PlayList(list): def set_mode(self, mode): # modes are "one-shot", "loop", "random" self.mode = mode - var.db.set('playlist', 'mode', mode) if mode == "random": self.randomize() diff --git a/mumbleBot.py b/mumbleBot.py index b0210a1..84d4677 100644 --- a/mumbleBot.py +++ b/mumbleBot.py @@ -752,7 +752,16 @@ if __name__ == '__main__': var.botamusique = MumbleBot(args) command.register_all_commands(var.botamusique) - if var.config.getboolean('debug', 'save_playlist', fallback=True): + playback_mode = None + if var.db.has_option("playlist", "playback_mode"): + playback_mode = var.db.get('playlist', 'playback_mode') + else: + playback_mode = var.config.get('bot', 'playback_mode', fallback="one-shot") + + if playback_mode in ["one-shot", "loop", "random"]: + var.playlist.set_mode(playback_mode) + + if var.config.getboolean('bot', 'save_playlist', fallback=True): logging.info("bot: load playlist from previous session") var.playlist.load()