コード例 #1
0
 public void Dump(ITriggerMsg e)
 {
     // Only allow owner to dump (writing temp files).
     if (meido.AuthLevel(e.Nick) == 3)
     {
         QueryTriggers.Dump(e);
     }
 }
コード例 #2
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)")
        }
            );
    }