]> git.0d.be Git - botaradio.git/commitdiff
#19
authorazlux <github@azlux.fr>
Tue, 26 Jun 2018 23:09:23 +0000 (01:09 +0200)
committerazlux <github@azlux.fr>
Tue, 26 Jun 2018 23:09:23 +0000 (01:09 +0200)
ignore user not in the same channel  execpt the admin

configuration.default.ini
mumbleBot.py

index c680a9ca0074ccc931c8632072313f17ae0adc4b..47143b1059fc8ca27d45a3e6a094cc746a97e7ed 100644 (file)
@@ -19,6 +19,7 @@ ignored_folders = tmp
 ignored_files = Thumbs.db
 
 announce_current_music = True
+allow_other_channel_message = False
 
 [webinterface]
 enabled = False
@@ -63,6 +64,7 @@ multiple_matches = Track not found! Possible candidates:
 queue_contents = The next items in the queue are:
 queue_empty = No more music in the playlist!
 now_playing = Now playing %s<br />%s
+not_in_my_channel = You're not in my channel, command refused !
 
 help = Command available:
        <br />!file [path]
index 126cfaeb05a269a73a8035ea83d95fb3925f2609..b0ff112977962c2d66015183a8d9ff811b61e553 100644 (file)
@@ -129,7 +129,13 @@ class MumbleBot:
 
             logging.info(command + ' - ' + parameter + ' by ' + user)
 
-            if command == var.config.get('command', 'play_file') and parameter:
+            if command == var.config.get('command', 'joinme'):
+                self.mumble.users.myself.move_in(self.mumble.users[text.actor]['channel_id'])
+
+            elif not self.is_admin(user) and not var.config.getboolean('bot', 'allow_other_channel_message') and self.mumble.users[text.actor]['channel_id'] != self.mumble.users.myself['channel_id']:
+                self.mumble.users[text.actor].send_message(var.config.get('strings', 'not_in_my_channel'))
+
+            elif command == var.config.get('command', 'play_file') and parameter:
                 music_folder = var.config.get('bot', 'music_folder')
                 # sanitize "../" and so on
                 path = os.path.abspath(os.path.join(music_folder, parameter))
@@ -166,7 +172,7 @@ class MumbleBot:
                 self.stop()
 
             elif command == var.config.get('command', 'kill'):
-                if self.is_admin(text.actor):
+                if self.is_admin(user):
                     self.stop()
                     self.exit = True
                 else:
@@ -177,9 +183,6 @@ class MumbleBot:
                 if self.channel:
                     self.mumble.channels.find_by_name(self.channel).move_in()
 
-            elif command == var.config.get('command', 'joinme'):
-                self.mumble.users.myself.move_in(self.mumble.users[text.actor]['channel_id'])
-
             elif command == var.config.get('command', 'volume'):
                 if parameter is not None and parameter.isdigit() and 0 <= int(parameter) <= 100:
                     self.volume = float(float(parameter) / 100)
@@ -246,8 +249,8 @@ class MumbleBot:
                     msg = var.config.get('strings', 'queue_empty')
                 else:
                     msg = var.config.get('strings', 'queue_contents') + '<br />'
-                    for (type, path) in var.playlist:
-                        msg += '({}) {}<br />'.format(type, path)
+                    for (music_type, path) in var.playlist:
+                        msg += '({}) {}<br />'.format(music_type, path)
 
                 self.send_msg_channel(msg)
 
@@ -268,9 +271,9 @@ class MumbleBot:
         self.playing = True
 
     def is_admin(self, user):
-        username = self.mumble.users[user]['name']
         list_admin = var.config.get('bot', 'admin').split(';')
-        if username in list_admin:
+        print(list_admin)
+        if user in list_admin:
             return True
         else:
             return False