]> git.0d.be Git - botaradio.git/blobdiff - command.py
also accept files according to their extension
[botaradio.git] / command.py
index 725f0c8c29791525e165c01ad96bb10bf521422e..28c38d85c45e1ce5148dc3f693e2d6758ea5b4cf 100644 (file)
@@ -77,7 +77,8 @@ def send_multi_lines(bot, lines, text, linebreak="<br />"):
     for newline in lines:
         msg += br
         br = linebreak
-        if (len(msg) + len(newline)) > (bot.mumble.get_max_message_length() - 4) != 0:  # 4 == len("<br>")
+        if bot.mumble.get_max_message_length()\
+                    and (len(msg) + len(newline)) > (bot.mumble.get_max_message_length() - 4):  # 4 == len("<br>")
             bot.send_msg(msg, text)
             msg = ""
         msg += newline
@@ -134,7 +135,7 @@ def cmd_url_ban(bot, user, text, command, parameter):
             var.cache.free_and_delete(id)
             var.playlist.remove_by_id(id)
         else:
-            if var.playlist.current_item().type == 'url':
+            if var.playlist.current_item() and var.playlist.current_item().type == 'url':
                 item = var.playlist.current_item().item()
                 bot.mumble.users[text.actor].send_text_message(util.url_ban(util.get_url_from_input(item.url)))
                 var.cache.free_and_delete(item.id)
@@ -176,7 +177,10 @@ def cmd_play(bot, user, text, command, parameter):
                 # the one you want
                 var.playlist.point_to(int(parameter) - 1 - 1)
 
-                bot.interrupt()
+                if not bot.is_pause:
+                    bot.interrupt()
+                else:
+                    bot.is_pause = False
             else:
                 bot.send_msg(constants.strings('invalid_index', index=parameter), text)
 
@@ -595,6 +599,9 @@ def cmd_stop_and_getout(bot, user, text, command, parameter):
     global log
 
     bot.stop()
+    if var.playlist.mode == "one-shot":
+        var.playlist.clear()
+
     if bot.channel:
         bot.mumble.channels.find_by_name(bot.channel).move_in()
 
@@ -701,7 +708,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 +726,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)