Ejemplo n.º 1
0
        internal static StalkLogItem newFromXmlElement(XmlElement element)
        {
            StalkLogItem sli = new StalkLogItem
                                   {
                                       stalk = element.GetAttribute("stalkflag"),
                                       ts = DateTime.Parse(element.GetAttribute("timestamp"))
                                   };

            string user, page, url, summary, flags, sizediff;
            user = page = url = summary = flags = "";
            sizediff = "0";
            foreach (XmlNode childNode in element.ChildNodes)
            {
                XmlElement ce = (XmlElement) childNode;
                if (ce.Name == "user")
                    user = ce.GetAttribute("value");
                if (ce.Name == "page")
                    page = ce.GetAttribute("value");
                if (ce.Name == "url")
                    url = ce.GetAttribute("value");
                if (ce.Name == "summary")
                    summary = ce.GetAttribute("value");
                if (ce.Name == "flags")
                    flags = ce.GetAttribute("value");
                if (ce.Name == "sizediff")
                    sizediff = ce.GetAttribute("value");

            }

            RecentChange rc = new RecentChange(page, user, url, summary, flags, int.Parse(sizediff));
            sli.rc = rc;
            return sli;
        }
Ejemplo n.º 2
0
 public abstract bool match(RecentChange rc);
Ejemplo n.º 3
0
 public StalkLogItem(string flag, RecentChange rcitem)
 {
     stalk = flag;
     rc = rcitem;
     ts = DateTime.Now;
 }
Ejemplo n.º 4
0
        public static RecentChange parse(string data)
        {
            Match m = getRegex().Match(data);
            if (m.Success == false)
                throw new FormatException();

            RecentChange rc = new RecentChange
                                  {
                                      user = m.Groups["user"].Value,
                                      url = m.Groups["url"].Value,
                                      flag = m.Groups["flag"].Value,
                                      title = m.Groups["title"].Value
                                  };

            string comment = m.Groups["comment"].Value;
            if (getColourRegex().Match(comment).Success)
                comment = getColourRegex().Replace(comment, "");
            rc.comment = comment;

            try
            {
                rc.szdiff = m.Groups["szdiff"].Value == "" ? 0 : int.Parse(m.Groups["szdiff"].Value.Trim(''));
            }
            catch(FormatException)
            {
                rc.szdiff = 0;
            }

            return rc;
        }
Ejemplo n.º 5
0
        public override bool match(RecentChange rc)
        {
            if (!isActive())
                return false;

            bool success = _baseNode.match(rc);
            if(success)
            {
                LastTriggerTime = DateTime.Now;

                if (mail && bool.Parse(EyeInTheSkyBot.Config["logstalks"]))
                    EyeInTheSkyBot.Config.LogStalkTrigger(flag, rc);

                if (immediatemail)
                    immediateMail(rc);

                return true;
            }
            return false;
        }
Ejemplo n.º 6
0
        public void immediateMail(RecentChange rc)
        {
            string arg1 = Flag;
            string arg2 = rc.Page;
            string arg3 = rc.User;
            string arg4 = rc.EditSummary;
            string arg5 = rc.Url;
            string arg6 = DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToLongTimeString();
            string arg7 = Description;
            string arg8 = _baseNode.ToString();
            string arg9 = rc.EditFlags;

            string template = new StreamReader("Templates/individual.txt").ReadToEnd();
            template = template
                .Replace("$1", arg1)
                .Replace("$2", arg2)
                .Replace("$3", arg3)
                .Replace("$4", arg4)
                .Replace("$5", arg5)
                .Replace("$6", arg6)
                .Replace("$7", arg7)
                .Replace("$8", arg8)
                .Replace("$9", arg9)
                ;

            var mailMessage = new MailMessage
                                   {
                                       From = new MailAddress("*****@*****.**"),
                                       Subject = "[EyeInTheSky] '" + Flag + "' notification",
                                       Body = template
                                   };

            mailMessage.To.Add("*****@*****.**");

            var client = new SmtpClient("mail.srv.stwalkerster.net");

            client.Send(mailMessage);
        }
Ejemplo n.º 7
0
 public void LogStalkTrigger(string s, RecentChange rc)
 {
     StalkLogItem sli = new StalkLogItem(s,rc);
     stalklog.Add(sli);
     this.save();
 }