public override void Hook_Channel(Channel channel) { if (channel.RetrieveObject("rss") == null) { channel.RegisterObject(new Feed(channel), "rss"); } }
public override string Extension_DumpHtml(Channel channel) { string HTML = ""; if (GetConfig(channel, "Rss.Enable", false)) { Feed list = (Feed)channel.RetrieveObject("rss"); if (list == null) { return ""; } if (GetConfig(channel, "Rss.Enable", false) != true) { return HTML; } HTML += "<h4>Rss feed</h4><br>"; HTML += "\n<br>\n<h4>Rss</h4>\n<br>\n\n<table class=\"infobot\" width=100% border=1>"; HTML += "<tr><th>Name</th><th>URL</th><th>Text</th><th>Enabled</th></tr>"; lock (list.Content) { foreach (Feed.Item feed in list.Content) { HTML += "\n<tr><td>" + feed.name + "</td><td><a href=\"" + feed.URL + "\">" + feed.URL + "</a></td><td>" + feed.template + "</td><td>" + (!feed.disabled).ToString() + "</td></tr>"; } } HTML += "</table>\n"; } return HTML; }
public override void Hook_Channel(Channel channel) { if (channel.RetrieveObject("Statistics") == null) { channel.RegisterObject(new Statistics(channel), NAME); } }
public override string Extension_DumpHtml(Channel channel) { string HTML = ""; if (Module.GetConfig(channel, "Statistics.Enabled", false)) { Statistics list = (Statistics)channel.RetrieveObject(NAME); if (list != null) { HTML += "\n<br>\n<h4>Most active users :)</h4>\n<br>\n\n<table class=\"infobot\" width=100% border=1>"; HTML += "<tr><td>N.</td><th>Nick</th><th>Messages (average / day)</th><th>Number of posted messages</th><th>Active since</th></tr>"; int id = 0; int totalms = 0; DateTime startime = DateTime.Now; lock (list.data) { list.data.Sort(); list.data.Reverse(); foreach (Statistics.list user in list.data) { id++; totalms += user.messages; if (id > 100) { continue; } if (startime > user.logging_since) { startime = user.logging_since; } System.TimeSpan uptime = System.DateTime.Now - user.logging_since; float average = user.messages; average = ((float)user.messages / (float)(uptime.Days + 1)); if (user.URL != "") { HTML += "<tr><td>" + id.ToString() + ".</td><td><a target=\"_blank\" href=\"" + user.URL + "\">" + user.user + "</a></td><td>" + average.ToString() + "</td><td>" + user.messages.ToString() + "</td><td>" + user.logging_since.ToString() + "</td></tr>"; } else { HTML += "<tr><td>" + id.ToString() + ".</td><td>" + user.user + "</td><td>" + average.ToString() + "</td><td>" + user.messages.ToString() + "</td><td>" + user.logging_since.ToString() + "</td></tr>"; } HTML += " \n"; } } System.TimeSpan uptime_total = System.DateTime.Now - startime; float average2 = totalms; average2 = (float)totalms / (1 + uptime_total.Days); HTML += "<tr><td>N/A</td><th>Total:</th><th>" + average2.ToString() + "</th><th>" + totalms.ToString() + "</th><td>N/A</td></tr>"; HTML += " \n"; HTML += "</table>"; } } return HTML; }
public override string Extension_DumpHtml(Channel channel) { string HTML = ""; Infobot info = (Infobot)channel.RetrieveObject("Infobot"); if (info != null) { HTML += "\n<table border=1 class=\"infobot\" width=100%>\n<tr><th width=10%>Key</th><th>Value</th></tr>\n"; List<Infobot.InfobotKey> list = new List<Infobot.InfobotKey>(); lock (info) { if (Module.GetConfig(channel, "Infobot.Sorted", false) != false) { list = info.SortedItem(); } else { list.AddRange(info.Keys); } } if (info.Keys.Count > 0) { foreach (Infobot.InfobotKey Key in list) { HTML += Core.HTML.AddKey(Key.Key, Key.Text); } } HTML += "</table>\n"; HTML += "<h4>Aliases</h4>\n<table class=\"infobot\" border=1 width=100%>\n"; lock (info) { foreach (Infobot.InfobotAlias data in info.Alias) { HTML += Core.HTML.AddLink(data.Name, data.Key); } } HTML += "</table><br>\n"; } return HTML; }
public override void Hook_Channel(Channel channel) { Syslog.Log("Loading " + channel.Name); if (channel == null) { Syslog.Log("NULL"); } if (Snapshots) { try { if (Directory.Exists(SnapshotsDirectory + Path.DirectorySeparatorChar + channel.Name) == false) { Syslog.Log("Creating directory for infobot for " + channel.Name); Directory.CreateDirectory(SnapshotsDirectory + Path.DirectorySeparatorChar + channel.Name); } } catch (Exception fail) { Core.HandleException(fail, "infobot"); } } if (channel.RetrieveObject("Infobot") == null) { // sensitivity bool cs = Module.GetConfig(channel, "Infobot.Case", true); channel.RegisterObject(new Infobot(getDB(ref channel), channel, this, cs), "Infobot"); } }
public override bool Hook_SetConfig(Channel chan, User invoker, string config, string value) { bool _temp_a; switch (config) { case "infobot-trim-white-space-in-name": if (bool.TryParse(value, out _temp_a)) { Module.SetConfig(chan, "Infobot.Trim-white-space-in-name", _temp_a); Core.irc.Queue.DeliverMessage(messages.Localize("configuresave", chan.Language, new List<string> { value, config }), chan.Name); chan.SaveConfig(); return true; } Core.irc.Queue.DeliverMessage(messages.Localize("configure-va", chan.Language, new List<string> { config, value }), chan.Name); return true; case "infobot-auto-complete": if (bool.TryParse(value, out _temp_a)) { Module.SetConfig(chan, "Infobot.auto-complete", _temp_a); Core.irc.Queue.DeliverMessage(messages.Localize("configuresave", chan.Language, new List<string> { value, config }), chan.Name); chan.SaveConfig(); return true; } Core.irc.Queue.DeliverMessage(messages.Localize("configure-va", chan.Language, new List<string> { config, value }), chan.Name); return true; case "infobot-sorted": if (bool.TryParse(value, out _temp_a)) { Module.SetConfig(chan, "Infobot.Sorted", _temp_a); Core.irc.Queue.DeliverMessage(messages.Localize("configuresave", chan.Language, new List<string> { value, config }), chan.Name); chan.SaveConfig(); return true; } Core.irc.Queue.DeliverMessage(messages.Localize("configure-va", chan.Language, new List<string> { config, value }), chan.Name); return true; case "infobot-help": if (bool.TryParse(value, out _temp_a)) { Module.SetConfig(chan, "Infobot.Help", _temp_a); Core.irc.Queue.DeliverMessage(messages.Localize("configuresave", chan.Language, new List<string> { value, config }), chan.Name); chan.SaveConfig(); return true; } Core.irc.Queue.DeliverMessage(messages.Localize("configure-va", chan.Language, new List<string> { config, value }), chan.Name); return true; case "infobot-case": if (bool.TryParse(value, out _temp_a)) { Module.SetConfig(chan, "Infobot.Case", _temp_a); Core.irc.Queue.DeliverMessage(messages.Localize("configuresave", chan.Language, new List<string> { value, config }), chan.Name); chan.SaveConfig(); Infobot infobot = (Infobot)chan.RetrieveObject("Infobot"); if (infobot != null) { infobot.Sensitive = _temp_a; } return true; } Core.irc.Queue.DeliverMessage(messages.Localize("configure-va", chan.Language, new List<string> { config, value }), chan.Name); return true; } return false; }
public override void Hook_PRIV(Channel channel, User invoker, string message) { // "\uff01" is the full-width version of "!". if ((message.StartsWith("!") || message.StartsWith("\uff01")) && GetConfig(channel, "Infobot.Enabled", true)) { while (Unwritable) { Thread.Sleep(10); } Unwritable = true; Infobot.InfoItem item = new Infobot.InfoItem(); item._Channel = channel; item.Name = "!" + message.Substring(1); // Normalizing "!". item.User = invoker.Nick; item.Host = invoker.Host; jobs.Add(item); Unwritable = false; } Infobot infobot = null; if (message.StartsWith(Configuration.System.CommandPrefix)) { infobot = (Infobot)channel.RetrieveObject("Infobot"); if (infobot == null) { Syslog.Log("Object Infobot in " + channel.Name + " doesn't exist", true); } if (GetConfig(channel, "Infobot.Enabled", true)) { if (infobot != null) { infobot.Find(message, channel); infobot.RSearch(message, channel); } } } if (Snapshots) { if (message.StartsWith(Configuration.System.CommandPrefix + "infobot-recovery ")) { if (channel.SystemUsers.IsApproved(invoker, "admin")) { string name = message.Substring("@infobot-recovery ".Length); if (!GetConfig(channel, "Infobot.Enabled", true)) { Core.irc.Queue.DeliverMessage("Infobot is not enabled in this channel", channel, IRC.priority.low); return; } if (infobot != null) { infobot.RecoverSnapshot(channel, name); } return; } if (!channel.SuppressWarnings) { Core.irc.Queue.DeliverMessage(messages.Localize("PermissionDenied", channel.Language), channel, IRC.priority.low); } return; } if (message.StartsWith(Configuration.System.CommandPrefix + "infobot-snapshot ")) { if (channel.SystemUsers.IsApproved(invoker, "admin")) { string name = message.Substring("@infobot-snapshot ".Length); if (!GetConfig(channel, "Infobot.Enabled", true)) { Core.irc.Queue.DeliverMessage("Infobot is not enabled in this channel", channel, IRC.priority.low); return; } if (infobot != null) { infobot.CreateSnapshot(channel, name); } return; } if (!channel.SuppressWarnings) { Core.irc.Queue.DeliverMessage(messages.Localize("PermissionDenied", channel.Language), channel, IRC.priority.low); } return; } if (message.StartsWith(Configuration.System.CommandPrefix + "infobot-set-raw ")) { if (channel.SystemUsers.IsApproved(invoker, "trust")) { string name = message.Substring("@infobot-set-raw ".Length); if (!GetConfig(channel, "Infobot.Enabled", true)) { Core.irc.Queue.DeliverMessage("Infobot is not enabled in this channel", channel, IRC.priority.low); return; } if (infobot != null) { infobot.SetRaw(name, invoker.Nick, channel); return; } } if (!channel.SuppressWarnings) { Core.irc.Queue.DeliverMessage(messages.Localize("PermissionDenied", channel.Language), channel, IRC.priority.low); } return; } if (message.StartsWith(Configuration.System.CommandPrefix + "infobot-unset-raw ")) { if (channel.SystemUsers.IsApproved(invoker, "trust")) { string name = message.Substring("@infobot-unset-raw ".Length); if (!GetConfig(channel, "Infobot.Enabled", true)) { Core.irc.Queue.DeliverMessage("Infobot is not enabled in this channel", channel, IRC.priority.low); return; } if (infobot != null) { infobot.UnsetRaw(name, invoker.Nick, channel); return; } } if (!channel.SuppressWarnings) { Core.irc.Queue.DeliverMessage(messages.Localize("PermissionDenied", channel.Language), channel, IRC.priority.low); } return; } if (message.StartsWith(Configuration.System.CommandPrefix + "infobot-snapshot-rm ")) { if (channel.SystemUsers.IsApproved(invoker, "admin")) { string name = message.Substring("@infobot-snapshot-rm ".Length); name.Replace(".", ""); name.Replace("/", ""); name.Replace("\\", ""); name.Replace("*", ""); name.Replace("?", ""); if (name == "") { Core.irc.Queue.DeliverMessage("You should specify a file name", channel, IRC.priority.normal); return; } if (!File.Exists(SnapshotsDirectory + Path.DirectorySeparatorChar + channel.Name + Path.DirectorySeparatorChar + name)) { Core.irc.Queue.DeliverMessage("File not found", channel, IRC.priority.normal); return; } File.Delete(SnapshotsDirectory + Path.DirectorySeparatorChar + channel.Name + Path.DirectorySeparatorChar + name); Core.irc.Queue.DeliverMessage("Requested file was removed", channel, IRC.priority.normal); return; } if (!channel.SuppressWarnings) { Core.irc.Queue.DeliverMessage(messages.Localize("PermissionDenied", channel.Language), channel, IRC.priority.low); } return; } if (message == Configuration.System.CommandPrefix + "infobot-snapshot-ls") { string files = ""; DirectoryInfo di = new DirectoryInfo(SnapshotsDirectory + Path.DirectorySeparatorChar + channel.Name); FileInfo[] rgFiles = di.GetFiles("*"); int curr = 0; int displaying = 0; foreach (FileInfo fi in rgFiles) { curr++; if (files.Length < 200) { files += fi.Name + " "; displaying++; } } string response = ""; if (curr == displaying) { response = "There are " + displaying.ToString() + " files: " + files; } else { response = "There are " + curr.ToString() + " files, but displaying only " + displaying.ToString() + " of them: " + files; } if (curr == 0) { response = "There is no snapshot so far, create one!:)"; } Core.irc.Queue.DeliverMessage(response, channel.Name, IRC.priority.normal); return; } } if (message.StartsWith(Configuration.System.CommandPrefix + "infobot-share-trust+ ")) { if (channel.SystemUsers.IsApproved(invoker, "admin")) { if (channel.SharedDB != "local") { Core.irc.Queue.DeliverMessage(messages.Localize("infobot16", channel.Language), channel); return; } if (channel.SharedDB != "local" && channel.SharedDB != "") { Core.irc.Queue.DeliverMessage(messages.Localize("infobot15", channel.Language), channel); return; } else { if (message.Length <= "@infobot-share-trust+ ".Length) { Core.irc.Queue.DeliverMessage(messages.Localize("db6", channel.Language), channel.Name); return; } string name = message.Substring("@infobot-share-trust+ ".Length); Channel guest = Core.GetChannel(name); if (guest == null) { Core.irc.Queue.DeliverMessage(messages.Localize("db8", channel.Language), channel.Name); return; } if (channel.SharedLinkedChan.Contains(guest)) { Core.irc.Queue.DeliverMessage(messages.Localize("db14", channel.Language), channel.Name); return; } Core.irc.Queue.DeliverMessage(messages.Localize("db1", channel.Language, new List<string> { name }), channel.Name); lock (channel.SharedLinkedChan) { channel.SharedLinkedChan.Add(guest); } channel.SaveConfig(); return; } } if (!channel.SuppressWarnings) { Core.irc.Queue.DeliverMessage(messages.Localize("PermissionDenied", channel.Language), channel.Name, IRC.priority.low); } return; } if (message.StartsWith(Configuration.System.CommandPrefix + "infobot-ignore- ")) { if (channel.SystemUsers.IsApproved(invoker, "trust")) { string item = message.Substring("@infobot-ignore+ ".Length); if (item != "") { if (!channel.Infobot_IgnoredNames.Contains(item)) { Core.irc.Queue.DeliverMessage(messages.Localize("infobot-ignore-found", channel.Language, new List<string> { item }), channel); return; } channel.Infobot_IgnoredNames.Remove(item); Core.irc.Queue.DeliverMessage(messages.Localize("infobot-ignore-rm", channel.Language, new List<string> { item }), channel); channel.SaveConfig(); return; } } else { if (!channel.SuppressWarnings) { Core.irc.Queue.DeliverMessage(messages.Localize("PermissionDenied", channel.Language), channel, IRC.priority.low); } } } if (message.StartsWith(Configuration.System.CommandPrefix + "infobot-ignore+ ")) { if (channel.SystemUsers.IsApproved(invoker, "trust")) { string item = message.Substring("@infobot-ignore+ ".Length); if (item != "") { if (channel.Infobot_IgnoredNames.Contains(item)) { Core.irc.Queue.DeliverMessage(messages.Localize("infobot-ignore-exist", channel.Language, new List<string> { item }), channel); return; } channel.Infobot_IgnoredNames.Add(item); Core.irc.Queue.DeliverMessage(messages.Localize("infobot-ignore-ok", channel.Language, new List<string> { item }), channel); channel.SaveConfig(); return; } } else { if (!channel.SuppressWarnings) { Core.irc.Queue.DeliverMessage(messages.Localize("PermissionDenied", channel.Language), channel, IRC.priority.low); } } } if (message == Configuration.System.CommandPrefix + "infobot-off") { if (channel.SystemUsers.IsApproved(invoker, "admin")) { if (!GetConfig(channel, "Infobot.Enabled", true)) { Core.irc.Queue.DeliverMessage(messages.Localize("infobot1", channel.Language), channel); return; } else { Core.irc.Queue.DeliverMessage(messages.Localize("infobot2", channel.Language), channel, IRC.priority.high); SetConfig(channel, "Infobot.Enabled", false); channel.SaveConfig(); return; } } if (!channel.SuppressWarnings) { Core.irc.Queue.DeliverMessage(messages.Localize("PermissionDenied", channel.Language), channel, IRC.priority.low); } return; } if (message.StartsWith(Configuration.System.CommandPrefix + "infobot-share-trust- ")) { if (channel.SystemUsers.IsApproved(invoker, "admin")) { if (channel.SharedDB != "local") { Core.irc.Queue.DeliverMessage(messages.Localize("infobot16", channel.Language), channel); return; } else { if (message.Length <= "@infobot-share-trust+ ".Length) { Core.irc.Queue.DeliverMessage(messages.Localize("db6", channel.Language), channel); return; } string name = message.Substring("@infobot-share-trust- ".Length); Channel target = Core.GetChannel(name); if (target == null) { Core.irc.Queue.DeliverMessage(messages.Localize("db8", channel.Language), channel); return; } if (channel.SharedLinkedChan.Contains(target)) { channel.SharedLinkedChan.Remove(target); Core.irc.Queue.DeliverMessage(messages.Localize("db2", channel.Language, new List<string> { name }), channel); channel.SaveConfig(); return; } Core.irc.Queue.DeliverMessage(messages.Localize("db4", channel.Language), channel); return; } } if (!channel.SuppressWarnings) { Core.irc.Queue.DeliverMessage(messages.Localize("PermissionDenied", channel.Language), channel, IRC.priority.low); } return; } if (message.StartsWith(Configuration.System.CommandPrefix + "infobot-detail ")) { if ((message.Length) <= "@infobot-detail ".Length) { Core.irc.Queue.DeliverMessage(messages.Localize("db6", channel.Language), channel); return; } if (GetConfig(channel, "Infobot.Enabled", true)) { if (channel.SharedDB == "local" || channel.SharedDB == "") { if (infobot != null) { infobot.InfobotDetail(message.Substring(16), channel); } return; } if (channel.SharedDB != "") { Channel db = Core.GetChannel(channel.SharedDB); if (db == null) { Core.irc.Queue.DeliverMessage("Error, null pointer to shared channel", channel, IRC.priority.low); return; } if (infobot != null) { infobot.InfobotDetail(message.Substring(16), channel); } return; } return; } Core.irc.Queue.DeliverMessage("Infobot is not enabled on this channel", channel, IRC.priority.low); return; } if (message.StartsWith(Configuration.System.CommandPrefix + "infobot-link ")) { if (channel.SystemUsers.IsApproved(invoker, "admin")) { if (channel.SharedDB == "local") { Core.irc.Queue.DeliverMessage(messages.Localize("infobot17", channel.Language), channel); return; } if (channel.SharedDB != "") { Core.irc.Queue.DeliverMessage(messages.Localize("infobot18", channel.Language, new List<string> { channel.SharedDB }), channel); return; } if ((message.Length - 1) < "@infobot-link ".Length) { Core.irc.Queue.DeliverMessage(messages.Localize("db6", channel.Language), channel); return; } string name = message.Substring("@infobot-link ".Length); Channel db = Core.GetChannel(name); if (db == null) { Core.irc.Queue.DeliverMessage(messages.Localize("db8", channel.Language), channel); return; } if (!Infobot.Linkable(db, channel)) { Core.irc.Queue.DeliverMessage(messages.Localize("db9", channel.Language), channel); return; } channel.SharedDB = name.ToLower(); Core.irc.Queue.DeliverMessage(messages.Localize("db10", channel.Language), channel); channel.SaveConfig(); return; } if (!channel.SuppressWarnings) { Core.irc.Queue.DeliverMessage(messages.Localize("PermissionDenied", channel.Language), channel, IRC.priority.low); } return; } if (message == Configuration.System.CommandPrefix + "infobot-share-off") { if (channel.SystemUsers.IsApproved(invoker, "admin")) { if (channel.SharedDB == "") { Core.irc.Queue.DeliverMessage(messages.Localize("infobot14", channel.Language), channel); return; } else { Core.irc.Queue.DeliverMessage(messages.Localize("infobot13", channel.Language), channel); lock (Configuration.Channels) { foreach (Channel curr in Configuration.Channels) { if (curr.SharedDB == channel.Name.ToLower()) { curr.SharedDB = ""; curr.SaveConfig(); Core.irc.Queue.DeliverMessage(messages.Localize("infobot19", curr.Language, new List<string> { invoker.Nick }), curr); } } } channel.SharedDB = ""; channel.SaveConfig(); return; } } if (!channel.SuppressWarnings) { Core.irc.Queue.DeliverMessage(messages.Localize("PermissionDenied", channel.Language), channel, IRC.priority.low); } return; } if (message == Configuration.System.CommandPrefix + "infobot-on") { if (channel.SystemUsers.IsApproved(invoker, "admin")) { if (GetConfig(channel, "Infobot.Enabled", true)) { Core.irc.Queue.DeliverMessage(messages.Localize("infobot3", channel.Language), channel); return; } SetConfig(channel, "Infobot.Enabled", true); channel.SaveConfig(); Core.irc.Queue.DeliverMessage(messages.Localize("infobot4", channel.Language), channel, IRC.priority.high); return; } if (!channel.SuppressWarnings) { Core.irc.Queue.DeliverMessage(messages.Localize("PermissionDenied", channel.Language), channel, IRC.priority.low); } return; } if (message == Configuration.System.CommandPrefix + "infobot-share-on") { if (channel.SystemUsers.IsApproved(invoker, "admin")) { if (channel.SharedDB == "local") { Core.irc.Queue.DeliverMessage(messages.Localize("infobot11", channel.Language), channel, IRC.priority.high); return; } if (channel.SharedDB != "local" && channel.SharedDB != "") { Core.irc.Queue.DeliverMessage(messages.Localize("infobot15", channel.Language), channel, IRC.priority.high); return; } else { Core.irc.Queue.DeliverMessage(messages.Localize("infobot12", channel.Language), channel); channel.SharedDB = "local"; channel.SaveConfig(); return; } } if (!channel.SuppressWarnings) { Core.irc.Queue.DeliverMessage(messages.Localize("PermissionDenied", channel.Language), channel, IRC.priority.low); } return; } }
public override void Hook_PRIV(Channel channel, User invoker, string message) { if (message.StartsWith(Configuration.System.CommandPrefix + "RC-")) { if (channel.SystemUsers.IsApproved(invoker, "trust")) { if (GetConfig(channel, "RC.Enabled", false)) { string[] a = message.Split(' '); if (a.Length < 3) { Core.irc.Queue.DeliverMessage(messages.Localize("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.Queue.DeliverMessage(messages.Localize("Feed3", channel.Language), channel.Name); return; } } if (!channel.SuppressWarnings) { Core.irc.Queue.DeliverMessage(messages.Localize("PermissionDenied", channel.Language), channel.Name, IRC.priority.low); } return; } if (message.StartsWith(Configuration.System.CommandPrefix + "recentchanges- ")) { if (channel.SystemUsers.IsApproved(invoker, "root")) { if (GetConfig(channel, "RC.Enabled", false)) { if (!message.Contains(" ")) { if (!channel.SuppressWarnings) { Core.irc.Queue.DeliverMessage(messages.Localize("InvalidWiki", channel.Language), channel.Name); } return; } string _channel = message.Substring(message.IndexOf(" ") + 1); if (RecentChanges.DeleteChannel(channel, _channel)) { Core.irc.Queue.DeliverMessage(messages.Localize("Wiki-", channel.Language), channel.Name, IRC.priority.high); } return; } else { Core.irc.Queue.DeliverMessage(messages.Localize("Feed3", channel.Language), channel.Name); return; } } if (!channel.SuppressWarnings) { Core.irc.Queue.DeliverMessage(messages.Localize("PermissionDenied", channel.Language), channel.Name, IRC.priority.low); } return; } if (message.StartsWith(Configuration.System.CommandPrefix + "RC+ ")) { if (channel.SystemUsers.IsApproved(invoker, "trust")) { if (GetConfig(channel, "RC.Enabled", false)) { string[] a = message.Split(' '); if (a.Length < 3) { Core.irc.Queue.DeliverMessage(messages.Localize("Feed4", channel.Language) + invoker.Nick + messages.Localize("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.Queue.DeliverMessage(messages.Localize("Feed3", channel.Language), channel.Name); return; } } if (!channel.SuppressWarnings) { Core.irc.Queue.DeliverMessage(messages.Localize("PermissionDenied", channel.Language), channel.Name, IRC.priority.low); } return; } if (message == Configuration.System.CommandPrefix + "recentchanges-off") { if (channel.SystemUsers.IsApproved(invoker, "admin")) { if (!GetConfig(channel, "RC.Enabled", false)) { Core.irc.Queue.DeliverMessage(messages.Localize("Feed6", channel.Language), channel.Name); return; } else { Core.irc.Queue.DeliverMessage(messages.Localize("Feed7", channel.Language), channel.Name); SetConfig(channel, "RC.Enabled", false); channel.SaveConfig(); return; } } if (!channel.SuppressWarnings) { Core.irc.Queue.DeliverMessage(messages.Localize("PermissionDenied", channel.Language), channel.Name, IRC.priority.low); } return; } if (message == Configuration.System.CommandPrefix + "recentchanges-on") { if (channel.SystemUsers.IsApproved(invoker, "recentchanges-manage")) { if (GetConfig(channel, "RC.Enabled", false)) { Core.irc.Queue.DeliverMessage(messages.Localize("Feed1", channel.Language), channel.Name); return; } else { Core.irc.Queue.DeliverMessage(messages.Localize("Feed2", channel.Language), channel.Name); SetConfig(channel, "RC.Enabled", true); channel.SaveConfig(); return; } } if (!channel.SuppressWarnings) { Core.irc.Queue.DeliverMessage(messages.Localize("PermissionDenied", channel.Language), channel.Name, IRC.priority.low); } return; } if (message.StartsWith(Configuration.System.CommandPrefix + "recentchanges+")) { if (channel.SystemUsers.IsApproved(invoker, "recentchanges-manage")) { if (GetConfig(channel, "RC.Enabled", false)) { if (!message.Contains(" ")) { if (!channel.SuppressWarnings) { Core.irc.Queue.DeliverMessage(messages.Localize("InvalidWiki", channel.Language), channel.Name); } return; } string _channel = message.Substring(message.IndexOf(" ") + 1); if (RecentChanges.InsertChannel(channel, _channel)) { Core.irc.Queue.DeliverMessage(messages.Localize("Wiki+", channel.Language), channel.Name); } return; } else { Core.irc.Queue.DeliverMessage(messages.Localize("Feed3", channel.Language), channel.Name); return; } } if (!channel.SuppressWarnings) { Core.irc.Queue.DeliverMessage(messages.Localize("PermissionDenied", channel.Language), channel.Name, IRC.priority.low); } return; } }
public override void Hook_Channel(Channel channel) { if (channel.RetrieveObject("RC") == null) { channel.RegisterObject(new RecentChanges(channel), "RC"); } }
public override string Extension_DumpHtml(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(Channel channel, User invoker, string message) { if (message.StartsWith(Configuration.System.CommandPrefix + "rss- ")) { if (channel.SystemUsers.IsApproved(invoker, "trust")) { string item = message.Substring("@rss+ ".Length); Feed feed = (Feed)channel.RetrieveObject("rss"); if (feed != null) { feed.RemoveItem(item); } return; } else { if (!channel.SuppressWarnings) { Core.irc.Queue.DeliverMessage(messages.Localize("PermissionDenied", channel.Language), channel.Name, IRC.priority.low); } } } if (message.StartsWith(Configuration.System.CommandPrefix + "rss-setstyle ")) { if (channel.SystemUsers.IsApproved(invoker, "trust")) { string item = message.Substring("@rss-setstyle ".Length); if (item.Contains(" ")) { string id = item.Substring(0, item.IndexOf(" ")); string ur = item.Substring(item.IndexOf(" ") + 1); Feed feed = (Feed)channel.RetrieveObject("rss"); if (feed != null) { feed.StyleItem(id, ur); } return; } if (item != "") { Feed feed = (Feed)channel.RetrieveObject("rss"); if (feed != null) { feed.StyleItem(item, ""); } return; } if (!channel.SuppressWarnings) { Core.irc.Queue.DeliverMessage(messages.Localize("Rss5", channel.Language), channel.Name, IRC.priority.low); } } else { if (!channel.SuppressWarnings) { Core.irc.Queue.DeliverMessage(messages.Localize("PermissionDenied", channel.Language), channel.Name, IRC.priority.low); } } } if (message.StartsWith(Configuration.System.CommandPrefix + "rss-search+ ")) { if (channel.SystemUsers.IsApproved(invoker, "trust")) { string item = message.Substring("@rss-search+ ".Length); Feed feed = (Feed)channel.RetrieveObject("rss"); if (feed != null) { lock (feed.ScannerMatches) { if (feed.ScannerMatches.Contains(item)) { Core.irc.Queue.DeliverMessage("This item is already being searched", channel); return; } Core.irc.Queue.DeliverMessage("This item is now searched", channel); feed.ScannerMatches.Add(item); return; } } Core.irc.Queue.DeliverMessage("Error, this channel doesn't have RC feed", channel); return; } else { if (!channel.SuppressWarnings) { Core.irc.Queue.DeliverMessage(messages.Localize("PermissionDenied", channel.Language), channel, IRC.priority.low); } } } if (message.StartsWith(Configuration.System.CommandPrefix + "rss-search- ")) { if (channel.SystemUsers.IsApproved(invoker, "trust")) { string item = message.Substring("@rss-search+ ".Length); Feed feed = (Feed)channel.RetrieveObject("rss"); if (feed != null) { lock (feed.ScannerMatches) { if (feed.ScannerMatches.Contains(item)) { feed.ScannerMatches.Remove(item); Core.irc.Queue.DeliverMessage("This item was removed", channel); return; } Core.irc.Queue.DeliverMessage("This item was not being searched", channel); return; } } Core.irc.Queue.DeliverMessage("Error, this channel doesn't have RC feed", channel); return; } else { if (!channel.SuppressWarnings) { Core.irc.Queue.DeliverMessage(messages.Localize("PermissionDenied", channel.Language), channel, IRC.priority.low); } } } if (message.StartsWith(Configuration.System.CommandPrefix + "rss+ ")) { if (channel.SystemUsers.IsApproved(invoker, "trust")) { string item = message.Substring("@rss+ ".Length); if (item.Contains(" ")) { string id = item.Substring(0, item.IndexOf(" ")); string ur = item.Substring(item.IndexOf(" ") + 1); Feed feed = (Feed)channel.RetrieveObject("rss"); if (feed != null) { feed.InsertItem(id, ur); } return; } if (item != "") { Feed feed = (Feed)channel.RetrieveObject("rss"); if (feed != null) { feed.InsertItem(item, ""); } return; } if (!channel.SuppressWarnings) { Core.irc.Queue.DeliverMessage(messages.Localize("Rss5", channel.Language), channel.Name, IRC.priority.low); } } else { if (!channel.SuppressWarnings) { Core.irc.Queue.DeliverMessage(messages.Localize("PermissionDenied", channel.Language), channel.Name, IRC.priority.low); } } } if (message.StartsWith("@rss-scanner+ ")) { if (channel.SystemUsers.IsApproved(invoker, "trust")) { string item = message.Substring("@rss-scanner+ ".Length); if (item.Contains(" ")) { string id = item.Substring(0, item.IndexOf(" ")); string ur = item.Substring(item.IndexOf(" ") + 1); Feed feed = (Feed)channel.RetrieveObject("rss"); if (feed != null) { feed.InsertItem(id, ur, true); } return; } if (item != "") { Feed feed = (Feed)channel.RetrieveObject("rss"); if (feed != null) { feed.InsertItem(item, "", true); } return; } if (!channel.SuppressWarnings) { Core.irc.Queue.DeliverMessage(messages.Localize("Rss5", channel.Language), channel.Name, IRC.priority.low); } } else { if (!channel.SuppressWarnings) { Core.irc.Queue.DeliverMessage(messages.Localize("PermissionDenied", channel.Language), channel.Name, IRC.priority.low); } } } if (message.StartsWith("@rss-scanner- ")) { if (channel.SystemUsers.IsApproved(invoker, "trust")) { string item = message.Substring("@rss-scannerx ".Length); Feed feed = (Feed)channel.RetrieveObject("rss"); if (feed != null) { feed.RemoveItem(item); } return; } else { if (!channel.SuppressWarnings) { Core.irc.Queue.DeliverMessage(messages.Localize("PermissionDenied", channel.Language), channel.Name, IRC.priority.low); } } } if (message == "@rss-off") { if (channel.SystemUsers.IsApproved(invoker, "admin")) { if (!GetConfig(channel, "Rss.Enable", false)) { Core.irc.Queue.DeliverMessage(messages.Localize("Rss1", channel.Language), channel.Name); return; } else { SetConfig(channel, "Rss.Enable", false); Core.irc.Queue.DeliverMessage(messages.Localize("Rss2", channel.Language), channel.Name); channel.SaveConfig(); return; } } if (!channel.SuppressWarnings) { Core.irc.Queue.DeliverMessage(messages.Localize("PermissionDenied", channel.Language), channel.Name, IRC.priority.low); } return; } if (message == "@rss-on") { if (channel.SystemUsers.IsApproved(invoker, "admin")) { if (GetConfig(channel, "Rss.Enable", false)) { Core.irc.Queue.DeliverMessage(messages.Localize("Rss3", channel.Language), channel.Name); return; } else { Core.irc.Queue.DeliverMessage(messages.Localize("Rss4", channel.Language), channel.Name); SetConfig(channel, "Rss.Enable", true); channel.SaveConfig(); return; } } if (!channel.SuppressWarnings) { Core.irc.Queue.DeliverMessage(messages.Localize("PermissionDenied", channel.Language), channel.Name, IRC.priority.low); } return; } }
public override void Hook_PRIV(Channel channel, User invoker, string message) { if (Module.GetConfig(channel, "Statistics.Enabled", false)) { Statistics st = (Statistics)channel.RetrieveObject("Statistics"); if (st != null) { st.Stat(invoker.Nick, message, invoker.Host); } } if (message == Configuration.System.CommandPrefix + "statistics-off") { if (channel.SystemUsers.IsApproved(invoker, "admin")) { if (!Module.GetConfig(channel, "Statistics.Enabled", false)) { Core.irc.Queue.DeliverMessage(messages.Localize("StatE2", channel.Language), channel); return; } else { Module.SetConfig(channel, "Statistics.Enabled", false); channel.SaveConfig(); Core.irc.Queue.DeliverMessage(messages.Localize("Stat-off", channel.Language), channel); return; } } if (!channel.SuppressWarnings) { Core.irc.Queue.DeliverMessage(messages.Localize("PermissionDenied", channel.Language), channel, IRC.priority.low); } return; } if (message == Configuration.System.CommandPrefix + "statistics-reset") { if (channel.SystemUsers.IsApproved(invoker, "admin")) { Statistics st = (Statistics)channel.RetrieveObject("Statistics"); if (st != null) { st.Delete(); } Core.irc.Queue.DeliverMessage(messages.Localize("Statdt", channel.Language), channel); return; } if (!channel.SuppressWarnings) { Core.irc.Queue.DeliverMessage(messages.Localize("PermissionDenied", channel.Language), channel, IRC.priority.low); } return; } if (message == Configuration.System.CommandPrefix + "statistics-on") { if (channel.SystemUsers.IsApproved(invoker, "admin")) { if (Module.GetConfig(channel, "Statistics.Enabled", false)) { Core.irc.Queue.DeliverMessage(messages.Localize("StatE1", channel.Language), channel); return; } else { Module.SetConfig(channel, "Statistics.Enabled", true); channel.SaveConfig(); Core.irc.Queue.DeliverMessage(messages.Localize("Stat-on", channel.Language), channel); return; } } if (!channel.SuppressWarnings) { Core.irc.Queue.DeliverMessage(messages.Localize("PermissionDenied", channel.Language), channel.Name, IRC.priority.low); } return; } }