]> git.0d.be Git - botaradio.git/commitdiff
fix: message too long on some extreme cases
authorTerry Geng <gengyanda@gmail.com>
Tue, 3 Mar 2020 08:47:24 +0000 (16:47 +0800)
committerTerry Geng <gengyanda@gmail.com>
Tue, 3 Mar 2020 08:47:24 +0000 (16:47 +0800)
command.py
configuration.default.ini
media/playlist.py
mumbleBot.py

index ca56a72f4c6bb84300e3d91e6270355afd66532b..a073df52291d11eec9e0f832db4dfec4754d6ffa 100644 (file)
@@ -68,7 +68,7 @@ def send_multi_lines(bot, lines, text):
     for newline in lines:
         msg += 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)
             msg = ""
         msg += newline
@@ -668,6 +668,10 @@ def cmd_last(bot, user, text, command, parameter):
 def cmd_remove(bot, user, text, command, parameter):
     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
     if parameter and parameter.isdigit() and int(parameter) > 0 \
             and int(parameter) <= var.playlist.length():
index 52b80d7c7d3ee0a7ea824683d2e8c62987da5642..ef38a99e949780a0effd98d29142a6b9cdf39f27 100644 (file)
@@ -190,6 +190,7 @@ 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...
+cannot_change_when_download = Downloading songs, please wait until the download completes.
 removing_item = Removed entry {item} from playlist.
 user_ban = You are banned, not allowed to do that!
 url_ban = This url is banned!
index 5b6d17be3ce53ee4b047cae4753753c597e501bf..78cb870cfbc36bce212660ae9c041df9f05286b3 100644 (file)
@@ -24,7 +24,6 @@ def get_playlist_info(url, start_index=0, user=""):
 
                 playlist_title = info['title']
                 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
                     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
index b187cb5de2a7377922f40aefe78ce05a82beb77a..ea8a014ba70006f5875e8a22027f3b8a15a3c2ce 100644 (file)
@@ -407,6 +407,8 @@ class MumbleBot:
             # then no need to download
             return music
 
+        self.download_in_progress = True
+
         url = music['url']
 
         url_hash = hashlib.md5(url.encode()).hexdigest()
@@ -469,6 +471,7 @@ class MumbleBot:
         music = util.get_music_tag_info(music)
 
         var.playlist.update(music, index)
+        self.download_in_progress = False
         return music
 
     def async_download_next(self):