Esempio n. 1
0
        public JSPM(ObjectInstance prototype, IPrivateMsg pm)
            : base(prototype.Engine, ((ClrFunction)prototype.Engine.Global["PM"]).InstancePrototype)
        {
            this._PM = pm;
            this.PopulateFunctions();

            DefineProperty(Engine.Symbol.ToStringTag, new PropertyDescriptor("PM", PropertyAttributes.Sealed), true);
        }
        public static void FilterPM(IUser client, IPrivateMsg msg)
        {
            String ip = client.ExternalIP.ToString();

            foreach (Item item in list)
            {
                if (msg.Contains(item.Trigger))
                {
                    switch (item.Type)
                    {
                    case FilterType.Ban:
                        if (client.Level == ILevel.Regular)
                        {
                            if (!client.Link.IsLinked)
                            {
                                Server.Print(Template.Text(Category.Filter, 16).Replace("+n", client.Name).Replace("+ip", ip), true);
                                client.Ban();
                            }

                            msg.Cancel = true;
                            return;
                        }
                        break;

                    case FilterType.Kill:
                        if (client.Level == ILevel.Regular)
                        {
                            if (!client.Link.IsLinked)
                            {
                                Server.Print(Template.Text(Category.Filter, 15).Replace("+n", client.Name).Replace("+ip", ip), true);
                                client.Disconnect();
                            }

                            msg.Cancel = true;
                            return;
                        }
                        break;

                    case FilterType.Redirect:
                        if (client.Level == ILevel.Regular)
                        {
                            if (!client.Link.IsLinked)
                            {
                                Server.Print(Template.Text(Category.Filter, 17).Replace("+n", client.Name).Replace("+ip", ip), true);
                                client.Redirect(item.Args);
                            }

                            msg.Cancel = true;
                            return;
                        }
                        break;
                    }
                }
            }
        }
Esempio n. 3
0
 public JSPM(ObjectInstance prototype, IPrivateMsg pm)
     : base(prototype.Engine, ((ClrFunction)prototype.Engine.Global["PM"]).InstancePrototype)
 {
     this._PM = pm;
     this.PopulateFunctions();
 }
Esempio n. 4
0
        public static void FilterPM(IUser client, IPrivateMsg msg)
        {
            String ip = client.ExternalIP.ToString();

            foreach (Item item in list)
            {
                string trigger = Regex.Escape(item.Trigger);
                trigger = trigger.Replace("\\?", ".").Replace("\\*", ".*");
                Regex regex = new Regex(trigger, RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace);

                if (regex.IsMatch(item.Trigger))
                {
                    switch (item.Type)
                    {
                    case FilterType.Ban:
                        if (client.Level == ILevel.Regular)
                        {
                            if (!client.Link.IsLinked)
                            {
                                Server.Print(
                                    Template.Text(Category.Filter, 16).Replace("+n", client.Name).Replace("+ip", ip),
                                    true);
                                LogSend.Log(LOGFILE, $"{client.Name} banned for typing {item.Trigger} in PM");
                                client.Ban();
                            }

                            msg.Cancel = true;
                            return;
                        }
                        break;

                    case FilterType.Kill:
                        if (client.Level == ILevel.Regular)
                        {
                            if (!client.Link.IsLinked)
                            {
                                Server.Print(
                                    Template.Text(Category.Filter, 15).Replace("+n", client.Name).Replace("+ip", ip),
                                    true);
                                LogSend.Log(LOGFILE, $"{client.Name} killed for typing {item.Trigger} in PM");
                                client.Disconnect();
                            }

                            msg.Cancel = true;
                            return;
                        }
                        break;

                    case FilterType.Redirect:
                        if (client.Level == ILevel.Regular)
                        {
                            if (!client.Link.IsLinked)
                            {
                                Server.Print(
                                    Template.Text(Category.Filter, 17).Replace("+n", client.Name).Replace("+ip", ip),
                                    true);
                                LogSend.Log(LOGFILE, $"{client.Name} redirected for typing {item.Trigger} in PM");
                                client.Redirect(item.Args);
                            }

                            msg.Cancel = true;
                            return;
                        }
                        break;
                    }
                }
            }
        }