コード例 #1
0
 def _pre_user_message_begin(args):
     try:
         # Replace original recipients filter
         tmp_recipients = make_object(BaseRecipientFilter, args[1])
     except RuntimeError:
         # Patch for issue #314
         tmp_recipients = RecipientFilter.from_abstract_pointer(args[1])
     _recipients.update(*tuple(tmp_recipients), clear=True)
     args[1] = _recipients
コード例 #2
0
def pre_playback_temp_entity(stack_data):
    """Handle pre hooks."""
    temp_entity = TempEntity(stack_data[3])
    try:
        recipients = make_object(RecipientFilter, stack_data[1])
    except RuntimeError:
        global _recipients
        _recipients = RecipientFilter.from_abstract_pointer(stack_data[1])
        stack_data[1] = recipients = _recipients
    return temp_entity.template.handle_hook(temp_entity, recipients)
コード例 #3
0
    def _pre_send_user_message(args):
        message_index = args[2]

        user_message_hooks = HookUserMessage.hooks[message_index]
        protobuf_user_message_hooks = HookProtobufUserMessage.hooks[
            message_index]

        # No need to do anything behind this if no listener is registered
        if not user_message_hooks and not protobuf_user_message_hooks:
            return

        try:
            # Replace original recipients filter
            tmp_recipients = make_object(BaseRecipientFilter, args[1])
        except RuntimeError:
            # Patch for issue #314
            tmp_recipients = RecipientFilter.from_abstract_pointer(args[1])
        _recipients.update(*tuple(tmp_recipients), clear=True)
        args[1] = _recipients

        try:
            buffer = make_object(ProtobufMessage, args[3])
            wrapped_from_abstract = False
        except RuntimeError:
            # Patch for issue #390 - UserMessage was created by another plugin.
            buffer = ProtobufMessage.from_abstract_pointer(args[3])
            wrapped_from_abstract = True

        protobuf_user_message_hooks.notify(_recipients, buffer)

        # No need to do anything behind this if no listener is registered
        if user_message_hooks:
            try:
                impl = get_user_message_impl(message_index)
            except NotImplementedError:
                impl = None

            if impl is not None:
                data = impl.read(buffer)
                user_message_hooks.notify(_recipients, data)

                # Update buffer if data has been changed
                if data.has_been_changed():
                    buffer.clear()
                    impl.write(buffer, data)

        # If we wrapped the buffer from an abstract pointer, make sure to
        #   apply any changes that may have been made back into the original.
        if wrapped_from_abstract:
            buffer.parse_to_abstract_pointer(args[3])