public NyaaSpam(IIrcComm ircComm, IMeidoComm meidoComm) { meido = meidoComm; irc = ircComm; log = meido.CreateLogger(this); // Setting up configuration. var xmlConf = new XmlConfig2 <Config>( Config.DefaultConfig(), (xml) => new Config(xml), log, Configure ); meido.LoadAndWatchConfig("NyaaSpam.xml", xmlConf); var bangs = new TopicHelp[] { new TopicHelp("nyaa bangs", Bangs()) }; var nyaaHelp = new TriggerHelp( () => string.Format( "Commands to manipulate which patterns are periodically checked for at {0}", conf.Feed), new CommandHelp( "add", "<pattern...>", "Adds pattern(s), separated by commas (,). Unless enclosed in quotation marks (\"), in which case " + "the pattern is added verbatim.") { AlsoSee = bangs }, new CommandHelp( "del", "<index...> | <pattern...>", "Removes pattern(s) indicated by list of indices. Can also accept a list of patterns " + "(or parts thereof) to be deleted. Lists of indices/patterns are comma (,) separated and indices can " + "be specified as a number range (x-y). (Ex: nyaa del 4, 7, 0-2)"), new CommandHelp( "show", "Gives an overview of all patterns that are checked for.") ) { AlsoSee = bangs }; Triggers = new Trigger[] { new Trigger("nyaa", Nyaa, TriggerOption.ChannelOnly) { Help = nyaaHelp } }; }
public IrcWeather(IIrcComm irc, IMeidoComm meido) { Triggers = Trigger.Group( new Trigger("w", WeatherSearch, TriggerThreading.Queue) { Help = new TriggerHelp( "<city>,[country] | <zip>,[country] | @<nick>", "Reports weather conditions at location. Location can have an optional 2-letter country code " + "(ISO 3166) at the end to more precisely indicate the location. " + "Will use your default location if called without arguments. (Powered by OpenWeatherMap)") }, new Trigger("W", SetWeatherLocation, TriggerThreading.Queue) { Help = new TriggerHelp( "<city>,[country] | <zip>,[country]", "Sets your default weather location.") } ); this.irc = irc; log = meido.CreateLogger(this); // Setting up configuration. var xmlConf = new XmlConfig2 <Config>( Config.DefaultConfig(), (xml) => new Config(xml), log, Configure ); meido.LoadAndWatchConfig("WeatherService.xml", xmlConf); // Setting up locations database/dict. storagePath = meido.DataPathTo("weather-locations.xml"); try { defaultLocations = Storage <string> .Deserialize(storagePath); } catch (FileNotFoundException) { defaultLocations = new Storage <string>(); } }
public IrcChainey(IIrcComm ircComm, IMeidoComm meidoComm) { meido = meidoComm; log = meido.CreateLogger(this); conf.Location = meidoComm.DataPathTo("chainey.sqlite"); backend = new SqliteBrain(conf.Location, conf.Order); chainey = new BrainFrontend(backend); chainey.Filter = false; irc = ircComm; var t = TriggerThreading.Queue; Triggers = Trigger.Group( new Trigger("markov", Markov, t) { Help = new TriggerHelp( "<seeds>", "Builds reply with markov chains using the specified seeds.") }, new Trigger(MarkovNick, t, "markov-nick", "nicksay") { Help = new TriggerHelp( "<nick> [seeds]", "Builds reply with markov chains based on `seeds`, with the contraint that the words " + "of the reply have been said by `nick` at some point.") }, new Trigger(Remove, t, "markov-remove", "remove") { Help = new TriggerHelp( "<sentence>", "Remove sentence and its constituent words from the markov chains database. " + "(Admin only)") } ); IrcHandlers = new IIrcHandler[] { new IrcHandler <IChannelMsg>(MessageHandler, t) }; }
public IrcRandom(IIrcComm ircComm, IMeidoComm meido) { var threading = TriggerThreading.Threadpool; Triggers = new Trigger[] { new Trigger(Choose, "choose", "decide", "d") { Help = new TriggerHelp( "<option...>", @"Takes a list of options separated by "","" and/or ""or"". " + "If the list of options contains neither, then options will be separated by space.") }, new Trigger(Countdown, threading, "countdown", "cd") { Help = new TriggerHelp( "[seconds]", "Want to simulwatch something? Countdown is the tool for you! Invoking this will provide you " + "with an automatic countdown (default/min: 3s, max: 10s) and a spectacular launch!") }, new Trigger(EightBall, threading, "8ball") { Help = new TriggerHelp( "[question]", "Ask the Magic 8-Ball any yes or no question.") } }; // Setting up configuration. var xmlConf = new XmlConfig2 <Config>( Config.DefaultConfig(), (xml) => new Config(xml), meido.CreateLogger(this), Configure ); meido.LoadAndWatchConfig("RandomChoice.xml", xmlConf); irc = ircComm; }
public MiscUtils(IIrcComm ircComm, IMeidoComm meido) { irc = ircComm; log = meido.CreateLogger(this); timerTrig = new TimerTrigger(); var timerHelp = new TriggerHelp( "<duration> [message]", "Starts a timer. Duration is either in the form of '1h45m30s' (where each part, h/m/s, is optional) or " + "just a number, which is taken to be minutes. If called with no arguments this'll give an overview of " + "all your running timers.", new CommandHelp( "stop", "[index]", "Stops previously started timer. If called without an index all timers are stopped."), new CommandHelp( "change", "<index> <delta>", "Change previously started timer by `delta`. Delta is either in the form of '1h45m30s' or just " + "minutes as a bare number. Delta can be prefixed with either + or -, to substract or add to " + "the timer (in fact, the shorthand requires you do so).\nShorthand: timer <delta> [index]") ); Triggers = new Trigger[] { new Trigger("timer", timerTrig.Timer) { Help = timerHelp }, new Trigger("say", Say) { Help = new TriggerHelp( "[channel] <message>", "If bot is in the specified channel, send message to the channel. If no channel is given, " + "message will be sent to current channel.") } }; }
public UrlTitler(IIrcComm irc, IMeidoComm meido) { this.meido = meido; log = meido.CreateLogger(this); manager = new ChannelThreadManager(irc, log); qTriggers = new QueryTriggers(); // Setting up main configuration. var xmlConf = new XmlConfig2 <Config>( Config.DefaultConfig(), (xml) => new Config(xml), log, manager.Configure, qTriggers.Configure ); meido.LoadAndWatchConfig("UrlTitling.xml", xmlConf); // Setting up black- and whitelist configuration. meido.LoadAndWatchConfig("blacklist", WrappedIO(LoadBlacklist)); meido.LoadAndWatchConfig("whitelist", WrappedIO(LoadWhitelist)); // For handling messages/actions that can potentially containg URL(s). IrcHandlers = new IIrcHandler[] { new IrcHandler <IIrcMsg>(UrlHandler) }; // Trigger handling. Triggers = Trigger.Group( new Trigger("disable", Disable, TriggerOption.ChannelOnly) { Help = new TriggerHelp( "Temporarily disable URL-Titling for you in current channel.") }, new Trigger("enable", Enable, TriggerOption.ChannelOnly) { Help = new TriggerHelp( "Re-enable (previously disabled) URL-Titling for you.") } ).AddGroup( new Trigger(msg => qTriggers.Query(msg, false), TriggerThreading.Threadpool, "query", "q") { Help = new TriggerHelp( "<url...>", "Query given URL(s) and return title or error.") }, new Trigger(msg => qTriggers.Query(msg, true), TriggerThreading.Threadpool, "query-dbg", "qd") { Help = new TriggerHelp( "<url...>", "Query given URL(s) and return title or error. (Includes extra information)") } ).AddGroup( new Trigger("dump", Dump) { Help = new TriggerHelp( "<url...>", "Dumps HTML content of given URL(s) to a local file for inspection. (Owner only)") } ); }