Ejemplo n.º 1
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, INFO_INVALID_WHISPER_CLIENT, origin=L_COMMAND)
                gs.gui_service.quick_gui(INFO_INVALID_WHISPER_CLIENT,
                                         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(
                        "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(
                            "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'])
            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,
                print_mode=PrintMode.VERBOSE_PRINT.value)
        except IndexError:
            log(ERROR,
                CMD_INVALID_REMOVE_WHISPER,
                origin=L_COMMAND,
                error_type=CMD_INVALID_ERR,
                print_mode=PrintMode.VERBOSE_PRINT.value)
            gs.gui_service.quick_gui(CMD_INVALID_ADD_WHISPER,
                                     text_type='header',
                                     box_align='left',
                                     user=data_actor['name'],
                                     ignore_whisper=True)
            return
Ejemplo n.º 2
0
    def cmd_setwhisperusers(self, data):
        all_data = data.message.strip().split()
        data_actor = GS.mumble_inst.users[data.actor]
        try:
            parameter = all_data[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=data_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=data_actor['name'],
                                     ignore_whisper=True)
            GS.log_service.info(f"Added whisper to multiple users!")
        except IndexError:
            GS.gui_service.quick_gui(
                f"Invalid whisper command!<br>Command format: {rutils.get_command_token()}setwhisperusers username0,username1,...",
                text_type='header',
                box_align='left',
                user=data_actor['name'],
                ignore_whisper=True)
            return
Ejemplo n.º 3
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
Ejemplo n.º 4
0
    def cmd_removewhisperuser(self, data):
        all_data = data.message.strip().split(' ', 1)
        data_actor = GS.mumble_inst.users[data.actor]
        try:
            username = all_data[1]
            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/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=data_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 RS.whisper_target['id']:
                    RS.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=data_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=data_actor['name'],
                                         ignore_whisper=True)
                return
            if len(RS.whisper_target['id']) < 1:
                rutils.clear_whisper()
            else:
                rutils.set_whisper_multi_user(RS.whisper_target['id'])

            GS.gui_service.quick_gui(f"Removed user: {username} from the whisper targets.", text_type='header',
                                     box_align='left', user=data_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=data_actor['name'],
                                     ignore_whisper=True)
            return
Ejemplo n.º 5
0
    def cmd_setwhisperusers(self, data):
        all_data = data.message.strip().split(' ', 1)
        data_actor = gs.mumble_inst.users[data.actor]
        try:
            parameter = all_data[1]

            users_list = [
                user.strip() for user in parameter
                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=data_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=data_actor['name'],
                                     ignore_whisper=True)
            log(INFO,
                INFO_ADDED_MULTIPLE_WHISPER,
                origin=L_COMMAND,
                print_mode=PrintMode.VERBOSE_PRINT.value)
        except IndexError:
            log(ERROR,
                CMD_INVALID_SET_WHISPER_USERS,
                origin=L_COMMAND,
                error_type=CMD_INVALID_ERR,
                print_mode=PrintMode.VERBOSE_PRINT.value)
            gs.gui_service.quick_gui(CMD_INVALID_SET_WHISPER_USERS,
                                     text_type='header',
                                     box_align='left',
                                     user=data_actor['name'],
                                     ignore_whisper=True)
            return
Ejemplo n.º 6
0
    def cmd_removewhisperuser(self, data):
        all_data = data.message.strip().split(' ', 1)
        data_actor = gs.mumble_inst.users[data.actor]
        try:
            username = all_data[1]
            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/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=data_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 rs.whisper_target['id']:
                    rs.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=data_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=data_actor['name'],
                    ignore_whisper=True)
                return
            if len(rs.whisper_target['id']) < 1:
                rutils.clear_whisper()
            else:
                rutils.set_whisper_multi_user(rs.whisper_target['id'])

            gs.gui_service.quick_gui(
                f"Removed user: {username} from the whisper targets.",
                text_type='header',
                box_align='left',
                user=data_actor['name'],
                ignore_whisper=True)
            log(INFO,
                f"Removed user: {username} from the whisper targets.",
                origin=L_COMMAND)
        except IndexError:
            log(ERROR,
                CMD_INVALID_REMOVE_WHISPER,
                origin=L_COMMAND,
                error_type=CMD_INVALID_ERR,
                print_mode=PrintMode.VERBOSE_PRINT.value)
            gs.gui_service.quick_gui(CMD_INVALID_REMOVE_WHISPER,
                                     text_type='header',
                                     box_align='left',
                                     user=data_actor['name'],
                                     ignore_whisper=True)
            return
Ejemplo n.º 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)