private static void categoryHasItemsEvent(ArrayList items, string keyword) { ArrayList newItems = updateDatabaseTable(items, keyword); DAL.Select q = new DAL.Select("channel_name"); q.addJoin("channelwatchers", DAL.Select.JoinTypes.Inner, new DAL.WhereConds(false, "watcher_id", "=", false, "cw_watcher")); q.addJoin("channel", DAL.Select.JoinTypes.Inner, new DAL.WhereConds(false, "channel_id", "=", false, "cw_channel")); q.setFrom("watcher"); q.addWhere(new DAL.WhereConds("watcher_keyword", keyword)); q.addLimit(10, 0); ArrayList channels = DAL.singleton().executeSelect(q); foreach (object[] item in channels) { string channel = (string)item[0]; string message = compileMessage(items, keyword, channel, false); if (Configuration.singleton()["silence", channel] == "false") { Helpmebot6.irc.ircPrivmsg(channel, message); } } if (newItems.Count > 0) { var message = compileMessage(newItems, keyword, ">TWITTER<", false); new Twitter().updateStatus(message); } }
/// <summary> /// Initializes a new instance of the <see cref="WatcherController"/> class. /// </summary> protected WatcherController() { this._watchers = new Dictionary<string, CategoryWatcher>(); DAL.Select q = new DAL.Select("watcher_category", "watcher_keyword", "watcher_sleeptime"); q.addOrder(new DAL.Select.Order("watcher_priority", true)); q.setFrom("watcher"); q.addLimit(100, 0); ArrayList watchersInDb = DAL.singleton().executeSelect(q); foreach (object[] item in watchersInDb) { this._watchers.Add((string) item[1], new CategoryWatcher((string) item[0], (string) item[1], int.Parse(((UInt32) item[2]).ToString()))); } foreach (KeyValuePair<string, CategoryWatcher> item in this._watchers) { item.Value.categoryHasItemsEvent += categoryHasItemsEvent; } }
/// <summary> /// Initializes a new instance of the <see cref="WatcherController"/> class. /// </summary> protected WatcherController() { this._watchers = new Dictionary <string, CategoryWatcher>(); DAL.Select q = new DAL.Select("watcher_category", "watcher_keyword", "watcher_sleeptime"); q.addOrder(new DAL.Select.Order("watcher_priority", true)); q.setFrom("watcher"); q.addLimit(100, 0); ArrayList watchersInDb = DAL.singleton().executeSelect(q); foreach (object[] item in watchersInDb) { this._watchers.Add((string)item[1], new CategoryWatcher((string)item[0], (string)item[1], int.Parse(((UInt32)item[2]).ToString()))); } foreach (KeyValuePair <string, CategoryWatcher> item in this._watchers) { item.Value.categoryHasItemsEvent += categoryHasItemsEvent; } }
private void threadBody() { Logger.instance().addToLog("Starting ACC Notifications watcher", Logger.LogTypes.General); try { DAL.Select query = new DAL.Select("notif_id", "notif_text", "notif_type"); query.setFrom("acc_notifications"); query.addLimit(1, 0); query.addOrder(new DAL.Select.Order("notif_id", true)); while (true) { Thread.Sleep(5000); ArrayList data = DAL.singleton().executeSelect(query); if (data.Count == 0) { continue; } foreach (object raw in data) { var d = (object[])raw; var id = (int)d[0]; var text = (string)d[1]; var type = (int)d[2]; var destination = "##helpmebot"; switch (type) { case 1: destination = "#wikipedia-en-accounts"; break; case 2: destination = "#wikipedia-en-accounts-devs"; break; } DAL.singleton().delete("acc_notifications", 1, new DAL.WhereConds("notif_id", id)); if (Configuration.singleton()["silence", destination] == "false") { Helpmebot6.irc.ircPrivmsg(destination, text); } } } } catch (ThreadAbortException) { EventHandler temp = this.threadFatalError; if (temp != null) { temp(this, new EventArgs()); } } Helpmebot6.irc.ircPrivmsg("##helpmebot", "ACC Notifications watcher died"); Logger.instance().addToLog("ACC Notifications watcher died.", Logger.LogTypes.Error); }
private static void categoryHasItemsEvent(ArrayList items, string keyword) { ArrayList newItems = updateDatabaseTable(items, keyword); DAL.Select q = new DAL.Select("channel_name"); q.addJoin("channelwatchers", DAL.Select.JoinTypes.Inner, new DAL.WhereConds(false, "watcher_id", "=", false, "cw_watcher")); q.addJoin("channel", DAL.Select.JoinTypes.Inner, new DAL.WhereConds(false, "channel_id", "=", false, "cw_channel")); q.setFrom("watcher"); q.addWhere(new DAL.WhereConds("watcher_keyword", keyword)); q.addLimit(10, 0); ArrayList channels = DAL.singleton().executeSelect(q); foreach (object[] item in channels) { string channel = (string) item[0]; string message = compileMessage(items, keyword, channel, false); if (Configuration.singleton()["silence",channel] == "false") Helpmebot6.irc.ircPrivmsg(channel, message); } if (newItems.Count > 0) new Twitter( ).updateStatus(compileMessage(newItems, keyword, ">TWITTER<", false)); }