Ejemplo n.º 1
0
def cmd_url_ban_list(bot, user, text, command, parameter):
    if bot.is_admin(user):
        bot.mumble.users[text.actor].send_text_message(util.get_url_ban())
    else:
        bot.mumble.users[text.actor].send_text_message(
            constants.strings('not_admin'))
    return
Ejemplo n.º 2
0
def cmd_url_ban(bot, user, text, command, parameter):
    if bot.is_admin(user):
        if parameter:
            bot.mumble.users[text.actor].send_text_message(util.url_ban(bot.get_url_from_input(parameter)))
        else:
            bot.mumble.users[text.actor].send_text_message(util.get_url_ban())
    else:
        bot.mumble.users[text.actor].send_text_message(var.config.get('strings', 'not_admin'))
    return
Ejemplo n.º 3
0
    def message_received(self, text):

        message = text.message.strip()
        user = self.mumble.users[text.actor]['name']

        if var.config.getboolean('command', 'split_username_at_space'):
            # in can you use https://github.com/Natenom/mumblemoderator-module-collection/tree/master/os-suffixes , you want to split the username
            user = user.split()[0]

        if message[0] == var.config.get('command', 'command_symbol'):
            # remove the symbol from the message
            message = message[1:].split(' ', 1)

            # use the first word as a command, the others one as  parameters
            if len(message) > 0:
                command = message[0]
                parameter = ''
                if len(message) > 1:
                    parameter = message[1]

            else:
                return

            logging.info(command + ' - ' + parameter + ' by ' + user)

            if command == var.config.get('command', 'joinme'):
                self.mumble.users.myself.move_in(self.mumble.users[text.actor]['channel_id'], token=parameter)
                return

            # Anti stupid guy function
            if 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'))
                return

            if not self.is_admin(user) and not var.config.getboolean('bot', 'allow_private_message') and text.session:
                self.mumble.users[text.actor].send_message(var.config.get('strings', 'pm_not_allowed'))
                return

            ###
            # Admin command
            ###
            for i in var.db.items("user_ban"):
                if user.lower() == i[0]:
                    self.mumble.users[text.actor].send_message(var.config.get('strings', 'user_ban'))
                    return

            if command == var.config.get('command', 'user_ban'):
                if self.is_admin(user):
                    if parameter:
                        self.mumble.users[text.actor].send_message(util.user_ban(parameter))
                    else:
                        self.mumble.users[text.actor].send_message(util.get_user_ban())
                else:
                    self.mumble.users[text.actor].send_message(var.config.get('strings', 'not_admin'))
                return

            elif command == var.config.get('command', 'user_unban'):
                if self.is_admin(user):
                    if parameter:
                        self.mumble.users[text.actor].send_message(util.user_unban(parameter))
                else:
                    self.mumble.users[text.actor].send_message(var.config.get('strings', 'not_admin'))
                return

            elif command == var.config.get('command', 'url_ban'):
                if self.is_admin(user):
                    if parameter:
                        self.mumble.users[text.actor].send_message(util.url_ban(self.get_url_from_input(parameter)))
                    else:
                        self.mumble.users[text.actor].send_message(util.get_url_ban())
                else:
                    self.mumble.users[text.actor].send_message(var.config.get('strings', 'not_admin'))
                return

            elif command == var.config.get('command', 'url_unban'):
                if self.is_admin(user):
                    if parameter:
                        self.mumble.users[text.actor].send_message(util.url_unban(self.get_url_from_input(parameter)))
                else:
                    self.mumble.users[text.actor].send_message(var.config.get('strings', 'not_admin'))
                return

            if parameter:
                for i in var.db.items("url_ban"):
                    if self.get_url_from_input(parameter.lower()) == i[0]:
                        self.mumble.users[text.actor].send_message(var.config.get('strings', 'url_ban'))
                        return

            ###
            # everyday commands
            ###
            if 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))
                if path.startswith(music_folder):
                    if os.path.isfile(path):
                        filename = path.replace(music_folder, '')
                        music = {'type': 'file',
                                 'path': filename,
                                 'user': user}
                        var.playlist.append(music)
                    else:
                        # try to do a partial match
                        matches = [file for file in util.get_recursive_filelist_sorted(music_folder) if parameter.lower() in file.lower()]
                        if len(matches) == 0:
                            self.send_msg(var.config.get('strings', 'no_file'), text)
                        elif len(matches) == 1:
                            music = {'type': 'file',
                                     'path': matches[0],
                                     'user': user}
                            var.playlist.append(music)
                        else:
                            msg = var.config.get('strings', 'multiple_matches') + '<br />'
                            msg += '<br />'.join(matches)
                            self.send_msg(msg, text)
                else:
                    self.send_msg(var.config.get('strings', 'bad_file'), text)
                self.async_download_next()

            elif command == var.config.get('command', 'play_url') and parameter:
                music = {'type': 'url',
                         'url': self.get_url_from_input(parameter),  # grab the real URL
                         'user': user,
                         'ready': 'validation'}
                var.playlist.append(music)

                if media.url.get_url_info():
                    if var.playlist[-1]['duration'] > var.config.getint('bot', 'max_track_duration'):
                        var.playlist.pop()
                        self.send_msg(var.config.get('strings', 'too_long'), text)
                    else:
                        for i in var.db.options("url_ban"):
                            if var.playlist[-1]['url'] == i:
                                self.mumble.users[text.actor].send_message(var.config.get('strings', 'url_ban'))
                                var.playlist.pop()
                                return
                        var.playlist[-1]['ready'] = "no"
                        self.async_download_next()
                else:
                    var.playlist.pop()
                    self.send_msg(var.config.get('strings', 'unable_download'), text)

            elif command == var.config.get('command', 'play_playlist') and parameter:
                offset = 1  # if you want to start the playlist at a specific index
                try:
                    offset = int(parameter.split(" ")[-1])
                except ValueError:
                    pass
                if media.playlist.get_playlist_info(url=self.get_url_from_input(parameter), start_index=offset, user=user):
                    self.async_download_next()

            elif command == var.config.get('command', 'play_radio') and parameter:
                if var.config.has_option('radio', parameter):
                    parameter = var.config.get('radio', parameter)
                music = {'type': 'radio',
                         'url': self.get_url_from_input(parameter),
                         'user': user}
                var.playlist.append(music)
                self.async_download_next()

            elif command == var.config.get('command', 'help'):
                self.send_msg(var.config.get('strings', 'help'), text)

            elif command == var.config.get('command', 'stop'):
                self.stop()

            elif command == var.config.get('command', 'kill'):
                if self.is_admin(user):
                    self.stop()
                    self.exit = True
                else:
                    self.mumble.users[text.actor].send_message(var.config.get('strings', 'not_admin'))

            elif command == var.config.get('command', 'update'):
                if self.is_admin(user):
                    self.mumble.users[text.actor].send_message("Starting the update")
                    # Need to be improved
                    tp = sp.check_output([var.config.get('bot', 'pip3_path'), 'install', '--upgrade', 'youtube-dl']).decode()
                    msg = ""
                    if "Requirement already up-to-date" in tp:
                        msg += "Youtube-dl is up-to-date"
                    else:
                        msg += "Update done : " + tp.split('Successfully installed')[1]
                    if 'up-to-date' not in sp.check_output(['/usr/bin/env', 'git', 'pull']).decode():
                        # Need to change it with release tag
                        msg += "<br /> I'm up-to-date"
                    else:
                        msg += "<br /> I have available updates, need to do it manually"
                    self.mumble.users[text.actor].send_message(msg)
                else:
                    self.mumble.users[text.actor].send_message(var.config.get('strings', 'not_admin'))

            elif command == var.config.get('command', 'stop_and_getout'):
                self.stop()
                if self.channel:
                    self.mumble.channels.find_by_name(self.channel).move_in()

            elif command == var.config.get('command', 'volume'):
                # The volume is a percentage
                if parameter is not None and parameter.isdigit() and 0 <= int(parameter) <= 100:
                    self.volume = float(float(parameter) / 100)
                    self.send_msg(var.config.get('strings', 'change_volume') % (
                        int(self.volume * 100), self.mumble.users[text.actor]['name']), text)
                    var.db.set('bot', 'volume', str(self.volume))
                else:
                    self.send_msg(var.config.get('strings', 'current_volume') % int(self.volume * 100), text)

            elif command == var.config.get('command', 'current_music'):
                if len(var.playlist) > 0:
                    source = var.playlist[0]["type"]
                    if source == "radio":
                        reply = "[radio] {title} on {url} by {user}".format(
                            title=media.radio.get_radio_title(var.playlist[0]["url"]),
                            url=var.playlist[0]["title"],
                            user=var.playlist[0]["user"]
                        )
                    elif source == "url" and 'from_playlist' in var.playlist[0]:
                        reply = "[playlist] {title} (from the playlist <a href=\"{url}\">{playlist}</a> by {user}".format(
                            title=var.playlist[0]["title"],
                            url=var.playlist[0]["playlist_url"],
                            playlist=var.playlist[0]["playlist_title"],
                            user=var.playlist[0]["user"]
                        )
                    elif source == "url":
                        reply = "[url] {title} (<a href=\"{url}\">{url}</a>) by {user}".format(
                            title=var.playlist[0]["title"],
                            url=var.playlist[0]["url"],
                            user=var.playlist[0]["user"]
                        )
                    elif source == "file":
                        reply = "[file] {title} by {user}".format(
                            title=var.playlist[0]["title"],
                            user=var.playlist[0]["user"])
                    else:
                        reply = "ERROR"
                        logging.error(var.playlist)
                else:
                    reply = var.config.get('strings', 'not_playing')

                self.send_msg(reply, text)

            elif command == var.config.get('command', 'skip'):
                if parameter is not None and parameter.isdigit() and int(parameter) > 0:  # Allow to remove specific music into the queue with a number
                    if int(parameter) < len(var.playlist):
                        removed = var.playlist.pop(int(parameter))

                        # the Title isn't here if the music wasn't downloaded
                        self.send_msg(var.config.get('strings', 'removing_item') % (removed['title'] if 'title' in removed else removed['url']), text)
                    else:
                        self.send_msg(var.config.get('strings', 'no_possible'), text)
                elif self.next():  # Is no number send, just skip the current music
                    self.launch_music()
                    self.async_download_next()
                else:
                    self.send_msg(var.config.get('strings', 'queue_empty'), text)
                    self.stop()

            elif command == var.config.get('command', 'list'):
                folder_path = var.config.get('bot', 'music_folder')

                files = util.get_recursive_filelist_sorted(folder_path)
                if files:
                    self.send_msg('<br>'.join(files), text)
                else:
                    self.send_msg(var.config.get('strings', 'no_file'), text)

            elif command == var.config.get('command', 'queue'):
                if len(var.playlist) <= 1:
                    msg = var.config.get('strings', 'queue_empty')
                else:
                    msg = var.config.get('strings', 'queue_contents') + '<br />'
                    i = 1
                    for value in var.playlist[1:]:
                        msg += '[{}] ({}) {}<br />'.format(i, value['type'], value['title'] if 'title' in value else value['url'])
                        i += 1

                self.send_msg(msg, text)

            elif command == var.config.get('command', 'repeat'):
                var.playlist.append(var.playlist[0])

            else:
                self.mumble.users[text.actor].send_message(var.config.get('strings', 'bad_command'))
Ejemplo n.º 4
0
def cmd_url_ban_list(bot, user, text, command, parameter):
    bot.mumble.users[text.actor].send_text_message(util.get_url_ban())
Ejemplo n.º 5
0
    def message_received(self, text):
        message = text.message.strip()
        user = self.mumble.users[text.actor]['name']
        if var.config.getboolean('command', 'split_username_at_space'):
            user = user.split()[0]
        if message[0] == var.config.get('command', 'command_symbol'):
            message = message[1:].split(' ', 1)
            if len(message) > 0:
                command = message[0]
                parameter = ''
                if len(message) > 1:
                    parameter = message[1]

            else:
                return

            logging.info(command + ' - ' + parameter + ' by ' + user)

            if command == var.config.get('command', 'joinme'):
                self.mumble.users.myself.move_in(
                    self.mumble.users[text.actor]['channel_id'])
                return

            if 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'))
                return

            if not self.is_admin(user) and not var.config.getboolean(
                    'bot', 'allow_private_message') and text.session:
                self.mumble.users[text.actor].send_message(
                    var.config.get('strings', 'pm_not_allowed'))
                return

            for i in var.db.items("user_ban"):
                if user.lower() == i[0]:
                    self.mumble.users[text.actor].send_message(
                        var.config.get('strings', 'user_ban'))
                    return

            if command == var.config.get('command', 'user_ban'):
                if self.is_admin(user):
                    if parameter:
                        self.mumble.users[text.actor].send_message(
                            util.user_ban(parameter))
                    else:
                        self.mumble.users[text.actor].send_message(
                            util.get_user_ban())
                else:
                    self.mumble.users[text.actor].send_message(
                        var.config.get('strings', 'not_admin'))
                return

            elif command == var.config.get('command', 'user_unban'):
                if self.is_admin(user):
                    if parameter:
                        self.mumble.users[text.actor].send_message(
                            util.user_unban(parameter))
                else:
                    self.mumble.users[text.actor].send_message(
                        var.config.get('strings', 'not_admin'))
                return

            elif command == var.config.get('command', 'url_ban'):
                if self.is_admin(user):
                    if parameter:
                        self.mumble.users[text.actor].send_message(
                            util.url_ban(self.get_url_from_input(parameter)))
                    else:
                        self.mumble.users[text.actor].send_message(
                            util.get_url_ban())
                else:
                    self.mumble.users[text.actor].send_message(
                        var.config.get('strings', 'not_admin'))
                return

            elif command == var.config.get('command', 'url_unban'):
                if self.is_admin(user):
                    if parameter:
                        self.mumble.users[text.actor].send_message(
                            util.url_unban(self.get_url_from_input(parameter)))
                else:
                    self.mumble.users[text.actor].send_message(
                        var.config.get('strings', 'not_admin'))
                return

            if parameter:
                for i in var.db.items("url_ban"):
                    if self.get_url_from_input(parameter.lower()) == i[0]:
                        self.mumble.users[text.actor].send_message(
                            var.config.get('strings', 'url_ban'))
                        return

            if 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))
                if path.startswith(music_folder):
                    if os.path.isfile(path):
                        filename = path.replace(music_folder, '')
                        music = {
                            'type': 'file',
                            'path': filename,
                            'user': user
                        }
                        var.playlist.append(music)
                    else:
                        # try to do a partial match
                        matches = [
                            file for file in
                            util.get_recursive_filelist_sorted(music_folder)
                            if parameter.lower() in file.lower()
                        ]
                        if len(matches) == 0:
                            self.send_msg(var.config.get('strings', 'no_file'),
                                          text)
                        elif len(matches) == 1:
                            music = {
                                'type': 'file',
                                'path': matches[0],
                                'user': user
                            }
                            var.playlist.append(music)
                        else:
                            messages = var.config.get(
                                'strings', 'multiple_matches') + '<br />'
                            messages += '<br />'.join(matches)
                            self.send_msg(messages, text)
                else:
                    self.send_msg(var.config.get('strings', 'bad_file'), text)
                self.async_download_next()

            elif command in [
                    var.config.get('command', 'play_url'),
                    var.config.get('command', 'play_search')
            ] and parameter:
                if command == var.config.get('command', 'play_search'):
                    parameter = media.url.search_youtube_url(parameter)
                    if not parameter:
                        self.send_msg(
                            var.config.get('strings', 'unable_download'), text)
                        return

                music = {
                    'type': 'url',
                    'url': self.get_url_from_input(parameter),
                    'user': user,
                    'ready': 'validation'
                }
                var.playlist.append(music)

                if media.url.get_url_info():
                    if var.playlist[-1]['duration'] > var.config.getint(
                            'bot', 'max_track_duration'):
                        var.playlist.pop()
                        self.send_msg(var.config.get('strings', 'too_long'),
                                      text)
                    else:
                        for i in var.db.options("url_ban"):
                            print(i, ' -> ', {var.playlist[-1]["url"]})
                            if var.playlist[-1]['url'] == i:
                                self.mumble.users[text.actor].send_message(
                                    var.config.get('strings', 'url_ban'))
                                var.playlist.pop()
                                return
                        var.playlist[-1]['ready'] = "no"
                        self.async_download_next()
                else:
                    var.playlist.pop()
                    self.send_msg(var.config.get('strings', 'unable_download'),
                                  text)

            elif command == var.config.get('command',
                                           'play_playlist') and parameter:
                offset = 0
                try:
                    offset = int(parameter.split(" ")[-1])
                except ValueError:
                    pass
                if media.playlist.get_playlist_info(
                        url=self.get_url_from_input(parameter),
                        start_index=offset,
                        user=user):
                    self.async_download_next()

            elif command == var.config.get('command',
                                           'play_autoplay') and parameter:
                parameter = media.url.search_youtube_url(parameter)
                music = {
                    'type': 'url',
                    'url': self.get_url_from_input(parameter),
                    'user': user,
                    'ready': 'validation'
                }
                var.playlist.append(music)

                for i in range(var.config.getint('bot', 'max_track_playlist')):
                    if media.url.get_url_info():
                        if var.playlist[-1]['duration'] > var.config.getint(
                                'bot', 'max_track_duration'):
                            var.playlist.pop()
                            self.send_msg(
                                var.config.get('strings', 'too_long'), text)
                        else:
                            for i in var.db.options("url_ban"):
                                print(i, ' -> ', {var.playlist[-1]["url"]})
                                if var.playlist[-1]['url'] == i:
                                    self.mumble.users[text.actor].send_message(
                                        var.config.get('strings', 'url_ban'))
                                    var.playlist.pop()
                                    return
                            var.playlist[-1]['ready'] = "no"
                            self.async_download_next()
                            parameter = media.url.get_youtube_recommendation(
                                parameter)
                            music = {
                                'type': 'url',
                                'url': self.get_url_from_input(parameter),
                                'user': user,
                                'ready': 'validation'
                            }
                            var.playlist.append(music)
                    else:
                        var.playlist.pop()
                        self.send_msg(
                            var.config.get('strings', 'unable_download'), text)

            elif command == var.config.get('command',
                                           'play_radio') and parameter:
                if var.config.has_option('radio', parameter):
                    parameter = var.config.get('radio', parameter)
                music = {
                    'type': 'radio',
                    'url': self.get_url_from_input(parameter),
                    'user': user
                }
                var.playlist.append(music)
                self.async_download_next()

            elif command == var.config.get('command', 'help'):
                self.send_msg(var.config.get('strings', 'help'), text)

            elif command == var.config.get('command', 'stop'):
                self.stop()

            elif command == var.config.get('command', 'kill'):
                if self.is_admin(user):
                    self.stop()
                    self.exit = True
                else:
                    self.mumble.users[text.actor].send_message(
                        var.config.get('strings', 'not_admin'))

            elif command == var.config.get('command', 'update'):
                if self.is_admin(user):
                    self.mumble.users[text.actor].send_message(
                        "Starting the update")
                    tp = sp.check_output([
                        var.config.get('bot', 'pip3_path'), 'install',
                        '--upgrade', 'youtube-dl'
                    ]).decode()
                    messages = []
                    need_restart = False
                    if "Requirement already up-to-date" in tp:
                        messages.append("Youtube-dl is up-to-date")
                    else:
                        messages.append("Update done : " +
                                        tp.split('Successfully installed')[1])
                    if 'up to date' in sp.check_output(
                        ['/usr/bin/git', 'pull']).decode():
                        messages.append("I'm up-to-date")
                    else:
                        messages.append("Updated source code, restarting..")
                        need_restart = True
                    self.mumble.users[text.actor].send_message(
                        '<br>'.join(messages))
                    if need_restart:
                        sp.check_output([
                            var.config.get('bot', 'pip3_path'), 'install',
                            '-r', 'requirements.txt'
                        ]).decode()
                        os.execv(sys.executable, ['python'] + sys.argv)
                else:
                    self.mumble.users[text.actor].send_message(
                        var.config.get('strings', 'not_admin'))

            elif command == var.config.get('command', 'stop_and_getout'):
                self.stop()
                if self.channel:
                    self.mumble.channels.find_by_name(self.channel).move_in()

            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)
                    self.send_msg(
                        var.config.get('strings', 'change_volume') %
                        (int(self.volume * 100),
                         self.mumble.users[text.actor]['name']), text)
                    var.db.set('bot', 'volume', str(self.volume))
                else:
                    self.send_msg(
                        var.config.get('strings', 'current_volume') %
                        int(self.volume * 100), text)

            elif command == var.config.get('command', 'current_music'):
                if len(var.playlist) > 0:
                    source = var.playlist[0]["type"]
                    if source == "radio":
                        reply = "[radio] {title} on {url} by {user}".format(
                            title=media.radio.get_radio_title(
                                var.playlist[0]["url"]),
                            url=var.playlist[0]["title"],
                            user=var.playlist[0]["user"])
                    elif source == "url" and 'from_playlist' in var.playlist[0]:
                        reply = "[playlist] {title} (from the playlist <a href=\"{url}\">{playlist}</a> by {user}".format(
                            title=var.playlist[0]["title"],
                            url=var.playlist[0]["playlist_url"],
                            playlist=var.playlist[0]["playlist_title"],
                            user=var.playlist[0]["user"])
                    elif source == "url":
                        reply = "[url] {title} (<a href=\"{url}\">{url}</a>) by {user}".format(
                            title=var.playlist[0]["title"],
                            url=var.playlist[0]["url"],
                            user=var.playlist[0]["user"])
                    elif source == "file":
                        reply = "[file] {title} by {user}".format(
                            title=var.playlist[0]["title"],
                            user=var.playlist[0]["user"])
                    else:
                        reply = "ERROR"
                        logging.error(var.playlist)
                else:
                    reply = var.config.get('strings', 'not_playing')

                self.send_msg(reply, text)

            elif command == var.config.get('command', 'skip'):
                if parameter == '':
                    parameter = 0
                elif parameter.isdigit():
                    parameter = int(parameter)
                else:
                    self.send_msg(var.config.get('strings', 'no_possible'),
                                  text)
                    return

                if len(var.playlist) > 0:
                    removed = var.playlist.pop(parameter)
                    removed = removed.get('title', removed['url'])
                    self.send_msg(
                        var.config.get('strings', 'removing_item') % removed,
                        text)

                    if len(var.playlist) == 0:
                        self.stop()
                    else:
                        self.launch_music()
                        self.async_download_next()

                if len(var.playlist) == 0:
                    self.send_msg(var.config.get('strings', 'queue_empty'),
                                  text)

            elif command == var.config.get('command', 'list'):
                folder_path = var.config.get('bot', 'music_folder')

                files = util.get_recursive_filelist_sorted(folder_path)
                if files:
                    self.send_msg('<br>'.join(files), text)
                else:
                    self.send_msg(var.config.get('strings', 'no_file'), text)

            elif command == var.config.get('command', 'queue'):
                if len(var.playlist) <= 1:
                    messages = var.config.get('strings', 'queue_empty')
                else:
                    messages = var.config.get('strings',
                                              'queue_contents') + '<br />'
                    i = 1
                    for value in var.playlist[1:]:
                        messages += '[{}] ({}) {}<br />'.format(
                            i, value['type'], value['title']
                            if 'title' in value else value['url'])
                        i += 1

                self.send_msg(messages, text)

            elif command == var.config.get('command', 'repeat'):
                var.playlist.append(var.playlist[0])

            else:
                self.mumble.users[text.actor].send_message(
                    var.config.get('strings', 'bad_command'))
Ejemplo n.º 6
0
    def message_received(self, text):

        message = text.message.strip()
        user = self.mumble.users[text.actor]['name']

        if var.config.getboolean('command', 'split_username_at_space'):
            # in can you use https://github.com/Natenom/mumblemoderator-module-collection/tree/master/os-suffixes , you want to split the username
            user = user.split()[0]

        if message[0] == var.config.get('command', 'command_symbol'):
            # remove the symbol from the message
            message = message[1:].split(' ', 1)

            # use the first word as a command, the others one as  parameters
            if len(message) > 0:
                command = message[0]
                parameter = ''
                if len(message) > 1:
                    parameter = message[1]

            else:
                return

            logging.info(command + ' - ' + parameter + ' by ' + user)

            if command == var.config.get('command', 'joinme'):
                self.mumble.users.myself.move_in(
                    self.mumble.users[text.actor]['channel_id'],
                    token=parameter)
                return

            # Anti stupid guy function
            if 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_text_message(
                    var.config.get('strings', 'not_in_my_channel'))
                return

            if not self.is_admin(user) and not var.config.getboolean(
                    'bot', 'allow_private_message') and text.session:
                self.mumble.users[text.actor].send_text_message(
                    var.config.get('strings', 'pm_not_allowed'))
                return

            ###
            # Admin command
            ###
            for i in var.db.items("user_ban"):
                if user.lower() == i[0]:
                    self.mumble.users[text.actor].send_text_message(
                        var.config.get('strings', 'user_ban'))
                    return

            if command == var.config.get('command', 'user_ban'):
                if self.is_admin(user):
                    if parameter:
                        self.mumble.users[text.actor].send_text_message(
                            util.user_ban(parameter))
                    else:
                        self.mumble.users[text.actor].send_text_message(
                            util.get_user_ban())
                else:
                    self.mumble.users[text.actor].send_text_message(
                        var.config.get('strings', 'not_admin'))
                return

            elif command == var.config.get('command', 'user_unban'):
                if self.is_admin(user):
                    if parameter:
                        self.mumble.users[text.actor].send_text_message(
                            util.user_unban(parameter))
                else:
                    self.mumble.users[text.actor].send_text_message(
                        var.config.get('strings', 'not_admin'))
                return

            elif command == var.config.get('command', 'url_ban'):
                if self.is_admin(user):
                    if parameter:
                        self.mumble.users[text.actor].send_text_message(
                            util.url_ban(self.get_url_from_input(parameter)))
                    else:
                        self.mumble.users[text.actor].send_text_message(
                            util.get_url_ban())
                else:
                    self.mumble.users[text.actor].send_text_message(
                        var.config.get('strings', 'not_admin'))
                return

            elif command == var.config.get('command', 'url_unban'):
                if self.is_admin(user):
                    if parameter:
                        self.mumble.users[text.actor].send_text_message(
                            util.url_unban(self.get_url_from_input(parameter)))
                else:
                    self.mumble.users[text.actor].send_text_message(
                        var.config.get('strings', 'not_admin'))
                return

            if parameter:
                for i in var.db.items("url_ban"):
                    if self.get_url_from_input(parameter.lower()) == i[0]:
                        self.mumble.users[text.actor].send_text_message(
                            var.config.get('strings', 'url_ban'))
                        return

            ###
            # everyday commands
            ###
            if 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))
                if path.startswith(music_folder):
                    if os.path.isfile(path):
                        filename = path.replace(music_folder, '')
                        music = {
                            'type': 'file',
                            'path': filename,
                            'user': user
                        }
                        var.playlist.append(music)
                    else:
                        # try to do a partial match
                        matches = [
                            file for file in
                            util.get_recursive_filelist_sorted(music_folder)
                            if parameter.lower() in file.lower()
                        ]
                        if len(matches) == 0:
                            self.send_msg(var.config.get('strings', 'no_file'),
                                          text)
                        elif len(matches) == 1:
                            music = {
                                'type': 'file',
                                'path': matches[0],
                                'user': user
                            }
                            var.playlist.append(music)
                        else:
                            msg = var.config.get('strings',
                                                 'multiple_matches') + '<br />'
                            msg += '<br />'.join(matches)
                            self.send_msg(msg, text)
                else:
                    self.send_msg(var.config.get('strings', 'bad_file'), text)
                self.async_download_next()

            elif command == var.config.get('command',
                                           'play_url') and parameter:
                music = {
                    'type': 'url',
                    # grab the real URL
                    'url': self.get_url_from_input(parameter),
                    'user': user,
                    'ready': 'validation'
                }
                var.playlist.append(music)

                if media.url.get_url_info():
                    if var.playlist[-1]['duration'] > var.config.getint(
                            'bot', 'max_track_duration'):
                        var.playlist.pop()
                        self.send_msg(var.config.get('strings', 'too_long'),
                                      text)
                    else:
                        for i in var.db.options("url_ban"):
                            if var.playlist[-1]['url'] == i:
                                self.mumble.users[
                                    text.actor].send_text_message(
                                        var.config.get('strings', 'url_ban'))
                                var.playlist.pop()
                                return
                        var.playlist[-1]['ready'] = "no"
                        self.async_download_next()
                else:
                    var.playlist.pop()
                    self.send_msg(var.config.get('strings', 'unable_download'),
                                  text)

            elif command == var.config.get('command',
                                           'play_playlist') and parameter:
                offset = 1  # if you want to start the playlist at a specific index
                try:
                    offset = int(parameter.split(" ")[-1])
                except ValueError:
                    pass
                if media.playlist.get_playlist_info(
                        url=self.get_url_from_input(parameter),
                        start_index=offset,
                        user=user):
                    self.async_download_next()

            elif command == var.config.get('command', 'play_radio'):
                if not parameter:
                    all_radio = var.config.items('radio')
                    msg = var.config.get('strings',
                                         'preconfigurated_radio') + " :"
                    for i in all_radio:
                        comment = ""
                        if len(i[1].split(maxsplit=1)) == 2:
                            comment = " - " + i[1].split(maxsplit=1)[1]
                        msg += "<br />" + i[0] + comment
                    self.send_msg(msg, text)
                else:
                    if var.config.has_option('radio', parameter):
                        parameter = var.config.get('radio', parameter)
                        parameter = parameter.split()[0]
                    url = self.get_url_from_input(parameter)
                    if url:
                        music = {'type': 'radio', 'url': url, 'user': user}
                        var.playlist.append(music)
                        self.async_download_next()
                    else:
                        self.send_msg(var.config.get('strings', 'bad_url'))
            # query http://www.radio-browser.info API for a radio station
            elif command == var.config.get('command', 'rb_query'):
                logging.info('Querying radio stations')
                if not parameter:
                    logging.debug('rbquery without parameter')
                    msg += 'You have to add a query text to search for a matching radio stations.'
                    self.send_msg(msg, text)
                else:
                    logging.debug('Found query parameter: ' + parameter)
                    # self.send_msg('Searching for stations - this may take some seconds...', text)
                    rb_stations = radiobrowser.getstations_byname(parameter)
                    msg = var.config.get('strings', 'rbqueryresult') + " :"
                    msg += '\n<table><tr><th>!rbplay ID</th><th>Station Name</th><th>Genre</th><th>Codec/Bitrate</th><th>Country</th></tr>'
                    if not rb_stations:
                        logging.debug('No matches found for rbquery ' +
                                      parameter)
                        self.send_msg(
                            'Radio-Browser found no matches for ' + parameter,
                            text)
                    else:
                        for s in rb_stations:
                            stationid = s['id']
                            stationname = s['stationname']
                            country = s['country']
                            codec = s['codec']
                            bitrate = s['bitrate']
                            genre = s['genre']
                            # msg += f'<tr><td>{stationid}</td><td>{stationname}</td><td>{genre}</td><td>{codec}/{bitrate}</td><td>{country}</td></tr>'
                            msg += '<tr><td>%s</td><td>%s</td><td>%s</td><td>%s/%s</td><td>%s</td></tr>' % (
                                stationid, stationname, genre, codec, bitrate,
                                country)
                        msg += '</table>'
                        # Full message as html table
                        if len(msg) <= 5000:
                            self.send_msg(msg, text)
                        # Shorten message if message too long (stage I)
                        else:
                            logging.debug('Result too long stage I')
                            msg = var.config.get(
                                'strings',
                                'rbqueryresult') + " :" + ' (shortened L1)'
                            msg += '\n<table><tr><th>!rbplay ID</th><th>Station Name</th></tr>'
                            for s in rb_stations:
                                stationid = s['id']
                                stationname = s['stationname']
                                # msg += f'<tr><td>{stationid}</td><td>{stationname}</td>'
                                msg += '<tr><td>%s</td><td>%s</td>' % (
                                    stationid, stationname)
                            msg += '</table>'
                            if len(msg) <= 5000:
                                self.send_msg(msg, text)
                            # Shorten message if message too long (stage II)
                            else:
                                logging.debug('Result too long stage II')
                                msg = var.config.get(
                                    'strings',
                                    'rbqueryresult') + " :" + ' (shortened L2)'
                                msg += '!rbplay ID - Station Name'
                                for s in rb_stations:
                                    stationid = s['id']
                                    stationname = s['stationname'][:12]
                                    # msg += f'{stationid} - {stationname}'
                                    msg += '%s - %s' % (stationid, stationname)
                                if len(msg) <= 5000:
                                    self.send_msg(msg, text)
                                # Message still too long
                                else:
                                    self.send_msg(
                                        'Query result too long to post (> 5000 characters), please try another query.',
                                        text)
            # Play a secific station (by id) from http://www.radio-browser.info API
            elif command == var.config.get('command', 'rb_play'):
                logging.debug('Play a station by ID')
                if not parameter:
                    logging.debug('rbplay without parameter')
                    msg += 'Please enter a station ID from rbquery. Example: !rbplay 96748'
                    self.send_msg(msg, text)
                else:
                    logging.debug('Retreiving url for station ID ' + parameter)
                    rstation = radiobrowser.getstationname_byid(parameter)
                    stationname = rstation[0]['name']
                    country = rstation[0]['country']
                    codec = rstation[0]['codec']
                    bitrate = rstation[0]['bitrate']
                    genre = rstation[0]['tags']
                    homepage = rstation[0]['homepage']
                    msg = 'Radio station added to playlist:'
                    # msg += '<table><tr><th>ID</th><th>Station Name</th><th>Genre</th><th>Codec/Bitrate</th><th>Country</th><th>Homepage</th></tr>' + \
                    #       f'<tr><td>{parameter}</td><td>{stationname}</td><td>{genre}</td><td>{codec}/{bitrate}</td><td>{country}</td><td>{homepage}</td></tr></table>'
                    msg += '<table><tr><th>ID</th><th>Station Name</th><th>Genre</th><th>Codec/Bitrate</th><th>Country</th><th>Homepage</th></tr>' + \
                          '<tr><td>%s</td><td>%s</td><td>%s</td><td>%s/%s</td><td>%s</td><td>%s</td></tr></table>' \
                           % (parameter, stationname, genre, codec, bitrate, country, homepage)
                    logging.debug('Added station to playlist %s' % stationname)
                    self.send_msg(msg, text)
                    url = radiobrowser.geturl_byid(parameter)
                    if url != "-1":
                        logging.info('Found url: ' + url)
                        music = {'type': 'radio', 'url': url, 'user': user}
                        var.playlist.append(music)
                        self.async_download_next()
                    else:
                        logging.info('No playable url found.')
                        msg += "No playable url found for this station, please try another station."
                        self.send_msg(msg, text)

            elif command == var.config.get('command', 'help'):
                self.send_msg(var.config.get('strings', 'help'), text)
                if self.is_admin(user):
                    self.send_msg(var.config.get('strings', 'admin_help'),
                                  text)

            elif command == var.config.get('command', 'stop'):
                self.stop()

            elif command == var.config.get('command', 'kill'):
                if self.is_admin(user):
                    self.stop()
                    self.exit = True
                else:
                    self.mumble.users[text.actor].send_text_message(
                        var.config.get('strings', 'not_admin'))

            elif command == var.config.get('command', 'update'):
                if self.is_admin(user):
                    self.mumble.users[text.actor].send_text_message(
                        "Starting the update")
                    # Need to be improved
                    msg = util.update(version)
                    self.mumble.users[text.actor].send_text_message(msg)
                else:
                    self.mumble.users[text.actor].send_text_message(
                        var.config.get('strings', 'not_admin'))

            elif command == var.config.get('command', 'stop_and_getout'):
                self.stop()
                if self.channel:
                    self.mumble.channels.find_by_name(self.channel).move_in()

            elif command == var.config.get('command', 'volume'):
                # The volume is a percentage
                if parameter is not None and parameter.isdigit(
                ) and 0 <= int(parameter) <= 100:
                    self.volume = float(float(parameter) / 100)
                    self.send_msg(
                        var.config.get('strings', 'change_volume') %
                        (int(self.volume * 100),
                         self.mumble.users[text.actor]['name']), text)
                    var.db.set('bot', 'volume', str(self.volume))
                else:
                    self.send_msg(
                        var.config.get('strings', 'current_volume') %
                        int(self.volume * 100), text)

            elif command == var.config.get('command', 'current_music'):
                if len(var.playlist) > 0:
                    source = var.playlist[0]["type"]
                    if source == "radio":
                        reply = "[radio] {title} on {url} by {user}".format(
                            title=media.radio.get_radio_title(
                                var.playlist[0]["url"]),
                            url=var.playlist[0]["title"],
                            user=var.playlist[0]["user"])
                    elif source == "url" and 'from_playlist' in var.playlist[0]:
                        reply = "[playlist] {title} (from the playlist <a href=\"{url}\">{playlist}</a> by {user}".format(
                            title=var.playlist[0]["title"],
                            url=var.playlist[0]["playlist_url"],
                            playlist=var.playlist[0]["playlist_title"],
                            user=var.playlist[0]["user"])
                    elif source == "url":
                        reply = "[url] {title} (<a href=\"{url}\">{url}</a>) by {user}".format(
                            title=var.playlist[0]["title"],
                            url=var.playlist[0]["url"],
                            user=var.playlist[0]["user"])
                    elif source == "file":
                        reply = "[file] {title} by {user}".format(
                            title=var.playlist[0]["title"],
                            user=var.playlist[0]["user"])
                    else:
                        reply = "ERROR"
                        logging.error(var.playlist)
                else:
                    reply = var.config.get('strings', 'not_playing')

                self.send_msg(reply, text)

            elif command == var.config.get('command', 'skip'):
                # Allow to remove specific music into the queue with a number
                if parameter is not None and parameter.isdigit(
                ) and int(parameter) > 0:
                    if int(parameter) < len(var.playlist):
                        removed = var.playlist.pop(int(parameter))

                        # the Title isn't here if the music wasn't downloaded
                        self.send_msg(
                            var.config.get('strings', 'removing_item') %
                            (removed['title']
                             if 'title' in removed else removed['url']), text)
                    else:
                        self.send_msg(var.config.get('strings', 'no_possible'),
                                      text)
                elif self.next(
                ):  # Is no number send, just skip the current music
                    self.launch_music()
                    self.async_download_next()
                else:
                    self.send_msg(var.config.get('strings', 'queue_empty'),
                                  text)
                    self.stop()

            elif command == var.config.get('command', 'list'):
                folder_path = var.config.get('bot', 'music_folder')

                files = util.get_recursive_filelist_sorted(folder_path)
                if files:
                    self.send_msg('<br>'.join(files), text)
                else:
                    self.send_msg(var.config.get('strings', 'no_file'), text)

            elif command == var.config.get('command', 'queue'):
                if len(var.playlist) <= 1:
                    msg = var.config.get('strings', 'queue_empty')
                else:
                    msg = var.config.get('strings',
                                         'queue_contents') + '<br />'
                    i = 1
                    for value in var.playlist[1:]:
                        msg += '[{}] ({}) {}<br />'.format(
                            i, value['type'], value['title']
                            if 'title' in value else value['url'])
                        i += 1

                self.send_msg(msg, text)

            elif command == var.config.get('command', 'repeat'):
                var.playlist.append(var.playlist[0])

            else:
                self.mumble.users[text.actor].send_text_message(
                    var.config.get('strings', 'bad_command'))