]> git.0d.be Git - botaradio.git/commitdiff
fix: fix KeyError when removing item
authorTerry Geng <gengyanda@gmail.com>
Thu, 12 Mar 2020 01:04:14 +0000 (09:04 +0800)
committerTerry Geng <gengyanda@gmail.com>
Thu, 12 Mar 2020 01:04:14 +0000 (09:04 +0800)
command.py

index 725f0c8c29791525e165c01ad96bb10bf521422e..eb7f6f655ce39968c90280df36efebc4b89d1cc7 100644 (file)
@@ -701,7 +701,12 @@ def cmd_remove(bot, user, text, command, parameter):
         index = int(parameter) - 1
 
         if index == var.playlist.current_index:
-            removed = var.playlist.remove(index)
+            removed = var.playlist[index]
+            bot.send_msg(constants.strings('removing_item',
+                                           item=removed.format_short_string()), text)
+            log.info("cmd: delete from playlist: " + removed.format_debug_string())
+
+            var.playlist.remove(index)
 
             if index < len(var.playlist):
                 if not bot.is_pause:
@@ -714,12 +719,8 @@ def cmd_remove(bot, user, text, command, parameter):
                 if not bot.is_pause:
                     bot.interrupt()
         else:
-            removed = var.playlist.remove(index)
-
-        bot.send_msg(constants.strings('removing_item',
-                                       item=removed.format_short_string()), text)
+            var.playlist.remove(index)
 
-        log.info("cmd: delete from playlist: " + removed.format_debug_string())
     else:
         bot.send_msg(constants.strings('bad_parameter', command=command), text)