From 622f86c8f2ebc30167cdac0d6c8ffd301d6a3923 Mon Sep 17 00:00:00 2001 From: Terry Geng Date: Fri, 10 Apr 2020 10:08:42 +0800 Subject: [PATCH] fix: listfile problem --- README.md | 2 +- command.py | 40 +++++++++++++-------------------------- configuration.default.ini | 6 +++--- 3 files changed, 17 insertions(+), 31 deletions(-) diff --git a/README.md b/README.md index a970262..2ee8589 100644 --- a/README.md +++ b/README.md @@ -146,7 +146,7 @@ If you want information about auto-starting and auto-restarting of the bot, you You can control the bot by both commands sent by text message and the web interface. -By default, all commands start with `!`. You can type `!help` in the text message to see the full list of commands supported, or see the [wiki page](https://github.com/azlux/botamusique/wiki/Command-Help). +By default, all commands start with `!`. You can type `!help` in the text message to see the full list of commands supported, or see the examples on the [wiki page](https://github.com/azlux/botamusique/wiki/Command-Help). The web interface can be used if you'd like an intuitive way of interacting with the bot. Through it is fairly straightforward, a walk-through can be found on the [wiki page](https://github.com/azlux/botamusique/wiki/Web-interface-walk-through). diff --git a/command.py b/command.py index a77ff53..6794fc3 100644 --- a/command.py +++ b/command.py @@ -225,20 +225,6 @@ def cmd_pause(bot, user, text, command, parameter): def cmd_play_file(bot, user, text, command, parameter, do_not_refresh_cache=False): global log, song_shortlist - # if parameter is {index} - if parameter.isdigit(): - music_wrappers = get_cached_wrappers_from_dicts(var.music_db.query_music(Condition() - .and_equal('type', 'file') - .order_by('path') - .limit(1) - .offset(int(parameter))), user) - - if music_wrappers: - var.playlist.append(music_wrappers[0]) - log.info("cmd: add to playlist: " + music_wrappers[0].format_debug_string()) - bot.send_msg(constants.strings('file_added', item=music_wrappers[0].format_song_string()), text) - return - # assume parameter is a path music_wrappers = get_cached_wrappers_from_dicts(var.music_db.query_music(Condition().and_equal('path', parameter)), user) if music_wrappers: @@ -256,7 +242,7 @@ def cmd_play_file(bot, user, text, command, parameter, do_not_refresh_cache=Fals for music_wrapper in music_wrappers: log.info("cmd: add to playlist: " + music_wrapper.format_debug_string()) - msgs.append("{} ({})".format(music_wrapper.item().title, music_wrapper.item().path)) + msgs.append("{:s} ({:s})".format(music_wrapper.item().title, music_wrapper.item().path)) var.playlist.extend(music_wrappers) @@ -753,36 +739,36 @@ def cmd_remove(bot, user, text, command, parameter): def cmd_list_file(bot, user, text, command, parameter): - global log + global song_shortlist - page = 0 + files = var.music_db.query_music(Condition() + .and_equal('type', 'file') + .order_by('path')) - files = [ file['path'] for file in var.music_db.query_music(Condition() - .and_equal('type', 'file') - .order_by('path') - .limit(ITEMS_PER_PAGE) - .offset(page * ITEMS_PER_PAGE)) ] + song_shortlist = files - msgs = [constants.strings("multiple_file_found")] + msgs = [constants.strings("multiple_file_found") + "") if count > ITEMS_PER_PAGE: msgs.append(constants.strings("records_omitted")) - send_multi_lines(bot, msgs, text) + msgs.append(constants.strings("shortlist_instruction")) + send_multi_lines(bot, msgs, text, "") else: - bot.send_msg(constants.strings('no_file'), text) + bot.send_msg(constants.strings("no_file"), text) except re.error as e: msg = constants.strings('wrong_pattern', error=str(e)) diff --git a/configuration.default.ini b/configuration.default.ini index fea11d1..eb6f42a 100644 --- a/configuration.default.ini +++ b/configuration.default.ini @@ -31,7 +31,7 @@ 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", "autoplay" +# playback mode should be one of "one-shot", "repeat", "random", "autoplay" playback_mode = one-shot autoplay_length = 5 clear_when_stop_in_oneshot = False @@ -236,7 +236,7 @@ database_dropped = Database dropped. All records have gone. new_version_found =

Update Available!

New version of botamusique is available, send !update to update! 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. +unknown_mode = Unknown playback mode '{mode}'. It should be one of one-shot, repeat, random. current_mode = Current playback mode is {mode}. change_mode = Playback mode set to {mode} by {user}. repeat = Repeat {song} for {n} times. @@ -277,7 +277,7 @@ help =

Commands

  • !now (or !np) - display the current song
  • !queue - display items in the playlist
  • !tag {tags} - add all items with tags {tags}, tags separated by ",".
  • -
  • !file (or !f) {path/folder/index/keyword} - add a single file to the playlist by its path or index returned by !listfile
  • +
  • !file (or !f) {path/folder/keyword} - add a single file to the playlist by its path or keyword in its path.
  • !filematch (or !fm) {pattern} - add all files that match regex {pattern}
  • !url {url} - add Youtube or SoundCloud music
  • !playlist {url} [{offset}] - add all items in a Youtube or SoundCloud playlist, and start with the {offset}-th item