public override bool Hook_OnRegister() { RecentChanges.InsertSite(); lock (config.channels) { foreach (config.channel channel in config.channels) { channel.RegisterObject(new RecentChanges(channel), "RC"); } } return(true); }
public override string Extension_DumpHtml(config.channel channel) { string HTML = ""; if (GetConfig(channel, "RC.Enabled", false)) { RecentChanges rc = (RecentChanges)channel.RetrieveObject("RC"); if (rc != null) { HTML = rc.ToTable(); } } return(HTML); }
public override void Hook_PRIV(config.channel channel, User invoker, string message) { if (message.StartsWith(config.CommandPrefix + "RC-")) { if (channel.Users.IsApproved(invoker, "trust")) { if (GetConfig(channel, "RC.Enabled", false)) { string[] a = message.Split(' '); if (a.Length < 3) { core.irc._SlowQueue.DeliverMessage(messages.get("Feed8", channel.Language, new List <string> { invoker.Nick }), channel.Name); return; } string wiki = a[1]; string Page = a[2]; RecentChanges rc = (RecentChanges)channel.RetrieveObject("RC"); if (rc != null) { rc.removeString(wiki, Page); } return; } else { core.irc._SlowQueue.DeliverMessage(messages.get("Feed3", channel.Language), channel.Name); return; } } if (!channel.suppress_warnings) { core.irc._SlowQueue.DeliverMessage(messages.get("PermissionDenied", channel.Language), channel.Name, IRC.priority.low); } return; } if (message.StartsWith(config.CommandPrefix + "recentchanges- ")) { if (channel.Users.IsApproved(invoker, "root")) { if (GetConfig(channel, "RC.Enabled", false)) { if (!message.Contains(" ")) { if (!channel.suppress_warnings) { core.irc._SlowQueue.DeliverMessage(messages.get("InvalidWiki", channel.Language), channel.Name); } return; } string _channel = message.Substring(message.IndexOf(" ") + 1); if (RecentChanges.DeleteChannel(channel, _channel)) { core.irc._SlowQueue.DeliverMessage(messages.get("Wiki-", channel.Language), channel.Name, IRC.priority.high); } return; } else { core.irc._SlowQueue.DeliverMessage(messages.get("Feed3", channel.Language), channel.Name); return; } } if (!channel.suppress_warnings) { core.irc._SlowQueue.DeliverMessage(messages.get("PermissionDenied", channel.Language), channel.Name, IRC.priority.low); } return; } if (message.StartsWith(config.CommandPrefix + "RC+ ")) { if (channel.Users.IsApproved(invoker, "trust")) { if (GetConfig(channel, "RC.Enabled", false)) { string[] a = message.Split(' '); if (a.Length < 3) { core.irc._SlowQueue.DeliverMessage(messages.get("Feed4", channel.Language) + invoker.Nick + messages.get("Feed5", channel.Language), channel.Name); return; } string wiki = a[1]; string Page = a[2]; RecentChanges rc = (RecentChanges)channel.RetrieveObject("RC"); if (rc != null) { rc.insertString(wiki, Page); } return; } else { core.irc._SlowQueue.DeliverMessage(messages.get("Feed3", channel.Language), channel.Name); return; } } if (!channel.suppress_warnings) { core.irc._SlowQueue.DeliverMessage(messages.get("PermissionDenied", channel.Language), channel.Name, IRC.priority.low); } return; } if (message == config.CommandPrefix + "recentchanges-off") { if (channel.Users.IsApproved(invoker, "admin")) { if (!GetConfig(channel, "RC.Enabled", false)) { core.irc._SlowQueue.DeliverMessage(messages.get("Feed6", channel.Language), channel.Name); return; } else { core.irc._SlowQueue.DeliverMessage(messages.get("Feed7", channel.Language), channel.Name); SetConfig(channel, "RC.Enabled", false); channel.SaveConfig(); return; } } if (!channel.suppress_warnings) { core.irc._SlowQueue.DeliverMessage(messages.get("PermissionDenied", channel.Language), channel.Name, IRC.priority.low); } return; } if (message == config.CommandPrefix + "recentchanges-on") { if (channel.Users.IsApproved(invoker, "recentchanges-manage")) { if (GetConfig(channel, "RC.Enabled", false)) { core.irc._SlowQueue.DeliverMessage(messages.get("Feed1", channel.Language), channel.Name); return; } else { core.irc._SlowQueue.DeliverMessage(messages.get("Feed2", channel.Language), channel.Name); SetConfig(channel, "RC.Enabled", true); channel.SaveConfig(); config.Save(); return; } } if (!channel.suppress_warnings) { core.irc._SlowQueue.DeliverMessage(messages.get("PermissionDenied", channel.Language), channel.Name, IRC.priority.low); } return; } if (message.StartsWith(config.CommandPrefix + "recentchanges+")) { if (channel.Users.IsApproved(invoker, "recentchanges-manage")) { if (GetConfig(channel, "RC.Enabled", false)) { if (!message.Contains(" ")) { if (!channel.suppress_warnings) { core.irc._SlowQueue.DeliverMessage(messages.get("InvalidWiki", channel.Language), channel.Name); } return; } string _channel = message.Substring(message.IndexOf(" ") + 1); if (RecentChanges.InsertChannel(channel, _channel)) { core.irc._SlowQueue.DeliverMessage(messages.get("Wiki+", channel.Language), channel.Name); } return; } else { core.irc._SlowQueue.DeliverMessage(messages.get("Feed3", channel.Language), channel.Name); return; } } if (!channel.suppress_warnings) { core.irc._SlowQueue.DeliverMessage(messages.get("PermissionDenied", channel.Language), channel.Name, IRC.priority.low); } return; } }
public override void Load() { try { RecentChanges.channels = new List <string>(); if (!File.Exists(RecentChanges.channeldata)) { File.WriteAllText(RecentChanges.channeldata, "#mediawiki.wikipedia"); } string message = ""; try { string[] list = System.IO.File.ReadAllLines(RecentChanges.channeldata); Log("Loading feed", false); lock (RecentChanges.channels) { foreach (string chan in list) { RecentChanges.channels.Add(chan); } } RecentChanges.Connect(); Log("Loaded feed", false); while (true) { try { if (RecentChanges.RD == null) { return; } while (!RecentChanges.RD.EndOfStream) { message = RecentChanges.RD.ReadLine(); if (!message.Contains(" PRIVMSG ")) { continue; } Change edit = String2Change(message); //Match Edit = RecentChanges.line.Match(message); if (edit != null) { string _channel = message.Substring(message.IndexOf("PRIVMSG")); _channel = _channel.Substring(_channel.IndexOf("#")); _channel = _channel.Substring(0, _channel.IndexOf(" ")); List <RecentChanges> R = new List <RecentChanges>(); lock (RecentChanges.rc) { R.AddRange(RecentChanges.rc); } foreach (RecentChanges curr in R) { if (curr != null) { if (edit.Special && !GetConfig(curr.channel, "RC.Special", false)) { continue; } if (GetConfig(curr.channel, "RC.Enabled", false)) { lock (curr.pages) { foreach (RecentChanges.IWatch w in curr.pages) { if (w != null) { if (w.Channel == _channel || w.Channel == "all") { if (edit.Page == w.Page) { if (edit.Size != null) { edit.Summary = "[" + edit.Size + "] " + edit.Summary; } if (w.URL == null) { DebugLog("NULL pointer on idata 1", 2); } core.irc._SlowQueue.DeliverMessage( Format(w.URL.name, w.URL.url, edit.Page, edit.User, edit.diff, edit.Summary, curr.channel, edit.Bot, edit.New, edit.Minor), curr.channel.Name, IRC.priority.low); } else if (w.Page.EndsWith("*")) { if (edit.Page.StartsWith(w.Page.Replace("*", ""))) { if (w.URL == null) { DebugLog("NULL pointer on idata 2", 2); } core.irc._SlowQueue.DeliverMessage( Format(w.URL.name, w.URL.url, edit.Page, edit.User, edit.diff, edit.Summary, curr.channel, edit.Bot, edit.New, edit.Minor), curr.channel.Name, IRC.priority.low); } } } } } } } } } } else { DebugLog("Error on: " + message); } Thread.Sleep(10); } Thread.Sleep(100); } catch (ThreadAbortException) { return; } catch (IOException) { RecentChanges.Connect(); } catch (Exception fail) { core.LastText = message; handleException(fail); } } } catch (ThreadAbortException) { return; } catch (Exception fail) { handleException(fail); // abort } } catch (ThreadAbortException) { return; } catch (Exception fail) { handleException(fail); } }