Example #1
0
 def initialize_mumble(md: MumbleData):
     global_settings.mumble_inst = pymumble.Mumble(
         md.ip_address,
         port=md.port,
         user=md.user_id,
         reconnect=md.auto_reconnect,
         password=md.password,
         certfile=md.certificate,
         stereo=md.stereo)
     global_settings.mumble_inst.callbacks.set_callback(
         'text_received', BotService.message_received)
     global_settings.mumble_inst.callbacks.set_callback(
         'sound_received', BotService.sound_received)
     global_settings.mumble_inst.callbacks.set_callback(
         'connected', BotService.on_connected)
     global_settings.mumble_inst.set_codec_profile('audio')
     global_settings.mumble_inst.set_receive_sound(True)
     global_settings.mumble_inst.start()
     global_settings.mumble_inst.is_ready()
     if global_settings.cfg.getboolean(C_CONNECTION_SETTINGS,
                                       P_SELF_REGISTER):
         global_settings.mumble_inst.users.myself.register()
     global_settings.mumble_inst.users.myself.comment(
         f'{runtime_utils.get_comment()}<br>[{META_NAME}({META_VERSION})] - {runtime_utils.get_bot_name()}<br>{runtime_utils.get_about()}'
     )
     runtime_utils.mute()
     runtime_utils.get_channel(global_settings.cfg[C_CONNECTION_SETTINGS]
                               [P_CHANNEL_DEF]).move_in()
Example #2
0
    def initialize_mumble(self, md: MumbleData):
        global_settings.mumble_inst = pymumble.Mumble(md.ip_address, port=md.port, user=md.user_id,
                                                      reconnect=md.auto_reconnect,
                                                      password=md.password, certfile=md.certificate, stereo=md.stereo)
        # Callback - message_received
        global_settings.mumble_inst.callbacks.set_callback(PYMUMBLE_CLBK_TEXTMESSAGERECEIVED,
                                                           global_settings.clbk_service.message_received)
        global_settings.core_callbacks.append_to_callback(PYMUMBLE_CLBK_TEXTMESSAGERECEIVED, self.message_received)
        # Callback - sound_received
        global_settings.mumble_inst.callbacks.set_callback(PYMUMBLE_CLBK_SOUNDRECEIVED,
                                                           global_settings.clbk_service.sound_received)
        global_settings.core_callbacks.append_to_callback(PYMUMBLE_CLBK_SOUNDRECEIVED, self.sound_received)
        # Callback - on_connected
        global_settings.mumble_inst.callbacks.set_callback(PYMUMBLE_CLBK_CONNECTED,
                                                           global_settings.clbk_service.connected)
        global_settings.core_callbacks.append_to_callback(PYMUMBLE_CLBK_CONNECTED, self.on_connected)
        # Callback - disconnected
        global_settings.mumble_inst.callbacks.set_callback(PYMUMBLE_CLBK_DISCONNECTED,
                                                           global_settings.clbk_service.disconnected)
        global_settings.core_callbacks.append_to_callback(PYMUMBLE_CLBK_DISCONNECTED, self.on_disconnected)
        # Callback - user_created
        global_settings.mumble_inst.callbacks.set_callback(PYMUMBLE_CLBK_USERCREATED,
                                                           global_settings.clbk_service.user_created)
        # Callback - user_updated
        global_settings.mumble_inst.callbacks.set_callback(PYMUMBLE_CLBK_USERUPDATED,
                                                           global_settings.clbk_service.user_updated)
        # Callback - user_removed
        global_settings.mumble_inst.callbacks.set_callback(PYMUMBLE_CLBK_USERREMOVED,
                                                           global_settings.clbk_service.user_removed)
        # Callback - channel_created
        global_settings.mumble_inst.callbacks.set_callback(PYMUMBLE_CLBK_CHANNELCREATED,
                                                           global_settings.clbk_service.channel_created)
        # Callback - channel_removed
        global_settings.mumble_inst.callbacks.set_callback(PYMUMBLE_CLBK_CHANNELREMOVED,
                                                           global_settings.clbk_service.channel_removed)
        # Callback - channel_updated
        global_settings.mumble_inst.callbacks.set_callback(PYMUMBLE_CLBK_CHANNELUPDATED,
                                                           global_settings.clbk_service.channel_updated)
        # Callback - permission_denied
        global_settings.mumble_inst.callbacks.set_callback(PYMUMBLE_CLBK_PERMISSIONDENIED,
                                                           global_settings.clbk_service.permission_denied)

        global_settings.mumble_inst.set_codec_profile('audio')
        global_settings.mumble_inst.set_receive_sound(True)

        try:
            global_settings.mumble_inst.start()
            global_settings.mumble_inst.is_ready()

            if global_settings.cfg.getboolean(C_CONNECTION_SETTINGS, P_SELF_REGISTER, fallback=False):
                global_settings.mumble_inst.users.myself.register()
            global_settings.mumble_inst.users.myself.comment(
                f'{runtime_utils.get_comment()}<br>[{META_NAME}({META_VERSION})] - {runtime_utils.get_bot_name()}<br>{runtime_utils.get_about()}')
            runtime_utils.mute()
            runtime_utils.get_channel(global_settings.cfg[C_CONNECTION_SETTINGS][P_DEFAULT_CHANNEL]).move_in()
        except ConnectionRejectedError as e:
            log(CRITICAL, f"The connection to the server was rejected! {e}",
                origin=L_STARTUP, print_mode=PrintMode.REG_PRINT.value)
            return
    def initialize_mumble(self, md: MumbleData):
        global_settings.mumble_inst = pymumble.Mumble(md.ip_address, port=md.port, user=md.user_id,
                                                      reconnect=md.auto_reconnect,
                                                      password=md.password, certfile=md.certificate, stereo=md.stereo)
        # Callback - message_received
        global_settings.mumble_inst.callbacks.set_callback(PYMUMBLE_CLBK_TEXTMESSAGERECEIVED,
                                                           global_settings.clbk_service.message_received)
        global_settings.core_callbacks.append_to_callback(PYMUMBLE_CLBK_TEXTMESSAGERECEIVED, self.message_received)
        # Callback - sound_received
        global_settings.mumble_inst.callbacks.set_callback(PYMUMBLE_CLBK_SOUNDRECEIVED,
                                                           global_settings.clbk_service.sound_received)
        global_settings.core_callbacks.append_to_callback(PYMUMBLE_CLBK_SOUNDRECEIVED, self.sound_received)
        # Callback - on_connected
        global_settings.mumble_inst.callbacks.set_callback(PYMUMBLE_CLBK_CONNECTED,
                                                           global_settings.clbk_service.connected)
        global_settings.core_callbacks.append_to_callback(PYMUMBLE_CLBK_CONNECTED, self.on_connected)
        # Callback - disconnected
        global_settings.mumble_inst.callbacks.set_callback(PYMUMBLE_CLBK_DISCONNECTED,
                                                           global_settings.clbk_service.disconnected)
        # Callback - user_created
        global_settings.mumble_inst.callbacks.set_callback(PYMUMBLE_CLBK_USERCREATED,
                                                           global_settings.clbk_service.user_created)
        # Callback - user_updated
        global_settings.mumble_inst.callbacks.set_callback(PYMUMBLE_CLBK_USERUPDATED,
                                                           global_settings.clbk_service.user_updated)
        # Callback - user_removed
        global_settings.mumble_inst.callbacks.set_callback(PYMUMBLE_CLBK_USERREMOVED,
                                                           global_settings.clbk_service.user_removed)
        # Callback - channel_created
        global_settings.mumble_inst.callbacks.set_callback(PYMUMBLE_CLBK_CHANNELCREATED,
                                                           global_settings.clbk_service.channel_created)
        # Callback - channel_removed
        global_settings.mumble_inst.callbacks.set_callback(PYMUMBLE_CLBK_CHANNELREMOVED,
                                                           global_settings.clbk_service.channel_removed)
        # Callback - channel_updated
        global_settings.mumble_inst.callbacks.set_callback(PYMUMBLE_CLBK_CHANNELUPDATED,
                                                           global_settings.clbk_service.channel_updated)

        global_settings.mumble_inst.set_codec_profile('audio')
        global_settings.mumble_inst.set_receive_sound(True)
        global_settings.mumble_inst.start()
        global_settings.mumble_inst.is_ready()

        if global_settings.cfg.getboolean(C_CONNECTION_SETTINGS, P_SELF_REGISTER, fallback=False):
            global_settings.mumble_inst.users.myself.register()
        global_settings.mumble_inst.users.myself.comment(
            f'{runtime_utils.get_comment()}<br>[{META_NAME}({META_VERSION})] - {runtime_utils.get_bot_name()}<br>{runtime_utils.get_about()}')
        runtime_utils.mute()
        runtime_utils.get_channel(global_settings.cfg[C_CONNECTION_SETTINGS][P_DEFAULT_CHANNEL]).move_in()
Example #4
0
 async def mute_user(self, command: StdModel):
     if len(command.text) > 0:
         if not rutils.mute(username=command.text.strip()):
             rutils.unmute(username=command.text.strip())
         return ResponseModel(200, "success").toDict()
     return ResponseModel(
         400, "error", {
             "error_message":
             f"Please be sure to provide the username of a valid user in the "
             f"server and make sure the bot has adequate permissions."
         })
Example #5
0
 def cmd_muteuser(self, data):
     split_data = data.message.strip().split(' ', 1)
     if len(split_data) != 2:
         log(ERROR,
             CMD_INVALID_MUTE_USER,
             origin=L_COMMAND,
             error_type=CMD_INVALID_ERR,
             print_mode=PrintMode.VERBOSE_PRINT.value)
         gs.gui_service.quick_gui(
             CMD_INVALID_MUTE_USER,
             text_type='header',
             box_align='left',
             user=gs.mumble_inst.users[data.actor]['name'],
             ignore_whisper=True)
         return
     to_mute = split_data[1].strip()
     if rutils.mute(username=to_mute):
         gs.gui_service.quick_gui(
             f"Muted user:[{to_mute}]",
             text_type='header',
             box_align='left',
             user=gs.mumble_inst.users[data.actor]['name'],
             ignore_whisper=True)