Exemplo n.º 1
0
        protected override void __evt_PRIVMSG(NetworkPRIVMSGEventArgs args)
        {
            if (Configuration.IgnoredHostmasks.Contains(args.SourceInfo.Host))
            {
                // messages from this user are ignored
                return;
            }

            if (args.ChannelName == null)
            {
                // private message
                // store which instance this message was from so that we can send it using same instance
                lock (Instance.TargetBuffer)
                {
                    if (!Instance.TargetBuffer.ContainsKey(args.SourceInfo.Nick))
                    {
                        Instance.TargetBuffer.Add(args.SourceInfo.Nick, this.instance);
                    }
                    else
                    {
                        Instance.TargetBuffer[args.SourceInfo.Nick] = this.instance;
                    }
                }
                string modules = "";
                bool   respond = !Commands.Trusted(args.Message, args.SourceInfo.Nick, args.SourceInfo.Host);
                if (!respond)
                {
                    modules += "@trusted ";
                }
                foreach (Module module in ExtensionHandler.ExtensionList)
                {
                    if (module.IsWorking)
                    {
                        try
                        {
                            if (module.Hook_OnPrivateFromUser(args.Message, args.SourceInfo))
                            {
                                respond  = false;
                                modules += module.Name + " ";
                            }
                        }
                        catch (Exception fail)
                        {
                            Core.HandleException(fail);
                        }
                    }
                }
                if (respond)
                {
                    IRC.DeliverMessage("Hi, I am a robot, this command was not understood." +
                                       " Please bear in mind that every message you send" +
                                       " to me will be logged for debugging purposes. See" +
                                       " documentation for the bot at http://meta.wikimedia.org/wiki" +
                                       "/wm-bot for explanation of the bot's commands.", args.SourceInfo,
                                       libirc.Defs.Priority.Low);
                    Syslog.Log("Ignoring private message: (" + args.SourceInfo.Nick + ") " + args.Message, false);
                }
                else
                {
                    modules = Core.Trim(modules);
                    Syslog.Log("Private message: (handled by " + modules + " from " + args.SourceInfo.Nick + ") " +
                               args.Message, false);
                }
            }
            else
            {
                if (args.ChannelName == Configuration.System.DebugChan && this.instance != Instance.PrimaryInstance)
                {
                    return;
                }
                if (args.IsAct)
                {
                    Core.GetAction(args.Message, args.ChannelName, args.SourceInfo.Host, args.SourceInfo.Nick);
                    return;
                }
                Core.GetMessage(args.ChannelName, args.SourceInfo.Nick, args.SourceInfo.Host, args.Message);
            }
        }
Exemplo n.º 2
0
 public override void __evt_PRIVMSG(NetworkPRIVMSGEventArgs args)
 {
     if (args.ChannelName == null)
     {
         // private message
         // store which instance this message was from so that we can send it using same instance
         lock(Instance.TargetBuffer)
         {
             if (!Instance.TargetBuffer.ContainsKey(args.SourceInfo.Nick))
             {
                 Instance.TargetBuffer.Add(args.SourceInfo.Nick, this.instance);
             } else
             {
                 Instance.TargetBuffer[args.SourceInfo.Nick] = this.instance;
             }
         }
         bool respond = !Commands.Trusted(args.Message, args.SourceInfo.Nick, args.SourceInfo.Host);
         string modules = "";
         lock(ExtensionHandler.Extensions)
         {
             foreach (Module module in ExtensionHandler.Extensions)
             {
                 if (module.IsWorking)
                 {
                     try
                     {
                         if (module.Hook_OnPrivateFromUser(args.Message, args.SourceInfo))
                         {
                             respond = false;
                             modules += module.Name + " ";
                         }
                     } catch (Exception fail)
                     {
                         Core.HandleException(fail);
                     }
                 }
             }
         }
         if (respond)
         {
             IRC.DeliverMessage("Hi, I am robot, this command was not understood." +
                                  " Please bear in mind that every message you send" +
                                  " to me will be logged for debuging purposes. See" +
                                  " documentation at http://meta.wikimedia.org/wiki" +
                                  "/WM-Bot for explanation of commands", args.SourceInfo,
                                  libirc.Defs.Priority.Low);
             Syslog.Log("Ignoring private message: (" + args.SourceInfo.Nick + ") " + args.Message, false);
         } else
         {
             Syslog.Log("Private message: (handled by " + modules + " from " + args.SourceInfo.Nick + ") " +
                        args.Message, false);
         }
     } else
     {
         if (args.ChannelName == Configuration.System.DebugChan && this.instance != Instance.PrimaryInstance)
             return;
         if (args.IsAct)
         {
             Core.GetAction(args.Message, args.ChannelName, args.SourceInfo.Host, args.SourceInfo.Nick);
             return;
         }
         Core.GetMessage(args.ChannelName, args.SourceInfo.Nick, args.SourceInfo.Host, args.Message);
     }
 }
Exemplo n.º 3
0
 protected internal virtual void __evt_PRIVMSG(NetworkPRIVMSGEventArgs args)
 {
     if (this.On_PRIVMSG != null)
         this.On_PRIVMSG(this, args);
 }