fix: message too long on some extreme cases
This commit is contained in:
parent
26345e456f
commit
499186c738
@ -68,7 +68,7 @@ def send_multi_lines(bot, lines, text):
|
|||||||
for newline in lines:
|
for newline in lines:
|
||||||
msg += br
|
msg += br
|
||||||
br = "<br>"
|
br = "<br>"
|
||||||
if len(msg) + len(newline) > 5000:
|
if (len(msg) + len(newline)) > (bot.mumble.get_max_message_length() - 4) != 0: # 4 == len("<br>")
|
||||||
bot.send_msg(msg, text)
|
bot.send_msg(msg, text)
|
||||||
msg = ""
|
msg = ""
|
||||||
msg += newline
|
msg += newline
|
||||||
@ -668,6 +668,10 @@ def cmd_last(bot, user, text, command, parameter):
|
|||||||
def cmd_remove(bot, user, text, command, parameter):
|
def cmd_remove(bot, user, text, command, parameter):
|
||||||
global log
|
global log
|
||||||
|
|
||||||
|
if bot.download_in_progress:
|
||||||
|
bot.send_msg(constants.strings("cannot_change_when_download"))
|
||||||
|
return
|
||||||
|
|
||||||
# Allow to remove specific music into the queue with a number
|
# Allow to remove specific music into the queue with a number
|
||||||
if parameter and parameter.isdigit() and int(parameter) > 0 \
|
if parameter and parameter.isdigit() and int(parameter) > 0 \
|
||||||
and int(parameter) <= var.playlist.length():
|
and int(parameter) <= var.playlist.length():
|
||||||
|
@ -190,6 +190,7 @@ not_in_my_channel = You're not in my channel, command refused!
|
|||||||
pm_not_allowed = Private message aren't allowed.
|
pm_not_allowed = Private message aren't allowed.
|
||||||
too_long = This music is too long, skip!
|
too_long = This music is too long, skip!
|
||||||
download_in_progress = Download of {item} in progress...
|
download_in_progress = Download of {item} in progress...
|
||||||
|
cannot_change_when_download = Downloading songs, please wait until the download completes.
|
||||||
removing_item = Removed entry {item} from playlist.
|
removing_item = Removed entry {item} from playlist.
|
||||||
user_ban = You are banned, not allowed to do that!
|
user_ban = You are banned, not allowed to do that!
|
||||||
url_ban = This url is banned!
|
url_ban = This url is banned!
|
||||||
|
@ -24,7 +24,6 @@ def get_playlist_info(url, start_index=0, user=""):
|
|||||||
|
|
||||||
playlist_title = info['title']
|
playlist_title = info['title']
|
||||||
for j in range(start_index, min(len(info['entries']), start_index + var.config.getint('bot', 'max_track_playlist'))):
|
for j in range(start_index, min(len(info['entries']), start_index + var.config.getint('bot', 'max_track_playlist'))):
|
||||||
print(info['entries'][j])
|
|
||||||
# Unknow String if No title into the json
|
# Unknow String if No title into the json
|
||||||
title = info['entries'][j]['title'] if 'title' in info['entries'][j] else "Unknown Title"
|
title = info['entries'][j]['title'] if 'title' in info['entries'][j] else "Unknown Title"
|
||||||
# Add youtube url if the url in the json isn't a full url
|
# Add youtube url if the url in the json isn't a full url
|
||||||
|
@ -407,6 +407,8 @@ class MumbleBot:
|
|||||||
# then no need to download
|
# then no need to download
|
||||||
return music
|
return music
|
||||||
|
|
||||||
|
self.download_in_progress = True
|
||||||
|
|
||||||
url = music['url']
|
url = music['url']
|
||||||
|
|
||||||
url_hash = hashlib.md5(url.encode()).hexdigest()
|
url_hash = hashlib.md5(url.encode()).hexdigest()
|
||||||
@ -469,6 +471,7 @@ class MumbleBot:
|
|||||||
music = util.get_music_tag_info(music)
|
music = util.get_music_tag_info(music)
|
||||||
|
|
||||||
var.playlist.update(music, index)
|
var.playlist.update(music, index)
|
||||||
|
self.download_in_progress = False
|
||||||
return music
|
return music
|
||||||
|
|
||||||
def async_download_next(self):
|
def async_download_next(self):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user