Esempio n. 1
0
 void SetupPatterns()
 {
     if (feedPatterns == null)
     {
         string patternsFile = meido.DataPathTo("nyaapatterns.xml");
         feedPatterns = new Patterns(TimeSpan.FromMinutes(1))
         {
             FileLocation = patternsFile
         };
         try
         {
             feedPatterns.Deserialize();
         }
         catch (System.IO.FileNotFoundException)
         {}
     }
 }
Esempio n. 2
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>();
        }
    }
Esempio n. 3
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)
        };
    }