feat: Prompt the position of the song added by cli. Implement #186.
This commit is contained in:
parent
7daef187a4
commit
56399c499f
24
command.py
24
command.py
@ -113,6 +113,18 @@ def send_multi_lines_in_channel(bot, lines, linebreak="<br />"):
|
|||||||
bot.send_channel_msg(msg)
|
bot.send_channel_msg(msg)
|
||||||
|
|
||||||
|
|
||||||
|
def send_item_added_message(bot, wrapper, index, text):
|
||||||
|
if index == var.playlist.current_index + 1:
|
||||||
|
bot.send_msg(tr('file_added', item=wrapper.format_song_string()) +
|
||||||
|
tr('position_in_the_queue', position=tr('next_to_play')), text)
|
||||||
|
elif index == len(var.playlist) - 1:
|
||||||
|
bot.send_msg(tr('file_added', item=wrapper.format_song_string()) +
|
||||||
|
tr('position_in_the_queue', position=tr('last_song_on_the_queue')), text)
|
||||||
|
else:
|
||||||
|
bot.send_msg(tr('file_added', item=wrapper.format_song_string()) +
|
||||||
|
tr('position_in_the_queue', position=f"{index + 1}/{len(var.playlist)}."), text)
|
||||||
|
|
||||||
|
|
||||||
# ---------------- Variables -----------------
|
# ---------------- Variables -----------------
|
||||||
|
|
||||||
ITEMS_PER_PAGE = 50
|
ITEMS_PER_PAGE = 50
|
||||||
@ -223,7 +235,7 @@ def cmd_play_file(bot, user, text, command, parameter, do_not_refresh_cache=Fals
|
|||||||
if music_wrappers:
|
if music_wrappers:
|
||||||
var.playlist.append(music_wrappers[0])
|
var.playlist.append(music_wrappers[0])
|
||||||
log.info("cmd: add to playlist: " + music_wrappers[0].format_debug_string())
|
log.info("cmd: add to playlist: " + music_wrappers[0].format_debug_string())
|
||||||
bot.send_msg(tr('file_added', item=music_wrappers[0].format_song_string()), text)
|
send_item_added_message(bot, music_wrappers[0], len(var.playlist) - 1, text)
|
||||||
return
|
return
|
||||||
|
|
||||||
# assume parameter is a folder
|
# assume parameter is a folder
|
||||||
@ -250,7 +262,7 @@ def cmd_play_file(bot, user, text, command, parameter, do_not_refresh_cache=Fals
|
|||||||
music_wrapper = get_cached_wrapper_from_dict(matches[0], user)
|
music_wrapper = get_cached_wrapper_from_dict(matches[0], user)
|
||||||
var.playlist.append(music_wrapper)
|
var.playlist.append(music_wrapper)
|
||||||
log.info("cmd: add to playlist: " + music_wrapper.format_debug_string())
|
log.info("cmd: add to playlist: " + music_wrapper.format_debug_string())
|
||||||
bot.send_msg(tr('file_added', item=music_wrapper.format_song_string()), text)
|
send_item_added_message(bot, music_wrapper, len(var.playlist) - 1, text)
|
||||||
return
|
return
|
||||||
elif len(matches) > 1:
|
elif len(matches) > 1:
|
||||||
song_shortlist = matches
|
song_shortlist = matches
|
||||||
@ -321,7 +333,7 @@ def cmd_play_url(bot, user, text, command, parameter):
|
|||||||
var.playlist.append(music_wrapper)
|
var.playlist.append(music_wrapper)
|
||||||
|
|
||||||
log.info("cmd: add to playlist: " + music_wrapper.format_debug_string())
|
log.info("cmd: add to playlist: " + music_wrapper.format_debug_string())
|
||||||
bot.send_msg(tr('file_added', item=music_wrapper.format_song_string()), text)
|
send_item_added_message(bot, music_wrapper, len(var.playlist) - 1, text)
|
||||||
if len(var.playlist) == 2:
|
if len(var.playlist) == 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!)
|
||||||
bot.async_download_next()
|
bot.async_download_next()
|
||||||
@ -371,7 +383,7 @@ def cmd_play_radio(bot, user, text, command, parameter):
|
|||||||
|
|
||||||
var.playlist.append(music_wrapper)
|
var.playlist.append(music_wrapper)
|
||||||
log.info("cmd: add to playlist: " + music_wrapper.format_debug_string())
|
log.info("cmd: add to playlist: " + music_wrapper.format_debug_string())
|
||||||
bot.send_msg(tr('file_added', item=music_wrapper.format_song_string()), text)
|
send_item_added_message(bot, music_wrapper, len(var.playlist) - 1, text)
|
||||||
else:
|
else:
|
||||||
bot.send_msg(tr('bad_url'), text)
|
bot.send_msg(tr('bad_url'), text)
|
||||||
|
|
||||||
@ -989,7 +1001,7 @@ def cmd_search_library(bot, user, text, command, parameter):
|
|||||||
music_wrapper = get_cached_wrapper(items[0], user)
|
music_wrapper = get_cached_wrapper(items[0], user)
|
||||||
var.playlist.append(music_wrapper)
|
var.playlist.append(music_wrapper)
|
||||||
log.info("cmd: add to playlist: " + music_wrapper.format_debug_string())
|
log.info("cmd: add to playlist: " + music_wrapper.format_debug_string())
|
||||||
bot.send_channel_msg(tr('file_added', item=music_wrapper.format_song_string()))
|
send_item_added_message(bot, music_wrapper, len(var.playlist) - 1, text)
|
||||||
else:
|
else:
|
||||||
for item in items:
|
for item in items:
|
||||||
count += 1
|
count += 1
|
||||||
@ -1065,7 +1077,7 @@ def cmd_shortlist(bot, user, text, command, parameter):
|
|||||||
music_wrapper = get_cached_wrapper_from_scrap(**kwargs)
|
music_wrapper = get_cached_wrapper_from_scrap(**kwargs)
|
||||||
var.playlist.append(music_wrapper)
|
var.playlist.append(music_wrapper)
|
||||||
log.info("cmd: add to playlist: " + music_wrapper.format_debug_string())
|
log.info("cmd: add to playlist: " + music_wrapper.format_debug_string())
|
||||||
bot.send_channel_msg(tr('file_added', item=music_wrapper.format_song_string()))
|
send_item_added_message(bot, music_wrapper, len(var.playlist) - 1, text)
|
||||||
return
|
return
|
||||||
|
|
||||||
bot.send_msg(tr('bad_parameter', command=command), text)
|
bot.send_msg(tr('bad_parameter', command=command), text)
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
"download_in_progress": "Download of <b>{item}</b> in progress...",
|
"download_in_progress": "Download of <b>{item}</b> in progress...",
|
||||||
"error_executing_command": "{command}: Command failed with error: {error}.",
|
"error_executing_command": "{command}: Command failed with error: {error}.",
|
||||||
"file": "File",
|
"file": "File",
|
||||||
"file_added": "Added {item}.",
|
"file_added": "Added {item}. ",
|
||||||
"file_deleted": "Deleted {item} from the library.",
|
"file_deleted": "Deleted {item} from the library.",
|
||||||
"file_item": "<b>{artist} - {title}</b> <i>added by</i> {user}",
|
"file_item": "<b>{artist} - {title}</b> <i>added by</i> {user}",
|
||||||
"file_missed": "Music file '{file}' missed! This item has been removed from the playlist.",
|
"file_missed": "Music file '{file}' missed! This item has been removed from the playlist.",
|
||||||
@ -32,7 +32,9 @@
|
|||||||
"multiple_file_deleted": "Multiple items deleted from the library:",
|
"multiple_file_deleted": "Multiple items deleted from the library:",
|
||||||
"multiple_file_found": "Found:",
|
"multiple_file_found": "Found:",
|
||||||
"multiple_matches": "File not found! Possible candidates:",
|
"multiple_matches": "File not found! Possible candidates:",
|
||||||
|
"last_song_on_the_queue": "Last one on the queue.",
|
||||||
"new_version_found": "<h2>Update Available!</h2> Version {new_version} of botamusique is available! <hr />\n<h3>Changelog</h3> {changelog} <hr /> Send <i>!update</i> to update!",
|
"new_version_found": "<h2>Update Available!</h2> Version {new_version} of botamusique is available! <hr />\n<h3>Changelog</h3> {changelog} <hr /> Send <i>!update</i> to update!",
|
||||||
|
"next_to_play": "Next song.",
|
||||||
"no_file": "File not found.",
|
"no_file": "File not found.",
|
||||||
"not_admin": "You are not an admin!",
|
"not_admin": "You are not an admin!",
|
||||||
"not_in_my_channel": "You're not in my channel!",
|
"not_in_my_channel": "You're not in my channel!",
|
||||||
@ -42,6 +44,7 @@
|
|||||||
"paused": "Music paused.",
|
"paused": "Music paused.",
|
||||||
"playlist_fetching_failed": "Unable to fetch the playlist!",
|
"playlist_fetching_failed": "Unable to fetch the playlist!",
|
||||||
"pm_not_allowed": "Private message aren't allowed.",
|
"pm_not_allowed": "Private message aren't allowed.",
|
||||||
|
"position_in_the_queue" : "Position: {position}",
|
||||||
"preconfigurated_radio": "Preconfigurated Radio available:",
|
"preconfigurated_radio": "Preconfigurated Radio available:",
|
||||||
"queue_contents": "Items on the playlist:",
|
"queue_contents": "Items on the playlist:",
|
||||||
"queue_empty": "Playlist is empty!",
|
"queue_empty": "Playlist is empty!",
|
||||||
|
@ -7,7 +7,7 @@ if TYPE_CHECKING:
|
|||||||
import database
|
import database
|
||||||
|
|
||||||
bot: 'mumbleBot.MumbleBot' = None
|
bot: 'mumbleBot.MumbleBot' = None
|
||||||
playlist: Type['media.playlist.BasePlaylist'] = None
|
playlist: 'media.playlist.BasePlaylist' = None
|
||||||
cache: 'media.cache.MusicCache' = None
|
cache: 'media.cache.MusicCache' = None
|
||||||
|
|
||||||
user = ""
|
user = ""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user