Example #1
0
    public IrcTell(IIrcComm irc, IMeidoComm meido)
    {
        var threading = TriggerThreading.Queue;

        Triggers = Trigger.Group(

            new Trigger("tell", Tell, threading)
        {
            Help = new TriggerHelp(
                "[<nick> <message>] | [count]",
                "Store message for nick, will be relayed when nick is active. If called with 1 or 0 arguments " +
                "this will read your tells, up to `count`.")
        },

            new Trigger(Read, threading, "tell-read", "tells")
        {
            Help = new TriggerHelp(
                "[count]",
                "Read stored tell messages, up to `count` (defaults to 5).")
        },

            new Trigger("tell-clear", Clear, threading)
        {
            Help = new TriggerHelp(
                "Clears all your stored tell messages.")
        }
            );

        IrcHandlers = new IIrcHandler[] {
            new IrcHandler <IChannelMsg>(MessageHandler, threading)
        };

        this.irc = irc;
        inboxes  = new Inboxes(meido.DataDir);
    }
Example #2
0
    public ChannelThreadManager(IIrcComm irc, ILog log)
    {
        this.irc = irc;
        this.log = log;

        Blacklist = new Blacklist();
        Whitelist = new Whitelist();
    }
Example #3
0
    public FeedReader(IIrcComm irc, ILog log, DateTimeFile dtFile, Patterns patterns)
    {
        this.irc      = irc;
        this.log      = log;
        this.dtFile   = dtFile;
        this.patterns = patterns;

        lastPrintedTime = dtFile.Read();
    }
Example #4
0
    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
            }
        };
    }
Example #5
0
    public IrcSed(IIrcComm irc, IMeidoComm meido)
    {
        IrcHandlers = new IIrcHandler[] {
            new IrcHandler <IChannelMsg>(HandleMessage)
        };

        Help = new TopicHelp[] {
            new TopicHelp(
                "sed",
                "Interprets messages in the form of s/<SEARCH>/<REPLACE>/<FLAGS>. For more information on " +
                "the specifics of the search and replace expressions, see: " +
                "https://msdn.microsoft.com/en-us/library/az24scfc.aspx")
        };

        this.irc = irc;
    }
Example #6
0
    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>();
        }
    }
Example #7
0
        public void LoadPlugins(IIrcComm ircComm, IMeidoComm meidoComm)
        {
            // Create catalog and add our plugin-directory to it.
            var catalog = new AggregateCatalog();

            catalog.Catalogs.Add(new DirectoryCatalog("."));

            // Put it in a container and compose/import the plugins into the pluginContainer field above.
            using (var container = new CompositionContainer(catalog))
            {
                // With thanks to http://stackoverflow.com/questions/7684766/
                container.ComposeExportedValue(ircComm);
                container.ComposeExportedValue(meidoComm);

                container.ComposeParts(this);
            }
            OnPluginLoad();
        }
Example #8
0
    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)
        };
    }
Example #9
0
    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;
    }
Example #10
0
    public ChannelThread(IIrcComm irc,
                         ILog log,
                         Blacklist black,
                         Whitelist white,
                         WebToIrc wIrc,
                         string channel)
    {
        this.irc = irc;
        this.log = log;

        blacklist = black;
        whitelist = white;

        WebToIrc = wIrc;

        Channel       = channel;
        MessageQueue  = new Queue <MessageItem>();
        DisabledNicks = new HashSet <string>();
        ChannelLock   = new object();

        new Thread(Consume).Start();
    }
Example #11
0
    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.")
            }
        };
    }
Example #12
0
    public WebSearches(IIrcComm ircComm, IMeidoComm meido)
    {
        irc = ircComm;

        var sites = new TopicHelp[] {
            new TopicHelp(
                "searches",
                "Supported site specific searches are, with the trigger in parentheses: YouTube (yt), " +
                "Wikipedia EN (wiki), MyAnimeList (mal), AniDB (anidb), MangaUpdates (mu), Visual Novel DB (vndb), " +
                "Steam Store (steam).")
        };

        var t = TriggerThreading.Threadpool;

        Triggers = Trigger.Group(

            new Trigger("g", GoogleSearch, t)
        {
            Help = new TriggerHelp(
                "<query>",
                "Returns the first 3 results of a Google Search on passed query. There are also a number of " +
                "triggers for site specific searches, see the 'searches' help subject for more information.")
            {
                AlsoSee = sites
            }
        },
            new Trigger("yt", YtSearch, t),
            new Trigger("wiki", WikiSearch, t),
            new Trigger("mal", MalSearch, t),
            new Trigger("anidb", AnidbSearch, t),
            new Trigger("mu", MuSearch, t),
            new Trigger("vndb", VndbSearch, t),
            new Trigger("steam", SteamSearch, t)
            // maybe: urbandict, dict, animenewsnetwork
            );
    }
Example #13
0
    public TimeLeft(IIrcComm ircComm, IMeidoComm meido)
    {
        loc = Path.Combine(meido.DataDir, "_timeleft.xml");

        try
        {
            storage = Storage <TimeLeftUnit> .Deserialize(loc);
        }
        catch (FileNotFoundException)
        {
            storage = new Storage <TimeLeftUnit>();
        }

        cleaner = new Timer(Cleaner, null, TimeSpan.FromHours(1), TimeSpan.FromHours(1));

        irc = ircComm;

        Triggers = new Trigger[] {
            new Trigger("timeleft", HandleTrigger)
            {
                Help = new TriggerHelp(
                    "[name]",
                    "Check on the timeleft of `name`, name doesn't have to be exact. If no name is specified, will " +
                    "show all currently tracking names.",

                    new CommandHelp(
                        "set", "<name> <date>",
                        "Date must be in YYYY-MM-DD. Will replace entry if already exists."),

                    new CommandHelp(
                        "del", "<name>",
                        "Removes exact name (case insensitive) from tracking.")
                    )
            }
        };
    }
Example #14
0
    public Calc(IIrcComm irc, IMeidoComm meido)
    {
        Triggers = Trigger.Group(

            new Trigger(HandleTrigger, "calc", "c")
        {
            Help = new TriggerHelp(
                "<expression>",
                "Evaluates mathematical expression. Accepted operators are: addition (+), " +
                "substraction (-), multiplication (*), division (/) and exponentiation (^ and **).")
        },

            new Trigger(DefVar, "defvar", "var")
        {
            Help = new TriggerHelp(
                "<variable> <expression>",
                "Evaluates and assigns expression to variable.")
        }
            );

        IrcHandlers = new IIrcHandler[] {
            new IrcHandler <IQueryMsg>(HandleMessage)
        };
    }
Example #15
0
    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)")
        }
            );
    }
Example #16
0
 public MyClass(IIrcComm irc, IMeidoComm meido)
 {
     meido.RegisterTrigger("example", ExampleTrigger);
 }