Ejemplo n.º 1
0
        public void FilterChat()
        {
            bool done = false;

            while (!done)
            {
                ChatMessageEventArgs message = PopInboundChat();
                if (message == null)
                {
                    done = true;
                }
                else
                {
                    if (DefaultFilter != null)
                    {
                        message.Filtered = DefaultFilter(message);
                    }

                    MessageFilter?.Invoke(this, message);

                    DispatchChatMessage(message);
                }
            }

            lock (PendingInboundChats)
                FilterWorker = null;
        }
 public bool PassesFilter(IMessage message)
 {
     try
     {
         return(MessageFilter?.Invoke(message) ?? true);
     }
     catch (Exception ex)
     {
         var logger = Plugin?.GetLogger();
         logger?.Error($"Encountered an error while checking if a message with label {message?.Label ?? "<Blank>"} ({ex.Message})");
         logger?.Debug(ex);
         return(false);
     }
 }
        public bool ShouldAttemptDelivery(IMapleMessage message)
        {
            if (message == null)
            {
                return(false);
            }

            if (!(typeof(TMessage).IsAssignableFrom(message.GetType())))
            {
                return(false);
            }

            return(MessageFilter.Invoke(message as TMessage));
        }