fix: missed repeat command
This commit is contained in:
parent
f1111d9735
commit
4a7dfc48c2
35
command.py
35
command.py
@ -47,6 +47,7 @@ def register_all_commands(bot):
|
|||||||
bot.register_command(constants.commands('list_file'), cmd_list_file)
|
bot.register_command(constants.commands('list_file'), cmd_list_file)
|
||||||
bot.register_command(constants.commands('queue'), cmd_queue)
|
bot.register_command(constants.commands('queue'), cmd_queue)
|
||||||
bot.register_command(constants.commands('random'), cmd_random)
|
bot.register_command(constants.commands('random'), cmd_random)
|
||||||
|
bot.register_command(constants.commands('repeat'), cmd_repeat)
|
||||||
bot.register_command(constants.commands('mode'), cmd_mode)
|
bot.register_command(constants.commands('mode'), cmd_mode)
|
||||||
bot.register_command(constants.commands('drop_database'), cmd_drop_database)
|
bot.register_command(constants.commands('drop_database'), cmd_drop_database)
|
||||||
|
|
||||||
@ -144,8 +145,8 @@ def cmd_play_file(bot, user, text, command, parameter):
|
|||||||
music = {'type': 'file',
|
music = {'type': 'file',
|
||||||
'path': filename,
|
'path': filename,
|
||||||
'user': user}
|
'user': user}
|
||||||
logging.info("cmd: add to playlist: " + filename)
|
|
||||||
music = var.playlist.append(music)
|
music = var.playlist.append(music)
|
||||||
|
logging.info("cmd: add to playlist: " + util.format_debug_song_string(music))
|
||||||
bot.send_msg(constants.strings('file_added', item=util.format_song_string(music)), text)
|
bot.send_msg(constants.strings('file_added', item=util.format_song_string(music)), text)
|
||||||
|
|
||||||
# if parameter is {path}
|
# if parameter is {path}
|
||||||
@ -160,8 +161,8 @@ def cmd_play_file(bot, user, text, command, parameter):
|
|||||||
music = {'type': 'file',
|
music = {'type': 'file',
|
||||||
'path': parameter,
|
'path': parameter,
|
||||||
'user': user}
|
'user': user}
|
||||||
logging.info("cmd: add to playlist: " + parameter)
|
|
||||||
music = var.playlist.append(music)
|
music = var.playlist.append(music)
|
||||||
|
logging.info("cmd: add to playlist: " + util.format_debug_song_string(music))
|
||||||
bot.send_msg(constants.strings('file_added', item=util.format_song_string(music)), text)
|
bot.send_msg(constants.strings('file_added', item=util.format_song_string(music)), text)
|
||||||
return
|
return
|
||||||
|
|
||||||
@ -187,9 +188,8 @@ def cmd_play_file(bot, user, text, command, parameter):
|
|||||||
music = {'type': 'file',
|
music = {'type': 'file',
|
||||||
'path': file,
|
'path': file,
|
||||||
'user': user}
|
'user': user}
|
||||||
logging.info("cmd: add to playlist: " + file)
|
|
||||||
music = var.playlist.append(music)
|
music = var.playlist.append(music)
|
||||||
|
logging.info("cmd: add to playlist: " + util.format_debug_song_string(music))
|
||||||
msgs.append("{} ({})".format(music['title'], music['path']))
|
msgs.append("{} ({})".format(music['title'], music['path']))
|
||||||
|
|
||||||
if count != 0:
|
if count != 0:
|
||||||
@ -207,8 +207,8 @@ def cmd_play_file(bot, user, text, command, parameter):
|
|||||||
music = {'type': 'file',
|
music = {'type': 'file',
|
||||||
'path': matches[0][1],
|
'path': matches[0][1],
|
||||||
'user': user}
|
'user': user}
|
||||||
logging.info("cmd: add to playlist: " + matches[0][1])
|
|
||||||
music = var.playlist.append(music)
|
music = var.playlist.append(music)
|
||||||
|
logging.info("cmd: add to playlist: " + util.format_debug_song_string(music))
|
||||||
bot.send_msg(constants.strings('file_added', item=util.format_song_string(music)), text)
|
bot.send_msg(constants.strings('file_added', item=util.format_song_string(music)), text)
|
||||||
else:
|
else:
|
||||||
msgs = [ constants.strings('multiple_matches')]
|
msgs = [ constants.strings('multiple_matches')]
|
||||||
@ -231,8 +231,8 @@ def cmd_play_file_match(bot, user, text, command, parameter):
|
|||||||
music = {'type': 'file',
|
music = {'type': 'file',
|
||||||
'path': file,
|
'path': file,
|
||||||
'user': user}
|
'user': user}
|
||||||
logging.info("cmd: add to playlist: " + file)
|
|
||||||
music = var.playlist.append(music)
|
music = var.playlist.append(music)
|
||||||
|
logging.info("cmd: add to playlist: " + util.format_debug_song_string(music))
|
||||||
|
|
||||||
msgs.append("{} ({})".format(music['title'], music['path']))
|
msgs.append("{} ({})".format(music['title'], music['path']))
|
||||||
|
|
||||||
@ -257,8 +257,8 @@ def cmd_play_url(bot, user, text, command, parameter):
|
|||||||
|
|
||||||
music = bot.validate_music(music)
|
music = bot.validate_music(music)
|
||||||
if music:
|
if music:
|
||||||
var.playlist.append(music)
|
music = var.playlist.append(music)
|
||||||
logging.info("cmd: add to playlist: " + music['url'])
|
logging.info("cmd: add to playlist: " + util.format_debug_song_string(music))
|
||||||
bot.send_msg(constants.strings('file_added', item=util.format_song_string(music)), text)
|
bot.send_msg(constants.strings('file_added', item=util.format_song_string(music)), text)
|
||||||
if var.playlist.length() == 2:
|
if var.playlist.length() == 2:
|
||||||
# If I am the second item on the playlist. (I am the next one!)
|
# If I am the second item on the playlist. (I am the next one!)
|
||||||
@ -303,7 +303,7 @@ def cmd_play_radio(bot, user, text, command, parameter):
|
|||||||
'url': url,
|
'url': url,
|
||||||
'user': user}
|
'user': user}
|
||||||
var.playlist.append(music)
|
var.playlist.append(music)
|
||||||
logging.info("cmd: add to playlist: " + music['url'])
|
logging.info("cmd: add to playlist: " + util.format_debug_song_string(music))
|
||||||
bot.async_download_next()
|
bot.async_download_next()
|
||||||
else:
|
else:
|
||||||
bot.send_msg(constants.strings('bad_url'))
|
bot.send_msg(constants.strings('bad_url'))
|
||||||
@ -402,7 +402,7 @@ def cmd_rb_play(bot, user, text, command, parameter):
|
|||||||
'url': url,
|
'url': url,
|
||||||
'user': user}
|
'user': user}
|
||||||
var.playlist.append(music)
|
var.playlist.append(music)
|
||||||
logging.info("cmd: add to playlist: " + music['url'])
|
logging.info("cmd: add to playlist: " + util.format_debug_song_string(music))
|
||||||
bot.async_download_next()
|
bot.async_download_next()
|
||||||
else:
|
else:
|
||||||
logging.info('cmd: No playable url found.')
|
logging.info('cmd: No playable url found.')
|
||||||
@ -609,6 +609,21 @@ def cmd_random(bot, user, text, command, parameter):
|
|||||||
bot.interrupt_playing()
|
bot.interrupt_playing()
|
||||||
var.playlist.randomize()
|
var.playlist.randomize()
|
||||||
|
|
||||||
|
def cmd_repeat(bot, user, text, command, parameter):
|
||||||
|
repeat = 1
|
||||||
|
if parameter is not None and parameter.isdigit():
|
||||||
|
repeat = int(parameter)
|
||||||
|
|
||||||
|
music = var.playlist.current_item()
|
||||||
|
for _ in range(repeat):
|
||||||
|
var.playlist.insert(
|
||||||
|
var.playlist.current_index + 1,
|
||||||
|
music
|
||||||
|
)
|
||||||
|
logging.info("bot: add to playlist: " + util.format_debug_song_string(music))
|
||||||
|
|
||||||
|
bot.send_msg(constants.strings("repeat", song=util.format_song_string(music), n=str(repeat)), text)
|
||||||
|
|
||||||
def cmd_mode(bot, user, text, command, parameter):
|
def cmd_mode(bot, user, text, command, parameter):
|
||||||
if not parameter:
|
if not parameter:
|
||||||
bot.send_msg(constants.strings("current_mode", mode=var.playlist.mode), text)
|
bot.send_msg(constants.strings("current_mode", mode=var.playlist.mode), text)
|
||||||
|
@ -191,6 +191,7 @@ file_missed = Music file '{file}' missed! This item has been removed from the pl
|
|||||||
unknown_mode = Unknown playback mode '{mode}'. It should be one of <i>one-shot</i>, <i>loop</i>, <i>random</i>.
|
unknown_mode = Unknown playback mode '{mode}'. It should be one of <i>one-shot</i>, <i>loop</i>, <i>random</i>.
|
||||||
current_mode = Current playback mode is <i>{mode}</i>.
|
current_mode = Current playback mode is <i>{mode}</i>.
|
||||||
change_mode = Playback mode set to <i>{mode}</i> by {user}.
|
change_mode = Playback mode set to <i>{mode}</i> by {user}.
|
||||||
|
repeat = Repeat {song} for {n} times.
|
||||||
|
|
||||||
help = <h3>Commands</h3>
|
help = <h3>Commands</h3>
|
||||||
<b>Control</b>
|
<b>Control</b>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user