Ejemplo n.º 1
0
        public void ProcessPrivmsgCommand(IrcMessage message)
        {
            var msgTokens = message.Message.Split(Separator);

            if (RemoveLeadingColon(msgTokens[0]) == ACTION)
            {
                if (Rfc2812Util.IsValidChannelName(message.Target))
                {
                    OnAction.Fire(this, new UserChannelMessageEventArgs(Rfc2812Util.UserFromString(message.From), message.Target,
                                                                        CleanActionMessage(message.Message)));
                    //Trace.WriteLine("Channel action", "IRC");
                }
                else
                {
                    OnPrivateAction.Fire(this,
                                         new UserMessageEventArgs(Rfc2812Util.UserFromString(message.From), CleanActionMessage(message.Message)));
                    //Trace.WriteLine("Private action", "IRC");
                }
            }
            else if (channelPattern.IsMatch(message.Target))
            {
                OnPublic.Fire(this,
                              new UserChannelMessageEventArgs(Rfc2812Util.UserFromString(message.From), message.Target,
                                                              message.Message));
                Trace.WriteLine("Public msg", "IRC");
            }
            else
            {
                OnPrivate.Fire(this, new UserMessageEventArgs(Rfc2812Util.UserFromString(message.From), message.Message));
                //Trace.WriteLine("Private msg", "IRC");
            }
        }
Ejemplo n.º 2
0
 public void ProcessPrivmsgCommand(string[] tokens)
 {
     tokens[3] = RemoveLeadingColon(tokens[3]);
     if (tokens[3] == ACTION)
     {
         if (Rfc2812Util.IsValidChannelName(tokens[2]))
         {
             int last = tokens.Length - 1;
             tokens[last] = RemoveTrailingChar(tokens[last]);
             OnAction.Fire(this,
                           new UserChannelMessageEventArgs(Rfc2812Util.UserFromString(tokens[0]), tokens[2],
                                                           CondenseStrings(tokens, 4)));
             //Trace.WriteLine("Channel action", "IRC");
         }
         else
         {
             int last = tokens.Length - 1;
             tokens[last] = RemoveTrailingChar(tokens[last]);
             OnPrivateAction.Fire(this,
                                  new UserMessageEventArgs(Rfc2812Util.UserFromString(tokens[0]), CondenseStrings(tokens, 4)));
             //Trace.WriteLine("Private action", "IRC");
         }
     }
     else if (channelPattern.IsMatch(tokens[2]))
     {
         OnPublic.Fire(this,
                       new UserChannelMessageEventArgs(Rfc2812Util.UserFromString(tokens[0]), tokens[2],
                                                       CondenseStrings(tokens, 3)));
         Trace.WriteLine("Public msg", "IRC");
     }
     else
     {
         OnPrivate.Fire(this, new UserMessageEventArgs(Rfc2812Util.UserFromString(tokens[0]), CondenseStrings(tokens, 3)));
         //Trace.WriteLine("Private msg", "IRC");
     }
 }