def process(self, text):
        message = text.message.strip()
        message_parse = message[1:].split(' ', 1)
        command = message_parse[0]

        if command == "oblivion":
            if not privileges.plugin_privilege_checker(text, command,
                                                       self.plugin_name):
                return
            self.randomize()
            speciality = self.choose_spec()
            attributes = self.choose_attrs()
            skills = self.choose_skills()

            ret_text = f"<font color='{GS.cfg[C_PGUI_SETTINGS][P_TXT_IND_COL]}'>Specialty:</font><br>{speciality}<br>" \
                       f"<font color='{GS.cfg[C_PGUI_SETTINGS][P_TXT_IND_COL]}'>Attributes:</font><br>{attributes[0]}<br>{attributes[1]}<br>" \
                       f"<font color='{GS.cfg[C_PGUI_SETTINGS][P_TXT_IND_COL]}'>Skills:</font><br>{skills[0]}<br>{skills[1]}<br>{skills[2]}<br>{skills[3]}" \
                       f"<br>{skills[4]}<br>{skills[5]}<br>{skills[6]}"

            GS.gui_service.quick_gui(
                f"Oblivion character generated for: {GS.mumble_inst.users[text.actor]['name']}",
                text_type='header',
                box_align='left')

            GS.gui_service.quick_gui(
                f"<font color='{GS.cfg[C_PGUI_SETTINGS][P_TXT_HEAD_COL]}'>Oblivion Character Generated:</font><br>{ret_text}",
                text_type='header',
                box_align='left',
                user=GS.mumble_inst.users[text.actor]['name'])
            return

        if command == "oblivion_echo":
            if not privileges.plugin_privilege_checker(text, command,
                                                       self.plugin_name):
                return
            self.randomize()
            speciality = self.choose_spec()
            attributes = self.choose_attrs()
            skills = self.choose_skills()

            ret_text = f"<font color='{GS.cfg[C_PGUI_SETTINGS][P_TXT_IND_COL]}'>Specialty:</font><br>{speciality}<br>" \
                       f"<font color='{GS.cfg[C_PGUI_SETTINGS][P_TXT_IND_COL]}'>Attributes:</font><br>{attributes[0]}<br>{attributes[1]}<br>" \
                       f"<font color='{GS.cfg[C_PGUI_SETTINGS][P_TXT_IND_COL]}'>Skills:</font><br>{skills[0]}<br>{skills[1]}<br>{skills[2]}<br>{skills[3]}" \
                       f"<br>{skills[4]}<br>{skills[5]}<br>{skills[6]}"

            GS.gui_service.quick_gui(
                f"Oblivion character generated for: {GS.mumble_inst.users[text.actor]['name']}",
                text_type='header',
                box_align='left')

            GS.gui_service.quick_gui(
                f"<font color='{GS.cfg[C_PGUI_SETTINGS][P_TXT_HEAD_COL]}'>Oblivion Character Generated:</font><br>{ret_text}",
                text_type='header',
                box_align='left')
            return
Пример #2
0
    def process(self, text):
        message = text.message.strip()
        message_parse = message[1:].split(' ', 1)
        command = message_parse[0]

        if command == "lmgtfy":
            if not privileges.plugin_privilege_checker(text, command, self.plugin_name):
                return
            parameter = message_parse[1]
            results = self.lmgtfy(parameter)
            GS.gui_service.quick_gui(f"<a href='{results}'>{results}</a>", text_type='header', box_align='left')
Пример #3
0
    def process(self, text):
        # By default, the method creates some variables that separate the command from the rest of the parameters.
        message = text.message.strip()
        message_parse = message[1:].split(' ', 1)
        command = message_parse[0]

        # A basic example command, using the if-else structure.
        if command == "example_echo":
            # Always check the user privileges at the start of your command processing.
            if not privileges.plugin_privilege_checker(text, command, self.plugin_name):
                return

            parameter = message_parse[1]
            global_settings.gui_service.quick_gui(parameter, text_type='header', box_align='left', ignore_whisper=True)
            log(INFO, f"Echo:[{parameter}]", origin=L_GENERAL)
            return
Пример #4
0
def execute_command(com):
    plugin = None

    # Check to see if the entered command has a registered callback.
    for command_clbk in global_settings.cmd_callbacks:
        if command_clbk == com.command:
            plugin = global_settings.bot_plugins[global_settings.cmd_callbacks[command_clbk][0]]
            break
    if not plugin:
        return

    # Check to make sure that WaitFor metadata is present in the plugin metadata.
    plugin_thr_settings = loads(plugin.metadata.get(C_PLUGIN_SETTINGS, P_THREAD_WAIT))
    if plugin_thr_settings is None:
        log(WARNING, "This plugin is missing the 'ThreadWaitForCommands' Tag in [Plugin Settings] "
                     "section in its metadata file.")
        return
    use_single_thread = plugin.metadata.getboolean(C_PLUGIN_SETTINGS, P_THREAD_SINGLE, fallback=False)
    if use_single_thread is None:
        log(WARNING, "This plugin is missing the 'UseSingleThread' tag in [Plugin Settings] section "
                     "in its metadata file.")
        return

    # Check user privileges before attempting to execute any commands.
    if not privileges.plugin_privilege_checker(com.text, com.command, plugin.plugin_name):
        global_settings.gui_service.quick_gui(
            f"{com.text.actor['name']} does not have the user privileges to use <code>{get_command_token()}{com.command}</code>.",
            text_type='header', box_align='left')
        log(INFO, f"{com.text.actor['name']} tried to use the {get_command_token()}{com.command} command, but lacked the user privileges to do so.", origin=L_COMMAND)
        return

    # Execute commands in either a blocking thread, or in a separate thread.
    if use_single_thread:
        global_settings.mtd_callbacks[f'{com.command}_clbk'](plugin, com.text)
        return
    thr = threading.Thread(target=global_settings.mtd_callbacks[f'{com.command}_clbk'], args=(plugin, com.text,))
    thr.start()
    if com.command in plugin_thr_settings:
        thr.join()
Пример #5
0
    def process(self, text):
        message = text.message.strip()
        message_parse = message[1:].split(' ', 1)
        command = message_parse[0]

        if command == "updatedependency":
            if not privileges.plugin_privilege_checker(text, command,
                                                       self.plugin_name):
                return
            res = update_utils.update_available(message_parse[1])
            if res is True:
                updated_version = update_utils.check_and_update(
                    message_parse[1],
                    pip_cmd=self.metadata[C_PLUGIN_SET][P_PIP_CMD])
                if updated_version:
                    GS.gui_service.quick_gui(
                        f"Dependency: [{message_parse[1]}] has been updated to v{updated_version}",
                        text_type='header',
                        box_align='left',
                        ignore_whisper=True)
                    log(INFO,
                        f"Dependency: [{message_parse[1]}] has been updated to v{updated_version}",
                        origin=L_DEPENDENCIES)
                    return
                GS.gui_service.quick_gui(
                    f"Dependency: [{message_parse[1]}] could not be updated.",
                    text_type='header',
                    box_align='left',
                    ignore_whisper=True)
                log(INFO,
                    f"Dependency: [{message_parse[1]} could not be updated.",
                    origin=L_DEPENDENCIES)
            elif res is None:
                GS.gui_service.quick_gui(
                    f"The package: [{message_parse[1]}] is not a dependency of this software.",
                    text_type='header',
                    box_align='left',
                    ignore_whisper=True)
                return
            else:
                GS.gui_service.quick_gui(
                    f"There is no update available for: [{message_parse[1]}].",
                    text_type='header',
                    box_align='left',
                    ignore_whisper=True)

        elif command == "checkforupdates":
            if not privileges.plugin_privilege_checker(text, command,
                                                       self.plugin_name):
                return
            if len(message_parse) < 2:
                return
            res = update_utils.update_available(message_parse[1])
            if res is True:
                GS.gui_service.quick_gui(
                    f"There is a newer version of: [{message_parse[1]}] available.",
                    text_type='header',
                    box_align='left',
                    ignore_whisper=True)
            elif res is None:
                GS.gui_service.quick_gui(
                    f"The package: [{message_parse[1]}] is not a dependency of this software.",
                    text_type='header',
                    box_align='left',
                    ignore_whisper=True)
            else:
                GS.gui_service.quick_gui(
                    f"There is no update available for: [{message_parse[1]}].",
                    text_type='header',
                    box_align='left',
                    ignore_whisper=True)
    def process(self, text):
        message = text.message.strip()
        message_parse = message[1:].split(' ', 1)
        command = message_parse[0]

        if command == "price":
            if not privileges.plugin_privilege_checker(text, command, self.plugin_name):
                return
            if self.osrs_wiki is None:
                self.osrs_wiki = MediaWiki(url=self.metadata[C_PLUGIN_SETTINGS][P_WIKI_URL], user_agent=self.metadata[C_PLUGIN_SETTINGS][P_USER_AGENT])

            parameter = message_parse[1]
            search_criteria = self.manage_search_criteria(parameter)
            all_item_data = self.pull_json(search_criteria)
            if all_item_data is not None:
                item_data_formatted = "<br><font color='{}'>Item:</font> {}<br>Avg. Price: {:,} coins.".format(global_settings.cfg[C_PGUI_SETTINGS][P_TXT_HEAD_COL], all_item_data['name'].title(), all_item_data['overall_average'])
                item_data_formatted += "<br><font color='{}'>Buy Avg. Price:</font> {:,} coins.".format(global_settings.cfg[C_PGUI_SETTINGS][P_TXT_IND_COL], all_item_data['buy_average'])
                item_data_formatted += "<br><font color='{}'>Sell Avg. Price:</font> {:,} coins.".format(global_settings.cfg[C_PGUI_SETTINGS][P_TXT_IND_COL], all_item_data['sell_average'])

                global_settings.gui_service.quick_gui(item_data_formatted, text_type='header', box_align='left')
            else:
                global_settings.gui_service.quick_gui(f"Could not find '{search_criteria}' on the grand exchange.", text_type='header', box_align='left')

        elif command == "osrs":
            if not privileges.plugin_privilege_checker(text, command, self.plugin_name):
                return
            if self.osrs_wiki is None:
                self.osrs_wiki = MediaWiki(url=self.metadata[C_PLUGIN_SETTINGS][P_WIKI_URL], user_agent=self.metadata[C_PLUGIN_SETTINGS][P_USER_AGENT])

            parameter = message_parse[1]
            global_settings.gui_service.quick_gui(f"Searching the OSRS Wiki for: {parameter}", text_type='header', box_align='left')
            search_results = self.osrs_wiki.opensearch(parameter)
            formatted_results = self.get_choices(search_results)

            if formatted_results is None:
                global_settings.gui_service.quick_gui("OSRS Wiki Results:<br>No search results found.", text_type='header', box_align='left')
                return
            global_settings.gui_service.quick_gui(f"OSRS Wiki Results:<br>{formatted_results}\n", text_type='header', box_align='left')

        elif command == "quest":
            if not privileges.plugin_privilege_checker(text, command, self.plugin_name):
                return
            if self.osrs_wiki is None:
                self.osrs_wiki = MediaWiki(url=self.metadata[C_PLUGIN_SETTINGS][P_WIKI_URL], user_agent=self.metadata[C_PLUGIN_SETTINGS][P_USER_AGENT])

            parameter = message_parse[1]
            global_settings.gui_service.quick_gui(f"Searching the OSRS Wiki for: {parameter}", text_type='header', box_align='left')

            try:
                page = self.osrs_wiki.page(parameter)
            except exceptions.PageError:
                global_settings.gui_service.quick_gui("OSRS Wiki Results:<br>No search results found.", text_type='header', box_align='left')
                return

            if "Quests" not in page.categories and page is not None:
                global_settings.gui_service.quick_gui("OSRS Wiki Results:<br>No search results found.", text_type='header', box_align='left')
                return

            soup = BeautifulSoup(page.html, 'html.parser')
            tds = soup.find_all('td', class_="questdetails-info")
            final_text = f"<br><u><font color='{global_settings.cfg[C_PGUI_SETTINGS][P_TXT_IND_COL]}'>{page.title} Quest Summary</font></u><br><a href='{page.url}'>{page.url}</a>"
            for i, item in enumerate(tds):
                f_text = ""

                if i == 0:
                    f_text = "<br><font color='{global_settings.cfg[C_PGUI_SETTINGS][P_TXT_HEAD_COL]}'>Start Point:</font><br>"
                elif i == 1:
                    f_text = "<br><font color='{global_settings.cfg[C_PGUI_SETTINGS][P_TXT_HEAD_COL]}'>Difficulty:</font><br>"
                elif i == 2:
                    f_text = "<br><font color='{global_settings.cfg[C_PGUI_SETTINGS][P_TXT_HEAD_COL]}'>Description:</font><br>"
                elif i == 3:
                    f_text = "<br><font color='{global_settings.cfg[C_PGUI_SETTINGS][P_TXT_HEAD_COL]}'>Length:</font><br>"
                elif i == 4:
                    f_text = "<br><font color='{global_settings.cfg[C_PGUI_SETTINGS][P_TXT_HEAD_COL]}'>Requirements:</font><br>"
                elif i == 5:
                    f_text = "<br><font color='{global_settings.cfg[C_PGUI_SETTINGS][P_TXT_HEAD_COL]}'>Items Required:</font><br>"
                elif i == 6:
                    f_text = "<br><font color='{global_settings.cfg[C_PGUI_SETTINGS][P_TXT_HEAD_COL]}'>Enemies To Defeat:</font><br>"

                counter = 0
                if i == 4 or i == 6:
                    uls = item.find_all('ul')
                    if uls is not None:
                        for ul in uls:
                            lis = ul.find_all('li')
                            for li in lis:
                                f_text += f"<font color='{global_settings.cfg[C_PGUI_SETTINGS][P_TXT_IND_COL]}'>-- </font>{li.text}<br>"
                    else:
                        f_text += "UNAVAILABLE"
                elif i == 5:
                    uls = item.find_all('ul')
                    if uls is not None:
                        for ul in item.find_all('ul'):
                            lis = ul.find_all('li')
                            for li in lis:
                                f_text += f"<font color='{global_settings.cfg[C_PGUI_SETTINGS][P_TXT_IND_COL]}'>-- </font>{li.text}<br>"

                            if counter == 0:
                                f_text += f"<br><font color='{global_settings.cfg[C_PGUI_SETTINGS][P_TXT_HEAD_COL]}'>Recommended Items:</font><br>"
                            counter += 1
                    else:
                        f_text += "UNAVAILABLE"
                else:
                    f_text += tds[i].text

                final_text += f_text
            global_settings.gui_service.quick_gui(final_text, text_type='header', box_align='left')
Пример #7
0
    def process(self, text):
        message = text.message.strip()
        message_parse = message[1:].split(' ', 1)
        command = message_parse[0]

        if command == "getwhisper":
            if not privileges.plugin_privilege_checker(text, command,
                                                       self.plugin_name):
                return
            if runtime_helper.whisper_target is None:
                GS.gui_service.quick_gui(
                    "There is no whisper target set",
                    text_type='header',
                    box_align='left',
                    user=GS.mumble_inst.users[text.actor]['name'],
                    ignore_whisper=True)
                return
            if runtime_helper.whisper_target["type"] == 0:
                ch = GS.mumble_inst.channels[
                    runtime_helper.whisper_target['id']]['name']
                GS.gui_service.quick_gui(
                    f"Current whisper channel: {ch}",
                    text_type='header',
                    box_align='left',
                    user=GS.mumble_inst.users[text.actor]['name'],
                    ignore_whisper=True)
            elif runtime_helper.whisper_target["type"] == 1:
                us = ""
                for user in GS.mumble_inst.users:
                    if GS.mumble_inst.users[user][
                            'session'] == runtime_helper.whisper_target['id']:
                        us = GS.mumble_inst.users[user]['name']
                GS.gui_service.quick_gui(
                    f"Current whisper user: {us}",
                    text_type='header',
                    box_align='left',
                    user=GS.mumble_inst.users[text.actor]['name'],
                    ignore_whisper=True)
            elif runtime_helper.whisper_target["type"] == 2:
                users = ""
                counter = 0
                for i, user in enumerate(GS.mumble_inst.users):
                    if GS.mumble_inst.users[user][
                            'session'] in runtime_helper.whisper_target['id']:
                        users += f"<br>[{counter}] - {GS.mumble_inst.users[user]['name']}"
                        counter += 1
                GS.gui_service.quick_gui(
                    f"Current whisper users: {users}",
                    text_type='header',
                    box_align='left',
                    user=GS.mumble_inst.users[text.actor]['name'],
                    ignore_whisper=True)

        elif command == "setwhisperuser":
            if not privileges.plugin_privilege_checker(text, command,
                                                       self.plugin_name):
                return
            try:
                parameter = message_parse[1]
                if parameter == GS.cfg[C_CONNECTION_SETTINGS][P_USER_ID]:
                    GS.log_service.info(
                        "I can't set the whisper target to myself!")
                    GS.gui_service.quick_gui(
                        "I can't set the whisper target to myself!",
                        text_type='header',
                        box_align='left',
                        user=GS.mumble_inst.users[text.actor]['name'],
                        ignore_whisper=True)
                    return
                rutils.set_whisper_user(parameter)

                GS.gui_service.quick_gui(
                    f"Set whisper to User: {parameter}",
                    text_type='header',
                    box_align='left',
                    user=GS.mumble_inst.users[text.actor]['name'],
                    ignore_whisper=True)
                log(INFO,
                    f"Set whisper to User: {parameter}.",
                    origin=L_COMMAND)
            except IndexError:
                GS.gui_service.quick_gui(
                    "Invalid whisper command!<br>Command format: !setwhisperuser username",
                    text_type='header',
                    box_align='left',
                    user=GS.mumble_inst.users[text.actor]['name'],
                    ignore_whisper=True)
                return

        elif command == "removewhisperuser":
            if not privileges.plugin_privilege_checker(text, command,
                                                       self.plugin_name):
                return
            try:
                username = message_parse[1]
                if runtime_helper.whisper_target is not None:
                    if not isinstance(runtime_helper.whisper_target['id'],
                                      list):
                        GS.gui_service.quick_gui(
                            "<br>The current whisper mode is set to single user/channel."
                            "<br>You can only remove a user from a multi-user whisper mode."
                            "<br>Did you mean to use the 'clearwhisper' command?",
                            text_type='header',
                            box_align='left',
                            user=GS.mumble_inst.users[text.actor]['name'],
                            ignore_whisper=True)
                        return
                else:
                    return

                user_id = None
                for user in GS.mumble_inst.users:
                    if GS.mumble_inst.users[user]['name'] == username:
                        user_id = GS.mumble_inst.users[user]['session']
                if user_id is not None:
                    if user_id in runtime_helper.whisper_target['id']:
                        runtime_helper.whisper_target['id'].remove(user_id)
                    else:
                        GS.gui_service.quick_gui(
                            f"Could not find user: {username} in the whisper targets.",
                            text_type='header',
                            box_align='left',
                            user=GS.mumble_inst.users[text.actor]['name'],
                            ignore_whisper=True)
                        return
                else:
                    GS.gui_service.quick_gui(
                        f"Could not find user: {username} in the whisper targets.",
                        text_type='header',
                        box_align='left',
                        user=GS.mumble_inst.users[text.actor]['name'],
                        ignore_whisper=True)
                    return
                if len(runtime_helper.whisper_target['id']) < 1:
                    rutils.clear_whisper()
                else:
                    rutils.set_whisper_multi_user(
                        runtime_helper.whisper_target['id'])

                GS.gui_service.quick_gui(
                    f"Removed user: {username} from the whisper targets.",
                    text_type='header',
                    box_align='left',
                    user=GS.mumble_inst.users[text.actor]['name'],
                    ignore_whisper=True)
                log(INFO,
                    f"Removed user: {username} from the whisper targets.",
                    origin=L_COMMAND)
            except IndexError:
                GS.gui_service.quick_gui(
                    "Invalid whisper command!<br>Command format: !removewhisperuser username",
                    text_type='header',
                    box_align='left',
                    user=GS.mumble_inst.users[text.actor]['name'],
                    ignore_whisper=True)
                return

        elif command == "addwhisperuser":
            if not privileges.plugin_privilege_checker(text, command,
                                                       self.plugin_name):
                return
            try:
                username = message_parse[1]
                if username == GS.cfg[C_CONNECTION_SETTINGS][P_USER_ID]:
                    log(INFO,
                        "I can't add myself to the whisper targets!",
                        origin=L_COMMAND)
                    GS.gui_service.quick_gui(
                        "I can't add myself to the whisper targets!",
                        text_type='header',
                        box_align='left',
                        user=GS.mumble_inst.users[text.actor]['name'],
                        ignore_whisper=True)
                    return
                if runtime_helper.whisper_target is not None:
                    if not isinstance(runtime_helper.whisper_target['id'],
                                      list):
                        GS.gui_service.quick_gui(
                            "<br>The current whisper mode is set to single user.<br>Use the 'setwhisperusers' command for multi-user whispers.",
                            text_type='header',
                            box_align='left',
                            user=GS.mumble_inst.users[text.actor]['name'],
                            ignore_whisper=True)
                        return
                else:
                    return
                for user in GS.mumble_inst.users:
                    if GS.mumble_inst.users[user]['name'] == username:
                        if GS.mumble_inst.users[user][
                                'session'] in runtime_helper.whisper_target[
                                    'id']:
                            GS.gui_service.quick_gui(
                                "<br>This user is already one of the whisper targets!",
                                text_type='header',
                                box_align='left',
                                user=GS.mumble_inst.users[text.actor]['name'],
                                ignore_whisper=True)
                            return

                runtime_helper.whisper_target['id'].append(username)
                rutils.set_whisper_multi_user(
                    runtime_helper.whisper_target['id'])

                GS.gui_service.quick_gui(
                    f"Added new user: {username} to the whisper targets!",
                    text_type='header',
                    box_align='left',
                    user=GS.mumble_inst.users[text.actor]['name'],
                    ignore_whisper=True)
                log(INFO,
                    f"Added new user: {username} to the whisper targets!",
                    origin=L_COMMAND)
            except IndexError:
                GS.gui_service.quick_gui(
                    "Invalid whisper command!<br>Command format: !addwhisperuser username",
                    text_type='header',
                    box_align='left',
                    user=GS.mumble_inst.users[text.actor]['name'],
                    ignore_whisper=True)
                return

        elif command == "setwhisperusers":
            if not privileges.plugin_privilege_checker(text, command,
                                                       self.plugin_name):
                return
            try:
                parameter = message_parse[1]

                users_list = [
                    user.strip() for user in parameter.split(',')
                    if not user.strip() == GS.cfg[C_CONNECTION_SETTINGS]
                    [P_USER_ID]
                ]
                if len(users_list) < 2:
                    GS.gui_service.quick_gui(
                        "Use the 'setwhisperuser' command for a single user!",
                        text_type='header',
                        box_align='left',
                        user=GS.mumble_inst.users[text.actor]['name'],
                        ignore_whisper=True)
                    return

                rutils.set_whisper_multi_user(users_list)

                GS.gui_service.quick_gui(
                    f"Added whisper to multiple users!",
                    text_type='header',
                    box_align='left',
                    user=GS.mumble_inst.users[text.actor]['name'],
                    ignore_whisper=True)
                GS.log_service.info(f"Added whisper to multiple users!")
            except IndexError:
                GS.gui_service.quick_gui(
                    "Invalid whisper command!<br>Command format: !setwhisperusers username0,username1,...",
                    text_type='header',
                    box_align='left',
                    user=GS.mumble_inst.users[text.actor]['name'],
                    ignore_whisper=True)
                return

        elif command == "setwhisperme":
            if not privileges.plugin_privilege_checker(text, command,
                                                       self.plugin_name):
                return
            parameter = GS.mumble_inst.users[text.actor]['name']
            if parameter == GS.cfg[C_CONNECTION_SETTINGS][P_USER_ID]:
                log(INFO,
                    "I can't set the whisper target to myself!",
                    origin=L_COMMAND)
                return

            rutils.set_whisper_user(parameter)

            GS.gui_service.quick_gui(
                f"Set whisper to user: {parameter}",
                text_type='header',
                box_align='left',
                user=GS.mumble_inst.users[text.actor]['name'],
                ignore_whisper=True)
            log(INFO, f"Set whisper to user: {parameter}.", origin=L_COMMAND)

        elif command == "setwhisperchannel":
            if not privileges.plugin_privilege_checker(text, command,
                                                       self.plugin_name):
                return
            try:
                parameter = message_parse[1]
                rutils.set_whisper_channel(parameter)

                GS.gui_service.quick_gui(
                    f"Set whisper to channel: {parameter}",
                    text_type='header',
                    box_align='left',
                    user=GS.mumble_inst.users[text.actor]['name'],
                    ignore_whisper=True)
                log(INFO,
                    f"Set whisper to channel: {parameter}.",
                    origin=L_COMMAND)
            except IndexError:
                GS.gui_service.quick_gui(
                    "Command format: !setwhisperchannel channel_name",
                    text_type='header',
                    box_align='left',
                    user=GS.mumble_inst.users[text.actor]['name'],
                    ignore_whisper=True)
                return

        elif command == "clearwhisper":
            if not privileges.plugin_privilege_checker(text, command,
                                                       self.plugin_name):
                return
            rutils.clear_whisper()
            if runtime_helper.whisper_target is None:
                GS.gui_service.quick_gui(
                    f"Cleared current whisper",
                    text_type='header',
                    box_align='left',
                    user=GS.mumble_inst.users[text.actor]['name'],
                    ignore_whisper=True)
                return
            GS.gui_service.quick_gui(
                "Unable to remove current whisper!",
                text_type='header',
                box_align='left',
                user=GS.mumble_inst.users[text.actor]['name'],
                ignore_whisper=True)
Пример #8
0
def execute_command(com):
    plugin = None

    # Check to see if the entered command has a registered callback.
    for command_clbk in global_settings.cmd_callbacks:
        if command_clbk == com.command:
            plugin = global_settings.bot_plugins[
                global_settings.cmd_callbacks[command_clbk][0]]
            break
    if not plugin:
        return

    # Check to make sure the plugin is initialized and running.
    if not plugin.is_running:
        log(WARNING,
            f"{plugin.plugin_name} has not implemented the 'is_running' attribute. "
            "Commands from this plugin will be ignored!",
            print_mode=PrintMode.VERBOSE_PRINT.value)
        return

    # Check to make sure that WaitFor metadata is present in the plugin metadata.
    plugin_thr_settings = loads(
        plugin.metadata.get(C_PLUGIN_SETTINGS, P_THREAD_WAIT))
    if plugin_thr_settings is None:
        log(WARNING,
            "This plugin is missing the 'ThreadWaitForCommands' Tag in [Plugin Settings] "
            "section in its metadata file.",
            print_mode=PrintMode.VERBOSE_PRINT.value)
        return
    use_single_thread = plugin.metadata.getboolean(C_PLUGIN_SETTINGS,
                                                   P_THREAD_SINGLE,
                                                   fallback=False)
    if use_single_thread is None:
        log(WARNING,
            "This plugin is missing the 'UseSingleThread' tag in [Plugin Settings] section "
            "in its metadata file.",
            print_mode=PrintMode.VERBOSE_PRINT.value)
        return

    # Check user privileges before attempting to execute any commands.
    if privileges_check(global_settings.mumble_inst.users[
            com.text.actor]) > Privileges.BLACKLIST.value:
        if not plugin_privilege_checker(com.text, com.command,
                                        plugin.plugin_name):
            global_settings.gui_service.quick_gui(
                f"{com.text.actor['name']} does not have the user privileges to use <code>{get_command_token()}{com.command}</code>.",
                text_type='header',
                box_align='left')
            log(INFO,
                f"{com.text.actor['name']} tried to use the {get_command_token()}{com.command} command, but lacked the user privileges to do so.",
                origin=L_COMMAND,
                print_mode=PrintMode.VERBOSE_PRINT.value)
            return
    else:
        global_settings.gui_service.quick_gui(
            f"Blacklisted user [{com.text.actor['name']}] does not have the user "
            f"privileges to use this command: [{com.command}]",
            text_type='header',
            box_align='left')
        log(INFO,
            f"{com.text.actor['name']} tried to use the {get_command_token()}{com.command} command, but is currently blacklisted.",
            origin=L_COMMAND,
            print_mode=PrintMode.VERBOSE_PRINT.value)
        return

    # Execute commands in either a blocking thread, or in a separate thread.
    if use_single_thread:
        global_settings.mtd_callbacks[f'{com.command}_clbk'](plugin, com.text)
        return
    thr = threading.Thread(
        target=global_settings.mtd_callbacks[f'{com.command}_clbk'],
        args=(
            plugin,
            com.text,
        ))
    thr.start()
    if com.command in plugin_thr_settings:
        thr.join()
Пример #9
0
    def process(self, text):
        message = text.message.strip()
        message_parse = message[1:].split(' ', 1)
        command = message_parse[0]

        if command == "ttsstop":
            if not privileges.plugin_privilege_checker(text, command,
                                                       self.plugin_name):
                return
            if tts_settings.is_playing and GS.audio_inst is not None:
                if not GS.audio_dni[0]:
                    GS.audio_dni = (
                        True, self.metadata[C_PLUGIN_INFO][P_PLUGIN_NAME])
                else:
                    if GS.audio_dni[1] != self.metadata[C_PLUGIN_INFO][
                            P_PLUGIN_NAME]:
                        rprint(
                            f'An audio plugin is using the audio thread with no interruption mode enabled. [{GS.audio_dni[1]}]'
                        )
                        GS.gui_service.quick_gui(
                            "An audio plugin is using the audio thread with no interruption mode enabled.",
                            text_type='header',
                            box_align='left')
                        return
                ttsu.stop_audio()
                GS.gui_service.quick_gui(
                    "Stopping text to speech audio thread...",
                    text_type='header',
                    box_align='left')
                return

        elif command == "ttsv":
            if not privileges.plugin_privilege_checker(text, command,
                                                       self.plugin_name):
                return
            try:
                vol = float(message[1:].split(' ', 1)[1])
            except IndexError:
                GS.gui_service.quick_gui(
                    f"Current text to speech volume: {tts_settings.volume}",
                    text_type='header',
                    box_align='left')
                return
            if vol > 1:
                GS.gui_service.quick_gui(
                    "Invalid text to speech volume Input: [0-1]",
                    text_type='header',
                    box_align='left')
                return
            if vol < 0:
                GS.gui_service.quick_gui(
                    "Invalid text to speech volume Input: [0-1]",
                    text_type='header',
                    box_align='left')
                return
            tts_settings.volume = vol
            GS.gui_service.quick_gui(
                f"Set text to speech volume to {tts_settings.volume}",
                text_type='header',
                box_align='left')

        elif command == "ttslist":
            if not privileges.plugin_privilege_checker(text, command,
                                                       self.plugin_name):
                return
            internal_list = []
            gather_list = ttsu.prepare_tts_list()
            for i, item in enumerate(gather_list):
                internal_list.append(
                    f"<br><font color='{GS.cfg[C_PGUI_SETTINGS][P_TXT_IND_COL]}'>[{i}]</font> - [{item}]"
                )
            cur_text = f"<font color='{GS.cfg[C_PGUI_SETTINGS][P_TXT_HEAD_COL]}'>Local TTS Files:</font>"
            if len(internal_list) == 0:
                cur_text += "<br>There are no local text to speech files available."
                GS.gui_service.quick_gui(
                    cur_text,
                    text_type='header',
                    box_align='left',
                    user=GS.mumble_inst.users[text.actor]['name'])
                GS.log_service.info(
                    "Displayed a list of all local text to speech files.")
                return
            for i, item in enumerate(internal_list):
                cur_text += item
                if i % 50 == 0 and i != 0:
                    GS.gui_service.quick_gui(
                        cur_text,
                        text_type='header',
                        box_align='left',
                        text_align='left',
                        user=GS.mumble_inst.users[text.actor]['name'])
                    cur_text = ""
            if cur_text != "":
                GS.gui_service.quick_gui(
                    cur_text,
                    text_type='header',
                    box_align='left',
                    text_align='left',
                    user=GS.mumble_inst.users[text.actor]['name'])
            log(INFO,
                "Displayed a list of all local text to speech files.",
                origin=L_COMMAND)

        elif command == "ttslist_echo":
            if not privileges.plugin_privilege_checker(text, command,
                                                       self.plugin_name):
                return
            internal_list = []
            gather_list = ttsu.prepare_tts_list()

            for i, item in enumerate(gather_list):
                internal_list.append(
                    f"<br><font color='{GS.cfg[C_PGUI_SETTINGS][P_TXT_IND_COL]}'>[{i}]</font> - [{item}]"
                )
            cur_text = f"<font color='{GS.cfg[C_PGUI_SETTINGS][P_TXT_HEAD_COL]}'>Local TTS Files:</font>"
            if len(internal_list) == 0:
                cur_text += "<br>There are no local text to speech files available."
                GS.gui_service.quick_gui(cur_text,
                                         text_type='header',
                                         box_align='left')
                log(INFO,
                    "Displayed a list of all local text to speech files.",
                    origin=L_COMMAND)
                return
            for i, item in enumerate(internal_list):
                cur_text += item
                if i % 50 == 0 and i != 0:
                    GS.gui_service.quick_gui(cur_text,
                                             text_type='header',
                                             box_align='left',
                                             text_align='left')
                    cur_text = ""
            if cur_text != "":
                GS.gui_service.quick_gui(cur_text,
                                         text_type='header',
                                         box_align='left',
                                         text_align='left')
            log(INFO,
                "Displayed a list of all text to speech board files.",
                origin=L_COMMAND)

        elif command == "ttsvoices":
            if not privileges.plugin_privilege_checker(text, command,
                                                       self.plugin_name):
                return
            if len(tts_settings.voice_list) == 0:
                cur_text = f"<font color='{GS.cfg[C_PGUI_SETTINGS][P_TXT_HEAD_COL]}'>Available Voices:</font> None"
                GS.gui_service.quick_gui(cur_text,
                                         text_type='header',
                                         box_align='left')
                log(INFO,
                    "Displayed a list of all available text to speech voices.",
                    origin=L_COMMAND)
                return
            cur_text = f"<font color='{GS.cfg[C_PGUI_SETTINGS][P_TXT_HEAD_COL]}'>Available Voices:</font>"
            for i, voice_name in enumerate(tts_settings.voice_list):
                cur_text += f"[{i}] - {voice_name}<br>"
            GS.gui_service.quick_gui(cur_text,
                                     text_type='header',
                                     box_align='left')
            log(INFO,
                "Displayed a list of all available text to speech voices.",
                origin=L_COMMAND)

        elif command == "ttsdownload":
            from JJMumbleBot.plugins.extensions.text_to_speech.resources.strings import P_VLC_DIR

            if not privileges.plugin_privilege_checker(text, command,
                                                       self.plugin_name):
                return
            all_messages = message[1:].split(' ', 3)
            if ttsu.download_clip(all_messages[1].strip(),
                                  all_messages[2].strip(),
                                  all_messages[3].strip()):
                GS.gui_service.quick_gui(
                    f"Downloaded text to speech clip as : {all_messages[1].strip()}.oga",
                    text_type='header',
                    box_align='left')
                return

        elif command == "ttsdelete":
            if not privileges.plugin_privilege_checker(text, command,
                                                       self.plugin_name):
                return
            all_messages = message[1:].split()
            if len(all_messages) == 2:
                if ".oga" in all_messages[1].strip():
                    dir_utils.remove_file(
                        all_messages[1].strip(),
                        f"{dir_utils.get_perm_med_dir()}/text_to_speech/")
                    GS.gui_service.quick_gui(
                        f"Deleted text to speech clip : {all_messages[1].strip()}",
                        text_type='header',
                        box_align='left')
                    return
                return

        elif command == "ttsplay":
            if not privileges.plugin_privilege_checker(text, command,
                                                       self.plugin_name):
                return
            if not GS.audio_dni[0]:
                GS.audio_dni = (True,
                                self.metadata[C_PLUGIN_INFO][P_PLUGIN_NAME])
            else:
                if GS.audio_dni[1] != self.metadata[C_PLUGIN_INFO][
                        P_PLUGIN_NAME]:
                    rprint(
                        f'An audio plugin is using the audio thread with no interruption mode enabled. [{GS.audio_dni[1]}]'
                    )
                    GS.gui_service.quick_gui(
                        "An audio plugin is using the audio thread with no interruption mode enabled.",
                        text_type='header',
                        box_align='left')
                    return
            parameter = message_parse[1].strip()
            if not os.path.isfile(
                    f"{dir_utils.get_perm_med_dir()}/text_to_speech/{parameter}.oga"
            ):
                GS.gui_service.quick_gui(
                    "The text to speech clip does not exist.",
                    text_type='header',
                    box_align='left')
                return False
            tts_settings.current_track = parameter
            ttsu.play_audio()

        elif command == "ttsplayquiet":
            if not privileges.plugin_privilege_checker(text, command,
                                                       self.plugin_name):
                return
            if not GS.audio_dni[0]:
                GS.audio_dni = (True,
                                self.metadata[C_PLUGIN_INFO][P_PLUGIN_NAME])
            else:
                if GS.audio_dni[1] != self.metadata[C_PLUGIN_INFO][
                        P_PLUGIN_NAME]:
                    return
            parameter = message_parse[1].strip()
            if not os.path.isfile(
                    f"{dir_utils.get_perm_med_dir()}/text_to_speech/{parameter}.oga"
            ):
                return False
            tts_settings.current_track = parameter
            ttsu.play_audio()

        elif command == "tts":
            if not privileges.plugin_privilege_checker(text, command,
                                                       self.plugin_name):
                return
            if not GS.audio_dni[0]:
                GS.audio_dni = (True,
                                self.metadata[C_PLUGIN_INFO][P_PLUGIN_NAME])
            else:
                if GS.audio_dni[1] != self.metadata[C_PLUGIN_INFO][
                        P_PLUGIN_NAME]:
                    rprint(
                        f'An audio plugin is using the audio thread with no interruption mode enabled. [{GS.audio_dni[1]}]'
                    )
                    GS.gui_service.quick_gui(
                        "An audio plugin is using the audio thread with no interruption mode enabled.",
                        text_type='header',
                        box_align='left')
                    return
            all_messages = message[1:].split(' ', 2)
            if all_messages[1].strip() in tts_settings.voice_list:
                all_messages = message[1:].split(' ', 2)
            else:
                all_messages = message[1:].split(' ', 1)

            if len(all_messages) == 2:
                if len(all_messages[1]) > int(
                        self.metadata[C_PLUGIN_SETTINGS][P_TTS_MSG_CHR_LIM]):
                    GS.gui_service.quick_gui(
                        f"The text to speech message exceeded the character limit:"
                        f" [{self.metadata[C_PLUGIN_SETTINGS][P_TTS_MSG_CHR_LIM]}].",
                        text_type='header',
                        box_align='left',
                        user=GS.mumble_inst.users[text.actor]['name'])
                    return
                if ttsu.download_clip(
                        "_temp",
                        self.metadata[C_PLUGIN_SETTINGS][P_TTS_DEF_VOICE],
                        all_messages[1].strip(),
                        directory=f'{dir_utils.get_temp_med_dir()}'):
                    tts_settings.current_track = "_temp"
                    ttsu.play_audio(mode=0)
                    return
            elif len(all_messages) == 3:
                if len(all_messages[1]) > int(
                        self.metadata[C_PLUGIN_SETTINGS][P_TTS_MSG_CHR_LIM]):
                    GS.gui_service.quick_gui(
                        f"The text to speech message exceeded the character limit:"
                        f" [{self.metadata[C_PLUGIN_SETTINGS][P_TTS_MSG_CHR_LIM]}].",
                        text_type='header',
                        box_align='left',
                        user=GS.mumble_inst.users[text.actor]['name'])
                    return
                if ttsu.download_clip(
                        "_temp",
                        all_messages[1].strip(),
                        all_messages[2].strip(),
                        directory=f'{dir_utils.get_temp_med_dir()}'):
                    tts_settings.current_track = "_temp"
                    ttsu.play_audio(mode=0)
                    return
            GS.gui_service.quick_gui(
                f"Incorrect Format:<br>!tts 'voice_name' 'message'<br>OR<br>!tts 'message'",
                text_type='header',
                box_align='left',
                user=GS.mumble_inst.users[text.actor]['name'])
Пример #10
0
    def process(self, text):
        message = text.message.strip()
        message_parse = message[1:].split(' ', 1)
        command = message_parse[0]

        if command == "sleep":
            if not privileges.plugin_privilege_checker(text, command,
                                                       self.plugin_name):
                return
            sleep_time = float(text.message[1:].split(' ', 1)[1].strip())
            RS.tick_rate = sleep_time
            sleep(sleep_time)
            RS.tick_rate = float(GS.cfg[C_MAIN_SETTINGS][P_CMD_TICK_RATE])

        elif command == "version":
            if not privileges.plugin_privilege_checker(text, command,
                                                       self.plugin_name):
                return
            GS.gui_service.quick_gui(
                f"{rutils.get_bot_name()} is on version {rutils.get_version()}",
                text_type='header',
                box_align='left')

        elif command == "about":
            if not privileges.plugin_privilege_checker(text, command,
                                                       self.plugin_name):
                return
            GS.gui_service.quick_gui(
                f"{rutils.get_about()}<br>{rutils.get_bot_name()} is on version {rutils.get_version()}",
                text_type='header',
                box_align='left')

        elif command == "uptime":
            if not privileges.plugin_privilege_checker(text, command,
                                                       self.plugin_name):
                return
            GS.gui_service.quick_gui(
                rutils.check_up_time(),
                text_type='header',
                box_align='left',
                ignore_whisper=True,
                user=GS.mumble_inst.users[text.actor]['name'])

        elif command == "exit":
            if not privileges.plugin_privilege_checker(text, command,
                                                       self.plugin_name):
                return
            dprint("Stopping all threads...")
            rutils.exit_bot()
            log(INFO, "JJ Mumble Bot is being shut down.")
            log(INFO, "######################################")

        elif command == "reboot":
            import os
            import sys
            if not privileges.plugin_privilege_checker(text, command,
                                                       self.plugin_name):
                return
            rutils.exit_bot()
            log(INFO, "JJ Mumble Bot is being rebooted.", origin=L_STARTUP)
            os.execv(sys.executable, ['python3'] + sys.argv)  # nosec

        elif command == "safereboot":
            import os
            import sys
            if not privileges.plugin_privilege_checker(text, command,
                                                       self.plugin_name):
                return
            rutils.exit_bot()
            log(INFO,
                "JJ Mumble Bot is being rebooted in safe mode.",
                origin=L_STARTUP)
            os.execv(sys.executable,
                     ['python3'] + sys.argv + ['-safe'])  # nosec

        elif command == "refresh":
            if not privileges.plugin_privilege_checker(text, command,
                                                       self.plugin_name):
                return
            rutils.refresh_plugins()

        elif command == "help":
            if not privileges.plugin_privilege_checker(text, command,
                                                       self.plugin_name):
                return
            message = text.message.strip()
            message_parse = message[1:].split(' ', 2)
            if len(message_parse) < 2:
                return
            plugin_name = message_parse[1]

            plugin_help_data = PluginUtilityService.process_help(
                db_cursor=get_memory_db().cursor(), plugin_name=plugin_name)
            if plugin_help_data:
                GS.gui_service.open_box()
                all_help_lines = [
                    msg.strip() for msg in plugin_help_data.split('<br>')
                ]
                content = GS.gui_service.make_content(
                    f'<font color="red">##### </font>'
                    f'<b>{rutils.get_bot_name()} Help Commands - [{plugin_name}]</b>'
                    f'<font color="red"> #####</font>')
                GS.gui_service.append_row(content)
                content = GS.gui_service.make_content(
                    f'Plugin Version: {self.metadata[C_PLUGIN_INFO][P_PLUGIN_VERS]}<br>',
                    text_color='cyan')
                GS.gui_service.append_row(content)
                for i, item in enumerate(all_help_lines):
                    item_parts = item.split(':', 1)
                    if len(item_parts) > 1:
                        content = GS.gui_service.make_content(
                            f'<font color="yellow">{item_parts[0]}</font>:{item_parts[1]}',
                            text_type='header',
                            text_align="left")
                    else:
                        content = GS.gui_service.make_content(
                            f'{item}', text_type='header', text_align="left")
                    GS.gui_service.append_row(content)
                GS.gui_service.close_box()
                GS.gui_service.display_box(channel=rutils.get_my_channel())
                dprint(
                    f"Displayed help screen for {plugin_name} in the channel.")
                log(INFO,
                    f"Displayed help screen for {plugin_name} in the channel.",
                    origin=L_COMMAND)

        elif command == "alias":
            if not privileges.plugin_privilege_checker(text, command,
                                                       self.plugin_name):
                return
            message = text.message.strip()
            message_parse = message[1:].split(' ', 2)
            if len(message_parse) < 2:
                return
            alias_name = message_parse[1]

            if aliases.add_to_aliases(alias_name, message_parse[2]):
                GS.gui_service.quick_gui(
                    f"Registered new alias: [{alias_name}] - [{message_parse[2]}]",
                    text_type='header',
                    box_align='left',
                    ignore_whisper=True,
                    user=GS.mumble_inst.users[text.actor]['name'])
            elif aliases.set_alias(alias_name, message_parse[2]):
                GS.gui_service.quick_gui(
                    f"Registered alias: [{alias_name}] - [{message_parse[2]}]",
                    text_type='header',
                    box_align='left',
                    ignore_whisper=True,
                    user=GS.mumble_inst.users[text.actor]['name'])

        elif command == "aliases":
            if not privileges.plugin_privilege_checker(text, command,
                                                       self.plugin_name):
                return
            aliases_list = aliases.get_all_aliases()
            if len(aliases_list) == 0:
                cur_text = f"<font color='{GS.cfg[C_PGUI_SETTINGS][P_TXT_HEAD_COL]}'>Registered Aliases: None</font>"
            else:
                cur_text = f"<font color='{GS.cfg[C_PGUI_SETTINGS][P_TXT_HEAD_COL]}'>Registered Aliases:</font>"
                for i, alias in enumerate(aliases_list):
                    cur_text += f"<br><font color={GS.cfg[C_PGUI_SETTINGS][P_TXT_IND_COL]}>[{alias[0]}]</font> - " \
                                f"[{BeautifulSoup(alias[1], 'html.parser').get_text()}] "
                    if i % 50 == 0 and i != 0:
                        GS.gui_service.quick_gui(
                            cur_text,
                            text_type='header',
                            box_align='left',
                            text_align='left',
                            ignore_whisper=True,
                            user=GS.mumble_inst.users[text.actor]['name'])
                        cur_text = ""
            GS.gui_service.quick_gui(
                cur_text,
                text_type='header',
                box_align='left',
                text_align='left',
                ignore_whisper=True,
                user=GS.mumble_inst.users[text.actor]['name'])

        elif command == "removealias":
            if not privileges.plugin_privilege_checker(text, command,
                                                       self.plugin_name):
                return
            message = text.message.strip()
            message_parse = message[1:].split(' ', 2)
            if len(message_parse) < 2:
                return
            alias_name = message_parse[1]
            if aliases.remove_from_aliases(alias_name):
                GS.gui_service.quick_gui(
                    f'Removed [{alias_name}] from registered aliases.',
                    text_type='header',
                    box_align='left',
                    ignore_whisper=True,
                    user=GS.mumble_inst.users[text.actor]['name'])
            else:
                GS.gui_service.quick_gui(
                    f'Could not remove [{alias_name}] from registered aliases.',
                    text_type='header',
                    box_align='left',
                    ignore_whisper=True,
                    user=GS.mumble_inst.users[text.actor]['name'])

        elif command == "clearaliases":
            if not privileges.plugin_privilege_checker(text, command,
                                                       self.plugin_name):
                return
            if aliases.clear_aliases():
                GS.gui_service.quick_gui(
                    'Cleared all registered aliases.',
                    text_type='header',
                    box_align='left',
                    ignore_whisper=True,
                    user=GS.mumble_inst.users[text.actor]['name'])
            else:
                GS.gui_service.quick_gui(
                    'The registered aliases could not be cleared.',
                    text_type='header',
                    box_align='left',
                    ignore_whisper=True,
                    user=GS.mumble_inst.users[text.actor]['name'])

        elif command == "clearhistory":
            if not privileges.plugin_privilege_checker(text, command,
                                                       self.plugin_name):
                return
            GS.cmd_history.queue_storage.clear()
            GS.gui_service.quick_gui(
                f'<font color="{GS.cfg[C_PGUI_SETTINGS][P_TXT_HEAD_COL]}">Cleared command history.</font>',
                text_type='header',
                box_align='left',
                text_align='left',
                ignore_whisper=True,
                user=GS.mumble_inst.users[text.actor]['name'])

        elif command == "history":
            if not privileges.plugin_privilege_checker(text, command,
                                                       self.plugin_name):
                return
            cur_text = f"<font color='{GS.cfg[C_PGUI_SETTINGS][P_TXT_HEAD_COL]}'>Command History:</font>"
            for i, item in enumerate(GS.cmd_history.queue_storage):
                cur_text += f"<br><font color={GS.cfg[C_PGUI_SETTINGS][P_TXT_IND_COL]}>[{i}]</font> - {item}"
                if i % 50 == 0 and i != 0:
                    GS.gui_service.quick_gui(
                        cur_text,
                        text_type='header',
                        box_align='left',
                        text_align='left',
                        ignore_whisper=True,
                        user=GS.mumble_inst.users[text.actor]['name'])
                    cur_text = ""
            GS.gui_service.quick_gui(
                cur_text,
                text_type='header',
                box_align='left',
                text_align='left',
                ignore_whisper=True,
                user=GS.mumble_inst.users[text.actor]['name'])
Пример #11
0
    def process(self, text):
        message = text.message.strip()
        message_parse = message[1:].split(' ', 1)
        command = message_parse[0]

        if command == "song":
            if not privileges.plugin_privilege_checker(text, command, self.plugin_name):
                return
            if YH.current_song_info is not None:
                GS.gui_service.quick_gui_img(f"{dir_utils.get_temp_med_dir()}/youtube",
                                             f"{YH.current_song_info['img_id']}",
                                             caption=f"Now playing: {YH.current_song_info['main_title']}",
                                             format_img=True,
                                             img_size=32768)
                log(INFO, "Displayed current song in the youtube plugin.", origin=L_COMMAND)
            else:
                GS.gui_service.quick_gui(
                    f"{runtime_utils.get_bot_name()}({self.plugin_name}) is not playing anything right now.",
                    text_type='header',
                    box_align='left')

        elif command == "autoplay":
            if not privileges.plugin_privilege_checker(text, command, self.plugin_name):
                return
            if YH.autoplay:
                YH.autoplay = False
                GS.gui_service.quick_gui(
                    "Autoplay has been disabled.",
                    text_type='header',
                    box_align='left')
                log(INFO, "Autoplay has been disabled in the youtube plugin.", origin=L_COMMAND)
            else:
                YH.autoplay = True
                GS.gui_service.quick_gui(
                    "Autoplay has been enabled.",
                    text_type='header',
                    box_align='left')
                log(INFO, "Autoplay has been enabled in the youtube plugin.", origin=L_COMMAND)

        elif command == "shuffle":
            if not privileges.plugin_privilege_checker(text, command, self.plugin_name):
                return
            if GS.audio_inst is not None:
                if not YH.queue_instance.is_empty():
                    YH.queue_instance.shuffle()
                    YM.download_next()
                    GS.gui_service.quick_gui(
                        "The youtube queue has been shuffled.",
                        text_type='header',
                        box_align='left')
                    log(INFO, "The youtube audio queue was shuffled.", origin=L_COMMAND)
                    return

        elif command == "next":
            if not privileges.plugin_privilege_checker(text, command, self.plugin_name):
                return
            if not GS.audio_dni[0]:
                GS.audio_dni = (True, self.metadata[C_PLUGIN_INFO][P_PLUGIN_NAME])
            else:
                if GS.audio_dni[1] != self.metadata[C_PLUGIN_INFO][P_PLUGIN_NAME]:
                    rprint(
                        f'An audio plugin is using the audio thread with no interruption mode enabled. [{GS.audio_dni[0]}|{GS.audio_dni[1]}]')
                    GS.gui_service.quick_gui(
                        "An audio plugin is using the audio thread with no interruption mode enabled.",
                        text_type='header',
                        box_align='left')
                    return
            YM.next_track()

        elif command == "removetrack":
            if not privileges.plugin_privilege_checker(text, command, self.plugin_name):
                return
            if GS.audio_inst is not None:
                if YH.queue_instance.is_empty():
                    GS.gui_service.quick_gui(
                        "The youtube queue is empty, so I can't remove tracks.",
                        text_type='header',
                        box_align='left')
                    return
                rem_val = int(message[1:].split(' ', 1)[1])
                if rem_val > YH.queue_instance.size() - 1 or rem_val < 0:
                    GS.gui_service.quick_gui(
                        f"You can't remove tracks beyond the length of the current queue.",
                        text_type='header',
                        box_align='left')
                    return
                removed_item = YH.queue_instance.remove(rem_val)
                GS.gui_service.quick_gui(
                    f"Removed track: [{rem_val}]-{removed_item['main_title']} from the queue.",
                    text_type='header',
                    box_align='left')
                log(INFO, f"Removed track #{rem_val} from the youtube audio queue.", origin=L_COMMAND)
                return

        elif command == "skipto":
            if not privileges.plugin_privilege_checker(text, command, self.plugin_name):
                return
            skip_val = int(message[1:].split(' ', 1)[1])
            YM.skipto(skip_val)
            log(INFO, f"The youtube audio queue skipped to track #{skip_val}.", origin=L_COMMAND)

        elif command == "stop":
            if not privileges.plugin_privilege_checker(text, command, self.plugin_name):
                return
            if GS.audio_inst is not None:
                if not GS.audio_dni[0]:
                    GS.audio_dni = (True, self.metadata[C_PLUGIN_INFO][P_PLUGIN_NAME])
                else:
                    if GS.audio_dni[1] != self.metadata[C_PLUGIN_INFO][P_PLUGIN_NAME]:
                        rprint(
                            f'An audio plugin is using the audio thread with no interruption mode enabled. [{GS.audio_dni[1]}]')
                        GS.gui_service.quick_gui(
                            "An audio plugin is using the audio thread with no interruption mode enabled.",
                            text_type='header',
                            box_align='left')
                        return
                GS.gui_service.quick_gui(
                    "Stopping youtube audio thread.",
                    text_type='header',
                    box_align='left')
                YH.queue_instance.clear()
                YM.stop_audio()
                dir_utils.clear_directory(f'{dir_utils.get_temp_med_dir()}/youtube')
                YH.queue_instance = qh.QueueHandler(YH.max_queue_size)
                log(INFO, "The youtube audio thread was stopped.", origin=L_COMMAND)
                return

        elif command == "clear":
            if not privileges.plugin_privilege_checker(text, command, self.plugin_name):
                return
            rprint("Clearing youtube queue.")
            YM.clear_queue()
            GS.gui_service.quick_gui(
                "Cleared youtube queue.",
                text_type='header',
                box_align='left')
            log(INFO, "The youtube queue was cleared.", origin=L_COMMAND)

        elif command == "volume":
            if not privileges.plugin_privilege_checker(text, command, self.plugin_name):
                return
            try:
                vol = float(message[1:].split(' ', 1)[1])
            except IndexError:
                GS.gui_service.quick_gui(
                    f"Current youtube volume: {YH.volume}",
                    text_type='header',
                    box_align='left')
                return

            if vol > 1 or vol < 0:
                GS.gui_service.quick_gui(
                    "Invalid Volume Input: [0-1]",
                    text_type='header',
                    box_align='left')
                return
            YH.volume = vol
            GS.gui_service.quick_gui(
                f"Set volume to {YH.volume}",
                text_type='header',
                box_align='left')
            log(INFO, f"The youtube audio volume was changed to {YH.volume}.", origin=L_COMMAND)

        elif command == "youtube":
            if not privileges.plugin_privilege_checker(text, command, self.plugin_name):
                return

            if not GS.audio_dni[0]:
                GS.audio_dni = (True, self.metadata[C_PLUGIN_INFO][P_PLUGIN_NAME])
            else:
                if GS.audio_dni[1] != self.metadata[C_PLUGIN_INFO][P_PLUGIN_NAME]:
                    rprint(
                        f'An audio plugin is using the audio thread with no interruption mode enabled. [{GS.audio_dni[1]}]')
                    GS.gui_service.quick_gui(
                        "An audio plugin is using the audio thread with no interruption mode enabled.",
                        text_type='header',
                        box_align='left')
                    return

            try:
                search_term = message_parse[1]
            except IndexError:
                return

            YH.all_searches = YM.get_search_results(search_term)
            search_results = YM.get_choices(YH.all_searches)
            GS.gui_service.quick_gui(
                f"{search_results}\nWhich one would you like to play?",
                text_type='header',
                box_align='left',
                text_align='left')
            log(INFO, "Displayed youtube search results.", origin=L_COMMAND)
            YH.can_play = True

        elif command == "queue":
            if not privileges.plugin_privilege_checker(text, command, self.plugin_name):
                return
            queue_results = YM.get_queue()
            if queue_results is not None:
                cur_text = ""
                for i, item in enumerate(queue_results):
                    cur_text += f"{item}"
                    if i % 50 == 0 and i != 0:
                        GS.gui_service.quick_gui(
                            f"{cur_text}",
                            text_type='header',
                            box_align='left',
                            text_align='left')
                        cur_text = ""
                if cur_text != "":
                    GS.gui_service.quick_gui(
                        f"{cur_text}",
                        text_type='header',
                        box_align='left',
                        text_align='left')
                log(INFO, "Displayed current youtube queue.", origin=L_COMMAND)
            else:
                GS.gui_service.quick_gui(
                    "The youtube queue is empty.",
                    text_type='header',
                    box_align='left')

        elif command == "playlist":
            if not privileges.plugin_privilege_checker(text, command, self.plugin_name):
                return
            if len(message_parse) == 2:
                if not GS.audio_dni[0]:
                    GS.audio_dni = (True, self.metadata[C_PLUGIN_INFO][P_PLUGIN_NAME])
                else:
                    if GS.audio_dni[1] != self.metadata[C_PLUGIN_INFO][P_PLUGIN_NAME]:
                        rprint(
                            f'An audio plugin is using the audio thread with no interruption mode enabled. [{GS.audio_dni[0]}|{GS.audio_dni[1]}]')
                        GS.gui_service.quick_gui(
                            "An audio plugin is using the audio thread with no interruption mode enabled.",
                            text_type='header',
                            box_align='left')
                        return

                stripped_url = BeautifulSoup(message_parse[1], features='html.parser').get_text()
                if "youtube.com" in stripped_url or "youtu.be" in stripped_url:
                    if YH.queue_instance.is_full():
                        GS.gui_service.quick_gui(
                            "The youtube queue is full!",
                            text_type='header',
                            box_align='left')
                        return
                    all_song_data = YM.download_playlist(stripped_url)
                    if all_song_data is None:
                        return

                    for i, song_data in enumerate(all_song_data):
                        YH.queue_instance.insert(song_data)

                    GS.gui_service.quick_gui(
                        f'Playlist Generated:<br><a href="{stripped_url}">{stripped_url}</a>',
                        text_type='header',
                        box_align='left')
                    log(INFO, f"Generated playlist: {stripped_url}", origin=L_COMMAND)
                    if not YH.is_playing:
                        YM.download_next()
                        YM.play_audio()
                    return
            else:
                GS.gui_service.quick_gui(
                    "The given link was not identified as a youtube video link!",
                    text_type='header',
                    box_align='left')
                return

        elif command == "linkfront":
            if not privileges.plugin_privilege_checker(text, command, self.plugin_name):
                return

            if not GS.audio_dni[0]:
                GS.audio_dni = (True, self.metadata[C_PLUGIN_INFO][P_PLUGIN_NAME])
            else:
                if GS.audio_dni[1] != self.metadata[C_PLUGIN_INFO][P_PLUGIN_NAME]:
                    rprint(
                        f'An audio plugin is using the audio thread with no interruption mode enabled. [{GS.audio_dni[1]}]')
                    GS.gui_service.quick_gui(
                        "An audio plugin is using the audio thread with no interruption mode enabled.",
                        text_type='header',
                        box_align='left')
                    return

            if len(message_parse) == 2:
                stripped_url = BeautifulSoup(message_parse[1], features='html.parser').get_text()
                if "youtube.com" in stripped_url or "youtu.be" in stripped_url:
                    if YH.queue_instance.is_full():
                        GS.gui_service.quick_gui(
                            "The youtube queue is full!",
                            text_type='header',
                            box_align='left')
                        return
                    song_data = YM.download_song_name(stripped_url)
                    if song_data is None:
                        GS.gui_service.quick_gui(
                            "ERROR: The chosen stream was either too long or a live stream.",
                            text_type='header',
                            box_align='left')
                        return
                    # song_data['main_url'] = stripped_url

                    # self.sound_board_plugin.clear_audio_thread()
                    if not GS.audio_dni[0]:
                        GS.audio_dni = (True, self.metadata[C_PLUGIN_INFO][P_PLUGIN_NAME])
                    else:
                        if GS.audio_dni[1] != self.metadata[C_PLUGIN_INFO][P_PLUGIN_NAME]:
                            rprint(
                                f'An audio plugin is using the audio thread with no interruption mode enabled. [{GS.audio_dni[1]}]')
                            GS.gui_service.quick_gui(
                                "An audio plugin is using the audio thread with no interruption mode enabled.",
                                text_type='header',
                                box_align='left')
                            return
                    YH.queue_instance.insert_priority(song_data)

                    GS.gui_service.quick_gui(
                        f"Added to front of queue: {stripped_url}",
                        text_type='header',
                        box_align='left')
                    GS.log_service.info("Direct link added to the front of the youtube queue.")
                    if not YH.is_playing:
                        YM.download_next()
                        YM.play_audio()
                else:
                    GS.gui_service.quick_gui(
                        "The given link was not identified as a youtube video link!",
                        text_type='header',
                        box_align='left')

        elif command == "link":
            if not privileges.plugin_privilege_checker(text, command, self.plugin_name):
                return
            if not GS.audio_dni[0]:
                GS.audio_dni = (True, self.metadata[C_PLUGIN_INFO][P_PLUGIN_NAME])
            else:
                if GS.audio_dni[1] != self.metadata[C_PLUGIN_INFO][P_PLUGIN_NAME]:
                    rprint(
                        f'An audio plugin is using the audio thread with no interruption mode enabled. [{GS.audio_dni[1]}]')
                    GS.gui_service.quick_gui(
                        "An audio plugin is using the audio thread with no interruption mode enabled.",
                        text_type='header',
                        box_align='left')
                    return

            if len(message_parse) == 2:
                stripped_url = BeautifulSoup(message_parse[1], features='html.parser').get_text()
                if "youtube.com" in stripped_url or "youtu.be" in stripped_url:
                    if YH.queue_instance.is_full():
                        GS.gui_service.quick_gui(
                            "The youtube queue is full!",
                            text_type='header',
                            box_align='left')
                        return
                    song_data = YM.download_song_name(stripped_url)
                    if song_data is None:
                        GS.gui_service.quick_gui(
                            "ERROR: The chosen stream was either too long or a live stream.",
                            text_type='header',
                            box_align='left')
                        return
                    # song_data['main_url'] = stripped_url

                    # self.sound_board_plugin.clear_audio_thread()
                    if not GS.audio_dni[0]:
                        GS.audio_dni = (True, self.metadata[C_PLUGIN_INFO][P_PLUGIN_NAME])
                    else:
                        if GS.audio_dni[1] != self.metadata[C_PLUGIN_INFO][P_PLUGIN_NAME]:
                            rprint(
                                f'An audio plugin is using the audio thread with no interruption mode enabled. [{GS.audio_dni[1]}]')
                            GS.gui_service.quick_gui(
                                "An audio plugin is using the audio thread with no interruption mode enabled.",
                                text_type='header',
                                box_align='left')
                            return
                    YH.queue_instance.insert(song_data)

                    GS.gui_service.quick_gui(
                        f"Added to queue: {stripped_url}",
                        text_type='header',
                        box_align='left')
                    GS.log_service.info("Direct link added to youtube queue.")
                    if not YH.is_playing:
                        YM.download_next()
                        YM.play_audio()
                else:
                    GS.gui_service.quick_gui(
                        "The given link was not identified as a youtube video link!",
                        text_type='header',
                        box_align='left')

        elif command == "loop":
            if not privileges.plugin_privilege_checker(text, command, self.plugin_name):
                return
            YH.loop_song = not YH.loop_song
            rprint(
                f'{"Enabled" if YH.loop_song is True else "Disabled"} {self.plugin_name} loop mode. {"The next track in the queue will start looping." if YH.loop_song else ""}')
            GS.gui_service.quick_gui(
                f'{"Enabled" if YH.loop_song is True else "Disabled"} {self.plugin_name} loop mode. {"The next track in the queue will start looping." if YH.loop_song else ""}',
                text_type='header',
                box_align='left')

        elif command == "play":
            if not privileges.plugin_privilege_checker(text, command, self.plugin_name):
                return
            if YH.can_play:
                if not GS.audio_dni[0]:
                    GS.audio_dni = (True, self.metadata[C_PLUGIN_INFO][P_PLUGIN_NAME])
                else:
                    if GS.audio_dni[1] != self.metadata[C_PLUGIN_INFO][P_PLUGIN_NAME]:
                        rprint(
                            f'An audio plugin is using the audio thread with no interruption mode enabled. [{GS.audio_dni[1]}]')
                        GS.gui_service.quick_gui(
                            "An audio plugin is using the audio thread with no interruption mode enabled.",
                            text_type='header',
                            box_align='left')
                        return

                if YH.queue_instance.is_full():
                    GS.gui_service.quick_gui(
                        "The youtube queue is full!",
                        text_type='header',
                        box_align='left')
                    return

                all_messages = message[1:].split()
                if len(all_messages) == 1:
                    song_data = YM.download_song_name(
                        "https://www.youtube.com" + YH.all_searches[0]['href'])
                    if song_data is None:
                        GS.gui_service.quick_gui(
                            f"The chosen video is too long. The maximum video length is {(YH.max_track_duration / 60)} minutes",
                            text_type='header',
                            box_align='left')
                        return
                    # song_data['main_url'] = "https://www.youtube.com" + YH.all_searches[0]['href']
                    GS.gui_service.quick_gui(
                        f"Automatically chosen: {YH.all_searches[0]['title']}",
                        text_type='header',
                        box_align='left')
                    YH.can_play = False
                    YH.queue_instance.insert(song_data)
                    if not YH.is_playing:
                        YM.download_next()
                        YM.play_audio()
                elif len(all_messages) == 2:
                    if 9 >= int(all_messages[1]) >= 0:
                        song_data = YM.download_song_name(
                            "https://www.youtube.com" + YH.all_searches[int(all_messages[1])]['href'])
                        if song_data is None:
                            GS.gui_service.quick_gui(
                                f"The chosen video is too long. The maximum video length is {(YH.max_track_duration / 60)} minutes",
                                text_type='header',
                                box_align='left')
                            return
                        # song_data['main_url'] = "https://www.youtube.com" + YH.all_searches[int(all_messages[1])]['href']
                        GS.gui_service.quick_gui(
                            f"You've chosen: {YH.all_searches[int(all_messages[1])]['title']}",
                            text_type='header',
                            box_align='left')
                        YH.can_play = False
                    else:
                        GS.gui_service.quick_gui(
                            "Invalid choice! Valid Range [0-9]",
                            text_type='header',
                            box_align='left')
                        YH.can_play = False
                        return
                    YH.queue_instance.insert(song_data)
                    if not YH.is_playing:
                        YM.download_next()
                        YM.play_audio()
                elif len(all_messages) == 3:
                    if 9 >= int(all_messages[1]) >= 0:
                        song_data = YM.download_song_name(
                            "https://www.youtube.com" + YH.all_searches[int(all_messages[1])]['href'])
                        if song_data is None:
                            GS.gui_service.quick_gui(
                                f"The chosen video is too long. The maximum video length is {(YH.max_track_duration / 60)} minutes",
                                text_type='header',
                                box_align='left')
                            return
                        #song_data['main_url'] = "https://www.youtube.com" + YH.all_searches[int(all_messages[1])]['href']
                        GS.gui_service.quick_gui(
                            f"You've chosen: {YH.all_searches[int(all_messages[1])]['title']}",
                            text_type='header',
                            box_align='left')
                        YH.can_play = False
                    else:
                        GS.gui_service.quick_gui(
                            "Invalid choice! Valid Range [0-9]",
                            text_type='header',
                            box_align='left')
                        YH.can_play = False
                        return
                    count = int(all_messages[2])
                    for i in range(count):
                        YH.queue_instance.insert(song_data)
                    if not YH.is_playing:
                        YM.download_next()
                        YM.play_audio()

        elif command == "replay":
            if not privileges.plugin_privilege_checker(text, command, self.plugin_name):
                return
            if GS.audio_inst is not None:
                if not GS.audio_dni[0]:
                    GS.audio_dni = (True, self.metadata[C_PLUGIN_INFO][P_PLUGIN_NAME])
                else:
                    if GS.audio_dni[1] != self.metadata[C_PLUGIN_INFO][P_PLUGIN_NAME]:
                        rprint(
                            f'An audio plugin is using the audio thread with no interruption mode enabled. [{GS.audio_dni[1]}]')
                        GS.gui_service.quick_gui(
                            "An audio plugin is using the audio thread with no interruption mode enabled.",
                            text_type='header',
                            box_align='left')
                        return

                if YH.current_song is not None and YH.current_song_info is not None:
                    YH.queue_instance.insert_priority(YH.current_song_info)
                    YM.stop_audio()
                    YM.download_next()
                    YM.play_audio()
            else:
                GS.gui_service.quick_gui(
                    "There is no track available to replay.",
                    text_type='header',
                    box_align='left')
                return
Пример #12
0
    def process(self, text):
        message = text.message.strip()
        message_parse = message[1:].split(' ', 1)
        command = message_parse[0]

        if command == "sbstop":
            if not privileges.plugin_privilege_checker(text, command,
                                                       self.plugin_name):
                return
            if sbu_settings.is_playing and GS.audio_inst is not None:
                if not GS.audio_dni[0]:
                    GS.audio_dni = (
                        True, self.metadata[C_PLUGIN_INFO][P_PLUGIN_NAME])
                else:
                    if GS.audio_dni[1] != self.metadata[C_PLUGIN_INFO][
                            P_PLUGIN_NAME]:
                        rprint(
                            f'An audio plugin is using the audio thread with no interruption mode enabled. [{GS.audio_dni[1]}]'
                        )
                        GS.gui_service.quick_gui(
                            "An audio plugin is using the audio thread with no interruption mode enabled.",
                            text_type='header',
                            box_align='left')
                        return
                sbu.stop_audio()
                GS.gui_service.quick_gui(
                    "Stopping sound board audio thread...",
                    text_type='header',
                    box_align='left')
                return

        elif command == "sbvolume":
            if not privileges.plugin_privilege_checker(text, command,
                                                       self.plugin_name):
                return
            try:
                vol = float(message[1:].split(' ', 1)[1])
            except IndexError:
                GS.gui_service.quick_gui(
                    f"Current sound board volume: {sbu_settings.volume}",
                    text_type='header',
                    box_align='left')
                return
            if vol > 1 or vol < 0:
                GS.gui_service.quick_gui(
                    "Invalid sound_board volume Input: [0-1]",
                    text_type='header',
                    box_align='left')
                return
            sbu_settings.volume = vol
            log(INFO,
                f"Set {self.plugin_name} volume to {sbu_settings.volume}",
                origin=L_COMMAND)
            GS.gui_service.quick_gui(
                f"Set {self.plugin_name} volume to {sbu_settings.volume}",
                text_type='header',
                box_align='left')

        elif command == "sblist":
            if not privileges.plugin_privilege_checker(text, command,
                                                       self.plugin_name):
                return
            internal_list = []
            gather_list = sbu.prepare_sb_list()
            for i, item in enumerate(gather_list):
                internal_list.append(
                    f"<br><font color='{GS.cfg[C_PGUI_SETTINGS][P_TXT_IND_COL]}'>[{i}]</font> - [{item}]"
                )
            cur_text = f"<font color='{GS.cfg[C_PGUI_SETTINGS][P_TXT_HEAD_COL]}'>Local Sound Board Files:</font>"
            if len(internal_list) == 0:
                cur_text += "<br>There are no local sound board files available."
                GS.gui_service.quick_gui(
                    cur_text,
                    text_type='header',
                    box_align='left',
                    user=GS.mumble_inst.users[text.actor]['name'])
                log(INFO, "Displayed a list of all local sound board files.")
                return
            for i, item in enumerate(internal_list):
                cur_text += item
                if i % 50 == 0 and i != 0:
                    GS.gui_service.quick_gui(
                        cur_text,
                        text_type='header',
                        box_align='left',
                        text_align='left',
                        user=GS.mumble_inst.users[text.actor]['name'])
                    cur_text = ""
            if cur_text != "":
                GS.gui_service.quick_gui(
                    cur_text,
                    text_type='header',
                    box_align='left',
                    text_align='left',
                    user=GS.mumble_inst.users[text.actor]['name'])
            log(INFO, "Displayed a list of all local sound board files.")

        elif command == "sblist_echo":
            if not privileges.plugin_privilege_checker(text, command,
                                                       self.plugin_name):
                return
            internal_list = []
            gather_list = sbu.prepare_sb_list()

            for i, item in enumerate(gather_list):
                internal_list.append(
                    f"<br><font color='{GS.cfg[C_PGUI_SETTINGS][P_TXT_IND_COL]}'>[{i}]</font> - [{item}]"
                )
            cur_text = f"<font color='{GS.cfg[C_PGUI_SETTINGS][P_TXT_HEAD_COL]}'>Local Sound Board Files:</font>"
            if len(internal_list) == 0:
                cur_text += "<br>There are no local sound board files available."
                GS.gui_service.quick_gui(cur_text,
                                         text_type='header',
                                         box_align='left')
                log(INFO, "Displayed a list of all local sound board files.")
                return
            for i, item in enumerate(internal_list):
                cur_text += item
                if i % 50 == 0 and i != 0:
                    GS.gui_service.quick_gui(cur_text,
                                             text_type='header',
                                             box_align='left',
                                             text_align='left')
                    cur_text = ""
            if cur_text != "":
                GS.gui_service.quick_gui(cur_text,
                                         text_type='header',
                                         box_align='left',
                                         text_align='left')
            log(INFO, "Displayed a list of all local sound board files.")

        elif command == "sbdownload":
            if not privileges.plugin_privilege_checker(text, command,
                                                       self.plugin_name):
                return
            all_messages = message[1:].split()
            all_messages_stripped = BeautifulSoup(
                message_parse[1], features='html.parser').get_text()
            split_msgs = all_messages_stripped.split()
            stripped_url = split_msgs[0]
            if len(all_messages) >= 3:
                if "youtube.com" in stripped_url or "youtu.be" in stripped_url:
                    sbu.download_clip(stripped_url, split_msgs[1].strip())
                    GS.gui_service.quick_gui(
                        f"Downloaded sound clip as : {split_msgs[1].strip()}.wav",
                        text_type='header',
                        box_align='left')
                    return
                return

        elif command == "sbdelete":
            if not privileges.plugin_privilege_checker(text, command,
                                                       self.plugin_name):
                return
            all_messages = message[1:].split()
            if len(all_messages) == 2:
                if ".wav" in all_messages[1].strip():
                    dir_utils.remove_file(
                        all_messages[1].strip(),
                        f"{dir_utils.get_perm_med_dir()}/{self.plugin_name}/")
                    GS.gui_service.quick_gui(
                        f"Deleted sound clip : {all_messages[1].strip()}",
                        text_type='header',
                        box_align='left')

        elif command == "sbplaying":
            if not privileges.plugin_privilege_checker(text, command,
                                                       self.plugin_name):
                return
            if GS.audio_dni[1] == self.metadata[C_PLUGIN_INFO][
                    P_PLUGIN_NAME] and GS.audio_dni[0] is True:
                track_duration = sbu.get_audio_length(
                    sbu_settings.current_track)
                rprint(
                    f'{get_bot_name()}({self.plugin_name}) is playing: {sbu_settings.current_track} (duration: {str(timedelta(seconds = round(track_duration))) if track_duration > 0 else "Unavailable"})',
                    origin=L_COMMAND)
                GS.gui_service.quick_gui(
                    f'{get_bot_name()}({self.plugin_name}) is playing: {sbu_settings.current_track} (duration: {str(timedelta(seconds = round(track_duration))) if track_duration > 0 else "Unavailable"})',
                    text_type='header',
                    box_align='left')

        elif command == "sbrandom":
            if not privileges.plugin_privilege_checker(text, command,
                                                       self.plugin_name):
                return
            if not GS.audio_dni[0]:
                GS.audio_dni = (True,
                                self.metadata[C_PLUGIN_INFO][P_PLUGIN_NAME])
            else:
                if GS.audio_dni[1] != self.metadata[C_PLUGIN_INFO][
                        P_PLUGIN_NAME]:
                    rprint(
                        f'An audio plugin is using the audio thread with no interruption mode enabled. [{GS.audio_dni[1]}]'
                    )
                    GS.gui_service.quick_gui(
                        "An audio plugin is using the audio thread with no interruption mode enabled.",
                        text_type='header',
                        box_align='left')
                    return
            # print(GS.audio_dni)
            gather_list = sbu.prepare_sb_list()

            random.seed(datetime.now())
            random_sfx = random.choice(gather_list)[:-4]

            if not os.path.isfile(
                    f"{dir_utils.get_perm_med_dir()}/{self.plugin_name}/{random_sfx}.wav"
            ):
                GS.gui_service.quick_gui("The sound clip does not exist.",
                                         text_type='header',
                                         box_align='left')
                return False
            sbu_settings.current_track = random_sfx
            sbu_settings.loop_clip = False
            sbu.play_audio()

        elif command == "sb":
            if not privileges.plugin_privilege_checker(text, command,
                                                       self.plugin_name):
                return
            if len(message_parse) < 2:
                return
            if not GS.audio_dni[0]:
                GS.audio_dni = (True,
                                self.metadata[C_PLUGIN_INFO][P_PLUGIN_NAME])
            else:
                if GS.audio_dni[1] != self.metadata[C_PLUGIN_INFO][
                        P_PLUGIN_NAME]:
                    rprint(
                        f'An audio plugin is using the audio thread with no interruption mode enabled. [{GS.audio_dni[1]}]'
                    )
                    GS.gui_service.quick_gui(
                        "An audio plugin is using the audio thread with no interruption mode enabled.",
                        text_type='header',
                        box_align='left')
                    return
            # print(GS.audio_dni)
            parameter = message_parse[1].strip()
            if not os.path.isfile(
                    f"{dir_utils.get_perm_med_dir()}/{self.plugin_name}/{parameter}.wav"
            ):
                GS.gui_service.quick_gui("The sound clip does not exist.",
                                         text_type='header',
                                         box_align='left')
                return False
            sbu_settings.current_track = parameter
            sbu_settings.loop_clip = False
            sbu.play_audio()

        elif command == "sbloop":
            if not privileges.plugin_privilege_checker(text, command,
                                                       self.plugin_name):
                return
            if len(message_parse) < 2:
                return
            if not GS.audio_dni[0]:
                GS.audio_dni = (True,
                                self.metadata[C_PLUGIN_INFO][P_PLUGIN_NAME])
            else:
                if GS.audio_dni[1] != self.metadata[C_PLUGIN_INFO][
                        P_PLUGIN_NAME]:
                    rprint(
                        f'An audio plugin is using the audio thread with no interruption mode enabled. [{GS.audio_dni[1]}]'
                    )
                    GS.gui_service.quick_gui(
                        "An audio plugin is using the audio thread with no interruption mode enabled.",
                        text_type='header',
                        box_align='left')
                    return
            # print(GS.audio_dni)
            parameter = message_parse[1].strip()
            if not os.path.isfile(
                    f"{dir_utils.get_perm_med_dir()}/{self.plugin_name}/{parameter}.wav"
            ):
                GS.gui_service.quick_gui("The sound clip does not exist.",
                                         text_type='header',
                                         box_align='left')
                return False
            sbu_settings.current_track = parameter
            sbu_settings.loop_clip = True
            sbu.play_audio()

        elif command == "sbskip":
            if not privileges.plugin_privilege_checker(text, command,
                                                       self.plugin_name):
                return
            if len(message_parse) < 2:
                return
            if GS.audio_dni[1] == self.metadata[C_PLUGIN_INFO][
                    P_PLUGIN_NAME] and GS.audio_dni[0] is True:
                if not sbu_settings.loop_clip:
                    try:
                        seconds_to_skip = int(message_parse[1])
                        sbu_settings.skip_to = seconds_to_skip
                        sbu.play_audio()
                    except ValueError:
                        return
                else:
                    GS.gui_service.quick_gui(
                        "The skip feature is currently unavailable when looping clips.",
                        text_type='header',
                        box_align='left')