def initialize_settings():
        global_settings.mtd_callbacks = Callbacks()
        global_settings.cmd_callbacks = CommandCallbacks()
        global_settings.plugin_callbacks = Callbacks()
        global_settings.core_callbacks = CoreCallbacks()

        runtime_settings.tick_rate = float(
            global_settings.cfg[C_MAIN_SETTINGS][P_CMD_TICK_RATE])
        runtime_settings.cmd_hist_lim = int(
            global_settings.cfg[C_MAIN_SETTINGS][P_CMD_MULTI_LIM])
        runtime_settings.cmd_token = global_settings.cfg[C_MAIN_SETTINGS][
            P_CMD_TOKEN]
        runtime_settings.use_logging = global_settings.cfg.getboolean(
            C_LOGGING, P_LOG_ENABLE, fallback=False)
        runtime_settings.max_logs = int(
            global_settings.cfg[C_LOGGING][P_LOG_MAX])
        runtime_settings.max_log_size = int(
            global_settings.cfg[C_LOGGING][P_LOG_SIZE_MAX])
        runtime_settings.cmd_queue_lim = int(
            global_settings.cfg[C_MAIN_SETTINGS][P_CMD_QUEUE_LIM])
        runtime_settings.cmd_hist_lim = int(
            global_settings.cfg[C_MAIN_SETTINGS][P_CMD_HIST_LIM])
        runtime_settings.can_duck = global_settings.cfg.getboolean(
            C_MEDIA_SETTINGS, P_MEDIA_DUCK_AUDIO, fallback=False)
        if len(runtime_settings.cmd_token) != 1:
            rprint(
                "ERROR: The command token must be a single character! Reverting to the default: '!' token."
            )
            runtime_settings.cmd_token = '!'
 def cmd_blacklistuser(self, data):
     try:
         all_data = data.message.strip().split(' ', 2)
         reason = "No reason provided."
         if len(all_data) > 2:
             reason = all_data[2]
         result = privileges.add_to_blacklist(all_data[1])
         if result:
             gs.gui_service.quick_gui(
                 f"User: {all_data[1]} added to the blacklist.<br>Reason: {reason}",
                 text_type='header',
                 box_align='left',
                 text_align='left',
                 user=gs.mumble_inst.users[data.actor]['name'],
                 ignore_whisper=True)
             log(INFO,
                 f"Blacklisted user: {all_data[1]} <br>Reason: {reason}",
                 origin=L_USER_PRIV)
     except IndexError:
         rprint(
             f"Incorrect format! Format: {rutils.get_command_token()}blacklistuser 'username'"
         )
         gs.gui_service.quick_gui(
             f"Incorrect format! Format: {rutils.get_command_token()}blacklistuser 'username'",
             text_type='header',
             box_align='left',
             user=gs.mumble_inst.users[data.actor]['name'],
             ignore_whisper=True)
 def cmd_joinuser(self, data):
     split_data = data.message.strip().split(' ', 1)
     if len(split_data) != 2:
         rprint(
             f"Incorrect format! Format: {rutils.get_command_token()}joinuser 'username'"
         )
         gs.gui_service.quick_gui(
             f"Incorrect format! Format: {rutils.get_command_token()}joinuser 'username'",
             text_type='header',
             box_align='left',
             user=gs.mumble_inst.users[data.actor]['name'],
             ignore_whisper=True)
         return
     to_join = split_data[1]
     all_users = rutils.get_all_users()
     for user_id in rutils.get_all_users():
         if all_users[user_id]['name'] == to_join:
             gs.gui_service.quick_gui(
                 f"Joining user: {all_users[user_id]['name']}",
                 text_type='header',
                 box_align='left',
                 ignore_whisper=True)
             gs.mumble_inst.channels[all_users[user_id]
                                     ['channel_id']].move_in()
             dprint(f"Joined user: {all_users[user_id]['name']}",
                    origin=L_COMMAND)
             log(INFO,
                 f"Joined user: {all_users[user_id]['name']}",
                 origin=L_COMMAND)
 def cmd_addprivileges(self, data):
     data_actor = gs.mumble_inst.users[data.actor]
     try:
         username = data.message.strip().split()[1]
         level = int(data.message.strip().split()[2])
         result = privileges.add_to_privileges(username, level)
         if result:
             gs.gui_service.quick_gui(
                 f"Added a new user: {username} to the user privileges.",
                 text_type='header',
                 box_align='left',
                 user=data_actor['name'],
                 ignore_whisper=True)
             log(INFO,
                 f"Added a new user: {username} to the user privileges.",
                 origin=L_USER_PRIV)
     except IndexError:
         rprint(
             f"Incorrect format! Format: {rutils.get_command_token()}addprivileges 'username' 'level'"
         )
         gs.gui_service.quick_gui(
             f"Incorrect format! Format: {rutils.get_command_token()}addprivileges 'username' 'level'",
             text_type='header',
             box_align='left',
             user=data_actor['name'],
             ignore_whisper=True)
Exemple #5
0
    def initialize_settings():
        import configparser
        global_settings.cfg = configparser.ConfigParser()
        global_settings.cfg.read(f"{dir_utils.get_main_dir()}/cfg/config.ini")
        global_settings.mtd_callbacks = Callbacks()
        global_settings.cmd_callbacks = CommandCallbacks()
        global_settings.plugin_callbacks = Callbacks()

        runtime_settings.tick_rate = float(
            global_settings.cfg[C_MAIN_SETTINGS][P_CMD_TICK_RATE])
        runtime_settings.cmd_hist_lim = int(
            global_settings.cfg[C_MAIN_SETTINGS][P_CMD_MULTI_LIM])
        runtime_settings.cmd_token = global_settings.cfg[C_MAIN_SETTINGS][
            P_CMD_TOKEN]
        runtime_settings.use_logging = global_settings.cfg.getboolean(
            C_LOGGING, P_LOG_ENABLE, fallback=False)
        runtime_settings.max_logs = global_settings.cfg[C_LOGGING][P_LOG_MAX]
        runtime_settings.cmd_queue_lim = int(
            global_settings.cfg[C_MAIN_SETTINGS][P_CMD_QUEUE_LIM])
        runtime_settings.cmd_hist_lim = int(
            global_settings.cfg[C_MAIN_SETTINGS][P_CMD_HIST_LIM])
        runtime_settings.can_duck = global_settings.cfg.getboolean(
            C_MEDIA_SETTINGS, P_MEDIA_VLC_DUCK, fallback=False)
        if len(runtime_settings.cmd_token) != 1:
            rprint(
                "ERROR: The command token must be a single character! Reverting to the default: '!' token."
            )
            runtime_settings.cmd_token = '!'
 def cmd_move(self, data):
     data_actor = gs.mumble_inst.users[data.actor]['name']
     split_data = data.message.strip().split(' ', 1)
     if len(split_data) != 2:
         rprint(
             f"Incorrect format! Format: {rutils.get_command_token()}move 'channel_name'"
         )
         gs.gui_service.quick_gui(
             f"Incorrect format! Format: {rutils.get_command_token()}move 'channel_name'",
             text_type='header',
             box_align='left',
             user=gs.mumble_inst.users[data.actor]['name'],
             ignore_whisper=True)
         return
     channel_name = split_data[1]
     if channel_name == "default" or channel_name == "Default":
         channel_name = rutils.get_default_channel()
     channel_search = rutils.get_channel(channel_name)
     if channel_search is None:
         return
     channel_search.move_in()
     gs.gui_service.quick_gui(
         f"{rutils.get_bot_name()} was moved by {data_actor}",
         text_type='header',
         box_align='left',
         ignore_whisper=True)
     dprint(f"Moved to channel: {channel_name} by {data_actor}",
            origin=L_COMMAND)
     log(INFO,
         f"Moved to channel: {channel_name} by {data_actor}",
         origin=L_COMMAND)
Exemple #7
0
    def cmd_addwhisperuser(self, data):
        all_data = data.message.strip().split(' ', 1)
        data_actor = GS.mumble_inst.users[data.actor]
        try:
            username = all_data[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=data_actor['name'],
                    ignore_whisper=True)
                return
            if RS.whisper_target is not None:
                if not isinstance(RS.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=data_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 RS.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=data_actor['name'],
                            ignore_whisper=True)
                        return

            RS.whisper_target['id'].append(username)
            rutils.set_whisper_multi_user(RS.whisper_target['id'])
            rprint(f"Added new user: {username} to the whisper targets!",
                   origin=L_COMMAND)
            GS.gui_service.quick_gui(
                f"Added new user: {username} to the whisper targets!",
                text_type='header',
                box_align='left',
                user=data_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(
                f"Invalid whisper command!<br>Command format: {rutils.get_command_token()}addwhisperuser username",
                text_type='header',
                box_align='left',
                user=data_actor['name'],
                ignore_whisper=True)
            return
Exemple #8
0
 def cmd_setwhisperchannel(self, data):
     all_data = data.message.strip().split(' ', 1)
     data_actor = GS.mumble_inst.users[data.actor]
     try:
         parameter = all_data[1]
         if rutils.set_whisper_channel(parameter):
             GS.gui_service.quick_gui(
                 f"Set whisper to channel: {parameter}",
                 text_type='header',
                 box_align='left',
                 user=data_actor['name'],
                 ignore_whisper=True)
             rprint(f"Set whisper to channel: {parameter}.",
                    origin=L_COMMAND)
             log(INFO,
                 f"Set whisper to channel: {parameter}.",
                 origin=L_COMMAND)
         else:
             GS.gui_service.quick_gui(
                 f"Could not find channel: {parameter}",
                 text_type='header',
                 box_align='left',
                 user=data_actor['name'],
                 ignore_whisper=True)
     except IndexError:
         GS.gui_service.quick_gui(
             "Command format: !setwhisperchannel channel_name",
             text_type='header',
             box_align='left',
             user=data_actor['name'],
             ignore_whisper=True)
         return
Exemple #9
0
 def cmd_img(self, data):
     all_data = data.message.strip().split()
     parameters = all_data[1].rsplit(".", 1)
     try:
         if not os.path.isfile(
                 f"{dir_utils.get_perm_med_dir()}/images/{parameters[0]}.{parameters[1]}"
         ):
             gs.gui_service.quick_gui("The image does not exist.",
                                      text_type='header',
                                      box_align='left')
             return False
     except IndexError:
         return False
     # Format image
     formatted_string = IH.format_image(
         parameters[0], parameters[1],
         f"{dir_utils.get_perm_med_dir()}/images/")
     rprint("Posting an image to the mumble channel chat.")
     # Display image with PGUI system
     gs.gui_service.quick_gui_img(
         f"{dir_utils.get_perm_med_dir()}/images/",
         formatted_string,
         bgcolor=self.metadata[C_PLUGIN_SETTINGS][P_FRAME_COL],
         cellspacing=self.metadata[C_PLUGIN_SETTINGS][P_FRAME_SIZE],
         format_img=False)
     log(INFO,
         "Posted an image to the mumble channel chat from local files.")
def parse_message(text):
    message = text.message.strip()
    user = global_settings.mumble_inst.users[text.actor]

    if message[0] == runtime_settings.cmd_token:
        rprint(f"Commands Received: [{user['name']} -> {message}]", origin=L_COMMAND)
        log(INFO, f"Commands Received: [{user['name']} -> {message}]", origin=L_COMMAND)
        # example input: !version ; !about ; !yt twice ; !p ; !status
        all_commands = [msg.strip() for msg in message.split(';')]
        # example output: ["!version", "!about", "!yt twice", "!p", "!status"]

        # add to command history
        [global_settings.cmd_history.insert(cmd) for cmd in all_commands]
        if len(all_commands) > runtime_settings.multi_cmd_limit:
            rprint(
                f"The multi-command limit was reached! The multi-command limit is {runtime_settings.multi_cmd_limit} commands per line.")
            log(WARNING,
                f"The multi-command limit was reached! The multi-command limit is {runtime_settings.multi_cmd_limit} commands per line.",
                origin=L_COMMAND)
            return
        return all_commands

    if "<img" in message:
        rprint(f"Message Received: [{user['name']} -> Image Data]")
        log(INFO, f"Message Received: [{user['name']} -> Image Data]")
    elif "<a href=" in message:
        rprint(f"Message Received: [{user['name']} -> Hyperlink Data]")
        log(INFO, f"Message Received: [{user['name']} -> Hyperlink Data]")
    else:
        rprint(f"Message Received: [{user['name']} -> {message}]")
        log(INFO, f"Message Received: [{user['name']} -> {message}]")
    return None
Exemple #11
0
    def cmd_setwhisperuser(self, data):
        all_data = data.message.strip().split(' ', 1)
        data_actor = GS.mumble_inst.users[data.actor]
        try:
            parameter = all_data[1]
            if parameter == GS.cfg[C_CONNECTION_SETTINGS][P_USER_ID]:
                log(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=data_actor['name'],
                                         ignore_whisper=True)
                return
            if rutils.set_whisper_user(parameter):
                GS.gui_service.quick_gui(f"Set whisper to User: {parameter}", text_type='header',
                                         box_align='left', user=data_actor['name'],
                                         ignore_whisper=True)
                rprint(f"Set whisper to User: {parameter}.", origin=L_COMMAND)
                log(INFO, f"Set whisper to User: {parameter}.", origin=L_COMMAND)

            GS.gui_service.quick_gui(f"Could not find User: {parameter}", text_type='header',
                                     box_align='left', user=data_actor['name'],
                                     ignore_whisper=True)
        except IndexError:
            GS.gui_service.quick_gui(
                f"Invalid whisper command!<br>Command format: {rutils.get_command_token()}setwhisperuser username",
                text_type='header',
                box_align='left', user=data_actor['name'],
                ignore_whisper=True)
            return
    def message_received(text):
        all_commands = runtime_utils.parse_message(text)
        if all_commands is None:
            return
        # Iterate through all commands provided and generate commands.
        for i, item in enumerate(all_commands):
            # Generate command with parameters
            new_text = deepcopy(text)
            new_text.message = item
            try:
                new_command = Command(item[1:].split()[0], new_text)
            except IndexError:
                continue
            all_aliases = aliases.get_all_aliases()
            all_alias_names = [x[0] for x in all_aliases]
            if len(all_aliases) != 0:
                if new_command.command in all_alias_names:
                    alias_item_index = all_alias_names.index(
                        new_command.command)
                    alias_commands = [
                        msg.strip()
                        for msg in all_aliases[alias_item_index][1].split('|')
                    ]
                    if len(alias_commands) > runtime_settings.multi_cmd_limit:
                        rprint(
                            f"The multi-command limit was reached! "
                            f"The multi-command limit is {runtime_settings.multi_cmd_limit} "
                            f"commands per line.",
                            origin=L_COMMAND)
                        log(WARNING, f"The multi-command limit was reached! "
                            f"The multi-command limit is {runtime_settings.multi_cmd_limit} "
                            f"commands per line.",
                            origin=L_COMMAND)
                        return
                    for x, sub_item in enumerate(alias_commands):
                        sub_text = deepcopy(text)
                        if len(item[1:].split()) > 1:
                            sub_text.message = f"{sub_item} {item[1:].split(' ', 1)[1]}"
                        else:
                            sub_text.message = sub_item
                        try:
                            sub_command = Command(sub_item[1:].split()[0],
                                                  sub_text)
                        except IndexError:
                            continue
                        global_settings.cmd_queue.insert(sub_command)
                else:
                    # Insert command into the command queue
                    global_settings.cmd_queue.insert(new_command)
            else:
                global_settings.cmd_queue.insert(new_command)

        # Process commands if the queue is not empty
        while not global_settings.cmd_queue.is_empty():
            # Process commands in the queue
            BotService.process_command_queue(global_settings.cmd_queue.pop())
            sleep(runtime_settings.tick_rate)
 def __init__(self):
     super().__init__()
     from os import path
     from json import loads
     self.plugin_name = path.basename(__file__).rsplit('.')[0]
     self.metadata = PluginUtilityService.process_metadata(f'plugins/core/{self.plugin_name}')
     self.plugin_cmds = loads(self.metadata.get(C_PLUGIN_INFO, P_PLUGIN_CMDS))
     rprint(
         f"{self.metadata[C_PLUGIN_INFO][P_PLUGIN_NAME]} v{self.metadata[C_PLUGIN_INFO][P_PLUGIN_VERS]} Plugin Initialized.")
def plugin_privilege_checker(text, command, plugin_name):
    if not privileges_check(GS.mumble_inst.users[text.actor]) >= plugin_privileges_check(command, plugin_name):
        rprint(
            f"User [{GS.mumble_inst.users[text.actor]['name']}] does not have the user privileges to use this command: [{command}]")
        GS.gui_service.quick_gui(f"User [{GS.mumble_inst.users[text.actor]['name']}] does not have the user "
                                 f"privileges to use this command: [{command}]", text_type='header', box_align='left')
        log(INFO,
            f"User [{GS.mumble_inst.users[text.actor]['name']}] does not have the user privileges to use this command: [{command}]",
            L_COMMAND)
        return False
    return True
Exemple #15
0
 def cmd_clearwhisper(self, data):
     data_actor = GS.mumble_inst.users[data.actor]
     rutils.clear_whisper()
     if RS.whisper_target is None:
         rprint(f"Cleared current whisper targets")
         GS.gui_service.quick_gui(f"Cleared current whisper", text_type='header',
                                  box_align='left', user=data_actor['name'],
                                  ignore_whisper=True)
         return
     GS.gui_service.quick_gui("Unable to remove current whisper!", text_type='header',
                              box_align='left', user=data_actor['name'],
                              ignore_whisper=True)
Exemple #16
0
    def cmd_setwhisperme(self, data):
        data_actor = GS.mumble_inst.users[data.actor]
        if data_actor == 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(data_actor['name'])
        rprint(f"Set whisper to user: {data_actor['name']}", origin=L_COMMAND)
        GS.gui_service.quick_gui(f"Set whisper to user: {data_actor['name']}", text_type='header',
                                 box_align='left', user=data_actor['name'],
                                 ignore_whisper=True)
        log(INFO, f"Set whisper to user: {data_actor['name']}.", origin=L_COMMAND)
def add_to_blacklist(username):
    all_user_data = GetDB.get_all_user_data(get_memory_db().cursor())
    user_names_list = [x[0] for x in all_user_data]
    if username in user_names_list:
        for user in all_user_data:
            if user[0] == username and user[1] == Privileges.BLACKLIST.value:
                rprint(f"The user: {username} is already in the blacklist.", origin=L_USER_PRIV)
                log(INFO, f"The user: {username} is already in the blacklist.", origin=L_USER_PRIV)
                return False
        if UpdateDB.update_user_privileges(db_conn=get_memory_db(), user_name=username, level=int(Privileges.BLACKLIST.value)):
            return True
    return False
 def __init__(self):
     super().__init__()
     import os
     import json
     self.plugin_name = os.path.basename(__file__).rsplit('.')[0]
     self.metadata = PluginUtilityService.process_metadata(f'plugins/extensions/{self.plugin_name}')
     self.plugin_cmds = json.loads(self.metadata.get(C_PLUGIN_INFO, P_PLUGIN_CMDS))
     # Add any custom initialization code here...
     # ...
     # ...
     rprint(
         f"{self.metadata[C_PLUGIN_INFO][P_PLUGIN_NAME]} v{self.metadata[C_PLUGIN_INFO][P_PLUGIN_VERS]} Plugin Initialized.")
Exemple #19
0
 def __init__(self):
     super().__init__()
     from json import loads
     self.plugin_name = os.path.basename(__file__).rsplit('.')[0]
     self.metadata = PluginUtilityService.process_metadata(
         f'plugins/extensions/{self.plugin_name}')
     self.plugin_cmds = loads(
         self.metadata.get(C_PLUGIN_INFO, P_PLUGIN_CMDS))
     dir_utils.make_directory(
         f'{gs.cfg[C_MEDIA_SETTINGS][P_PERM_MEDIA_DIR]}/{self.plugin_name}/'
     )
     rprint(
         f"{self.metadata[C_PLUGIN_INFO][P_PLUGIN_NAME]} v{self.metadata[C_PLUGIN_INFO][P_PLUGIN_VERS]} Plugin Initialized."
     )
 def loop():
     try:
         while not global_settings.exit_flag:
             if time() > global_settings.aud_interface.status[
                 'duck_end'] and global_settings.aud_interface.audio_utilities.is_ducking():
                 global_settings.aud_interface.audio_utilities.unduck_volume()
             sleep(runtime_settings.tick_rate)
         BotService.stop()
     except KeyboardInterrupt:
         rprint(f"{runtime_utils.get_bot_name()} was booted offline by a keyboard interrupt (ctrl-c).",
                origin=L_SHUTDOWN)
         log(INFO, f"{runtime_utils.get_bot_name()} was booted offline by a keyboard interrupt (ctrl-c).",
             origin=L_SHUTDOWN)
         runtime_utils.exit_bot()
         BotService.stop()
 def __init__(self):
     super().__init__()
     from os import path
     from json import loads
     self.plugin_name = path.basename(__file__).rsplit('.')[0]
     self.metadata = PluginUtilityService.process_metadata(f'plugins/extensions/{self.plugin_name}')
     self.plugin_cmds = loads(self.metadata.get(C_PLUGIN_INFO, P_PLUGIN_CMDS))
     self.osrs_wiki_url = self.metadata[C_PLUGIN_SET][P_WIKI_URL]
     self.osrs_user_agent = self.metadata[C_PLUGIN_SET][P_USER_AGENT]
     rprint(
         f"{self.metadata[C_PLUGIN_INFO][P_PLUGIN_NAME]} v{self.metadata[C_PLUGIN_INFO][P_PLUGIN_VERS]} Plugin Initialized.")
     try:
         self.osrs_wiki = MediaWiki(url=self.osrs_wiki_url, user_agent=self.osrs_user_agent)
     except Exception:
         rprint(f"{self.plugin_name} Plugin could not be initialized.")
 def cmd_log(self, data):
     split_data = data.message.strip().split(' ', 1)
     if len(split_data) != 2:
         rprint(
             f"Incorrect format! Format: {rutils.get_command_token()}log 'message'"
         )
         gs.gui_service.quick_gui(
             f"Incorrect format! Format: {rutils.get_command_token()}log 'message'",
             text_type='header',
             box_align='left',
             user=gs.mumble_inst.users[data.actor]['name'],
             ignore_whisper=True)
         return
     to_log = split_data[1]
     dprint(f"Manually Logged: [{to_log}]", origin=L_LOGGING)
     log(INFO, f'Manually Logged: [{to_log}]', origin=L_LOGGING)
Exemple #23
0
 def __init__(self):
     super().__init__()
     from json import loads
     self.plugin_name = os.path.basename(__file__).rsplit('.')[0]
     self.metadata = PluginUtilityService.process_metadata(f'plugins/extensions/{self.plugin_name}')
     self.plugin_cmds = loads(self.metadata.get(C_PLUGIN_INFO, P_PLUGIN_CMDS))
     dir_utils.make_directory(f'{GS.cfg[C_MEDIA_DIR][P_TEMP_MED_DIR]}/{self.plugin_name}/')
     warnings.filterwarnings("ignore", category=UserWarning, module='bs4')
     YH.yt_metadata = self.metadata
     YH.volume = float(self.metadata[C_PLUGIN_SETTINGS][P_YT_DEF_VOL])
     YH.max_queue_size = int(self.metadata[C_PLUGIN_SETTINGS][P_YT_MAX_QUE_LEN])
     YH.max_track_duration = int(self.metadata[C_PLUGIN_SETTINGS][P_YT_MAX_VID_LEN])
     YH.autoplay = self.metadata.getboolean(C_PLUGIN_SETTINGS, P_YT_AUTO_PLAY, fallback=True)
     YH.queue_instance = qh.QueueHandler(YH.max_queue_size)
     rprint(
         f"{self.metadata[C_PLUGIN_INFO][P_PLUGIN_NAME]} v{self.metadata[C_PLUGIN_INFO][P_PLUGIN_VERS]} Plugin Initialized.")
Exemple #24
0
def initialize_web():
    ws = websockets.serve(
        send_message,
        global_settings.cfg[C_WEB_SETTINGS][P_WEB_IP],
        int(global_settings.cfg[C_WEB_SETTINGS][P_WEB_SOCK_PORT]),
        origins=None)
    asyncio.get_event_loop().run_until_complete(ws)
    global_settings.socket_server = Thread(
        target=asyncio.get_event_loop().run_forever, daemon=True)
    global_settings.socket_server.start()
    rprint("Initialized Socket Server.", origin=L_WEB_INTERFACE)
    log(INFO, "Initialized Socket Server", origin=L_WEB_INTERFACE)

    global_settings.flask_server = Thread(target=start_flask_server,
                                          daemon=True)
    global_settings.flask_server.start()
    rprint("Initialized Flask Server.", origin=L_WEB_INTERFACE)
    log(INFO, "Initialized Flask Server", origin=L_WEB_INTERFACE)
Exemple #25
0
 def __init__(self):
     from json import loads
     super().__init__()
     self.plugin_name = os.path.basename(__file__).rsplit('.')[0]
     self.metadata = PluginUtilityService.process_metadata(
         f'plugins/extensions/{self.plugin_name}')
     self.plugin_cmds = loads(
         self.metadata.get(C_PLUGIN_INFO, P_PLUGIN_CMDS))
     dir_utils.make_directory(
         f'{GS.cfg[C_MEDIA_DIR][P_PERM_MEDIA_DIR]}/{self.plugin_name}/')
     dir_utils.make_directory(
         f'{GS.cfg[C_MEDIA_DIR][P_TEMP_MED_DIR]}/{self.plugin_name}/')
     tts_settings.tts_metadata = self.metadata
     tts_settings.voice_list = loads(
         self.metadata.get(C_PLUGIN_SETTINGS, P_TTS_ALL_VOICE))
     rprint(
         f"{self.metadata[C_PLUGIN_INFO][P_PLUGIN_NAME]} v{self.metadata[C_PLUGIN_INFO][P_PLUGIN_VERS]} Plugin Initialized."
     )
Exemple #26
0
 def __init__(self):
     super().__init__()
     from json import loads
     self.plugin_name = os.path.basename(__file__).rsplit('.')[0]
     self.metadata = PluginUtilityService.process_metadata(
         f'plugins/extensions/{self.plugin_name}')
     self.plugin_cmds = loads(
         self.metadata.get(C_PLUGIN_INFO, P_PLUGIN_CMDS))
     dir_utils.make_directory(
         f'{gs.cfg[C_MEDIA_SETTINGS][P_TEMP_MED_DIR]}/{self.plugin_name}/')
     dir_utils.clear_directory(
         f'{dir_utils.get_temp_med_dir()}/{self.plugin_name}')
     warnings.filterwarnings("ignore", category=UserWarning, module='bs4')
     md_settings.youtube_metadata = self.metadata
     md_settings.plugin_name = self.plugin_name
     self.register_callbacks()
     rprint(
         f"{self.metadata[C_PLUGIN_INFO][P_PLUGIN_NAME]} v{self.metadata[C_PLUGIN_INFO][P_PLUGIN_VERS]} Plugin Initialized."
     )
Exemple #27
0
 def cmd_post(self, data):
     all_data = data.message.strip().split(' ', 1)
     img_url = all_data[1]
     # Download image
     img_url = BeautifulSoup(img_url, 'html.parser').get_text()
     try:
         IH.download_image_stream(img_url)
     except exceptions.HTTPError:
         gs.gui_service.quick_gui(
             "Encountered an HTTP Error while trying to retrieve the image.",
             text_type='header',
             text_align='left',
             box_align='left')
         return
     except exceptions.InvalidSchema:
         gs.gui_service.quick_gui(
             "Encountered an Invalid Schema Error while trying to retrieve the image.",
             text_type='header',
             text_align='left',
             box_align='left')
         return
     except exceptions.RequestException:
         gs.gui_service.quick_gui(
             "Encountered a Request Error while trying to retrieve the image.",
             text_type='header',
             text_align='left',
             box_align='left')
         return
     img_ext = img_url.rsplit('.', 1)[1]
     formatted_string = IH.format_image(
         "_image", img_ext,
         f'{dir_utils.get_temp_med_dir()}/internal/images')
     rprint("Posting an image to the mumble channel chat.")
     # Display image with PGUI system
     gs.gui_service.quick_gui_img(
         f"{dir_utils.get_temp_med_dir()}/internal/images",
         formatted_string,
         bgcolor=self.metadata[C_PLUGIN_SETTINGS][P_FRAME_COL],
         cellspacing=self.metadata[C_PLUGIN_SETTINGS][P_FRAME_SIZE],
         format_img=False)
     log(INFO,
         f"Posted an image to the mumble channel chat from: {img_url}.")
def skipto(skip_val):
    if GS.audio_inst is not None:
        if not GS.audio_dni[0]:
            GS.audio_dni = (True, YoutubeHelper.yt_metadata[C_PLUGIN_INFO][P_PLUGIN_NAME])
        else:
            if GS.audio_dni[1] != YoutubeHelper.yt_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 YoutubeHelper.queue_instance.is_empty():
            GS.gui_service.quick_gui(
                "The youtube queue is empty, so I can't skip tracks.",
                text_type='header',
                box_align='left')
            return
        if skip_val > YoutubeHelper.queue_instance.size() - 1:
            GS.gui_service.quick_gui(
                f"You can't skip beyond the length of the current queue.",
                text_type='header',
                box_align='left')
            return
        if skip_val < 1:
            next_track()
            return
        GS.gui_service.quick_gui(
            f"Skipping to track {skip_val} in the queue.",
            text_type='header',
            box_align='left')
        for i in range(skip_val):
            YoutubeHelper.queue_instance.pop()

        GS.log_service.info("The youtube audio queue skipped tracks.")
        dir_utils.clear_directory(f'{dir_utils.get_temp_med_dir()}/youtube')
        stop_audio()
        GS.audio_dni = (True, YoutubeHelper.yt_metadata[C_PLUGIN_INFO][P_PLUGIN_NAME])
        download_next()
        play_audio()
        return
 def cmd_echo(self, data):
     split_data = data.message.strip().split(' ', 1)
     if len(split_data) != 2:
         rprint(
             f"Incorrect format! Format: {rutils.get_command_token()}echo 'message'"
         )
         gs.gui_service.quick_gui(
             f"Incorrect format! Format: {rutils.get_command_token()}echo 'message'",
             text_type='header',
             box_align='left',
             user=gs.mumble_inst.users[data.actor]['name'],
             ignore_whisper=True)
         return
     to_echo = split_data[1]
     gs.gui_service.quick_gui(to_echo,
                              text_type='header',
                              box_align='left',
                              ignore_whisper=True)
     dprint(f"Echo:[{to_echo}]", origin=L_COMMAND)
     log(INFO, f"Echo:[{to_echo}]", origin=L_COMMAND)
Exemple #30
0
 def __init__(self):
     super().__init__()
     from json import loads
     self.plugin_name = path.basename(__file__).rsplit('.')[0]
     self.metadata = PluginUtilityService.process_metadata(
         f'plugins/extensions/{self.plugin_name}')
     self.plugin_cmds = loads(
         self.metadata.get(C_PLUGIN_INFO, P_PLUGIN_CMDS))
     dir_utils.make_directory(
         f'{gs.cfg[C_MEDIA_SETTINGS][P_PERM_MEDIA_DIR]}/{self.plugin_name}/'
     )
     dir_utils.make_directory(
         f'{gs.cfg[C_MEDIA_SETTINGS][P_TEMP_MED_DIR]}/{self.plugin_name}/')
     st_settings.server_tools_metadata = self.metadata
     st_settings.plugin_name = self.plugin_name
     if not st_utility.create_empty_user_connections():
         self.quit()
     self.register_callbacks()
     rprint(
         f"{self.metadata[C_PLUGIN_INFO][P_PLUGIN_NAME]} v{self.metadata[C_PLUGIN_INFO][P_PLUGIN_VERS]} Plugin Initialized."
     )