protected override void execute(User source, string destination, string[] tokens) { // =acc id user if (tokens.Length < 2) { EyeInTheSkyBot.IrcFreenode.ircNotice(source.nickname, "More params pls!"); return; } string id = GlobalFunctions.popFromFront(ref tokens); string user = string.Join(" ", tokens); var s = new ComplexStalk( "acc" + id ); OrNode or = new OrNode(); OrNode uor = new OrNode(); UserStalkNode usn = new UserStalkNode(); usn.setMatchExpression(user); PageStalkNode psn = new PageStalkNode(); psn.setMatchExpression(user); uor.LeftChildNode = usn; uor.RightChildNode = psn; OrNode upor = new OrNode(); PageStalkNode upsn = new PageStalkNode(); upsn.setMatchExpression("User:"******"User talk:" + user); upor.LeftChildNode = upsn; upor.RightChildNode = utpsn; SummaryStalkNode ssn = new SummaryStalkNode(); ssn.setMatchExpression(user); OrNode or2 = new OrNode(); or2.LeftChildNode = uor; or2.RightChildNode = upor; or.LeftChildNode = or2; or.RightChildNode = ssn; s.immediatemail = true; s.Description = "ACC " + id + ": " + user; s.mail = false; s.setSearchTree(or, true); s.enabled = true; s.expiryTime = DateTime.Now.AddMonths(3); EyeInTheSkyBot.Config.Stalks.Add("acc" + id, s); EyeInTheSkyBot.Config.save(); EyeInTheSkyBot.IrcFreenode.ircPrivmsg(destination, "Set new stalk " + s.Flag + " with CSL value: " + or); }
protected override void execute(User source, string destination, string[] tokens) { // =quick token type value if (tokens.Length < 3) { EyeInTheSkyBot.IrcFreenode.ircNotice(source.nickname, "More params pls!"); return; } string name = GlobalFunctions.popFromFront(ref tokens); string type = GlobalFunctions.popFromFront(ref tokens); string regex = string.Join(" ", tokens); var s = new ComplexStalk(name); EyeInTheSkyBot.Config.Stalks.Add(name, s); switch (type) { case "user": UserStalkNode usn = new UserStalkNode(); usn.setMatchExpression(regex); s.setSearchTree(usn, true); EyeInTheSkyBot.IrcFreenode.ircPrivmsg(destination, "Set " + type + " for new stalk " + name + " with CSL value: " + usn); break; case "page": PageStalkNode psn = new PageStalkNode(); psn.setMatchExpression(regex); s.setSearchTree(psn, true); EyeInTheSkyBot.IrcFreenode.ircPrivmsg(destination, "Set " + type + " for new stalk " + name + " with CSL value: " + psn); break; case "summary": SummaryStalkNode ssn = new SummaryStalkNode(); ssn.setMatchExpression(regex); s.setSearchTree(ssn, true); EyeInTheSkyBot.IrcFreenode.ircPrivmsg(destination, "Set " + type + " for new stalk " + name + " with CSL value: " + ssn); break; case "xml": string xmlfragment = string.Join(" ", tokens); try { XmlDocument xd = new XmlDocument(); xd.LoadXml(xmlfragment); StalkNode node = StalkNode.newFromXmlFragment(xd.FirstChild); s.setSearchTree(node, true); EyeInTheSkyBot.IrcFreenode.ircPrivmsg(destination, "Set " + type + " for new stalk " + name + " with CSL value: " + node); } catch (XmlException) { EyeInTheSkyBot.IrcFreenode.ircNotice(source.nickname, "XML Error."); } break; default: EyeInTheSkyBot.IrcFreenode.ircNotice(source.nickname, "Unknown stalk type!"); return; } s.enabled = true; EyeInTheSkyBot.Config.save(); }