コード例 #1
0
        // ---------------- Functions ----------------

        public void Init(PluginInitor pluginInit)
        {
            string configPath = Path.Combine(
                pluginInit.ChaskisConfigPluginRoot,
                "HttpServer",
                "HttpServerConfig.xml"
                );

            this.config = XmlLoader.LoadConfig(configPath);
            this.log    = pluginInit.Log;

            IChaskisEventCreator eventCreator = pluginInit.ChaskisEventCreator;

            ChaskisEventHandler coreEvent = eventCreator.CreateCoreEventHandler(
                ChaskisEventProtocol.IRC,
                this.OnConnect
                );

            this.handlers.Add(coreEvent);

            ConnectedEventConfig connectedEventConfig = new ConnectedEventConfig
            {
                ConnectedAction = this.OnConnect
            };

            this.handlers.Add(
                new ConnectedEventHandler(connectedEventConfig)
                );
        }
コード例 #2
0
        // ---------------- Functions ----------------

        public void Init(PluginInitor initor)
        {
            this.chaskisEventCreator = initor.ChaskisEventCreator;
            this.eventSender         = initor.ChaskisEventSender;
            this.ircConfig           = initor.IrcConfig;
            this.logger = initor.Log;

            this.pluginDir = Path.Combine(
                initor.ChaskisConfigPluginRoot,
                "NewVersionNotifier"
                );

            string configPath = Path.Combine(
                this.pluginDir,
                "NewVersionNotifierConfig.xml"
                );

            this.config = XmlLoader.LoadConfig(configPath);

            this.cachedFilePath = Path.Combine(
                this.pluginDir,
                cacheFileName
                );

            if (File.Exists(this.cachedFilePath) == false)
            {
                this.cachedVersion = string.Empty;
            }
            else
            {
                string[] lines = File.ReadAllLines(this.cachedFilePath);
                if (lines.Length == 0)
                {
                    this.cachedVersion = string.Empty;
                }
                else
                {
                    this.cachedVersion = lines[0].Trim();
                }
            }

            ChaskisEventHandler eventHandler = this.chaskisEventCreator.CreatePluginEventHandler(
                "chaskis",
                this.HandleChaskisEvent
                );

            this.ircHandlers.Add(eventHandler);

            JoinHandlerConfig joinHandlerConfig = new JoinHandlerConfig
            {
                JoinAction    = this.OnJoinChannel,
                RespondToSelf = true
            };
            JoinHandler joinHandler = new JoinHandler(joinHandlerConfig);

            this.ircHandlers.Add(joinHandler);
        }
コード例 #3
0
ファイル: WelcomeBot.cs プロジェクト: Stefancanvas/Chaskis
        /// <summary>
        /// An initor that is used if we already know the config object.
        /// </summary>
        public void Init(PluginInitor initor, WelcomeBotConfig config)
        {
            if (this.isLoaded == false)
            {
                this.eventCreator = initor.ChaskisEventCreator;
                this.eventSender  = initor.ChaskisEventSender;

                if (config.EnableJoinMessages)
                {
                    JoinHandlerConfig joinHandlerConfig = new JoinHandlerConfig
                    {
                        JoinAction = this.JoinMessage
                    };
                    this.handlers.Add(new JoinHandler(joinHandlerConfig));
                }

                if (config.EnablePartMessages)
                {
                    PartHandlerConfig partHandlerConfig = new PartHandlerConfig
                    {
                        PartAction = PartMessage
                    };
                    this.handlers.Add(new PartHandler(partHandlerConfig));
                }

                if (config.EnableKickMessages)
                {
                    KickHandlerConfig kickHandlerConfig = new KickHandlerConfig
                    {
                        KickAction = KickMessage
                    };

                    this.handlers.Add(new KickHandler(kickHandlerConfig));
                }

                if (config.EnableJoinMessages && config.KarmaBotIntegration)
                {
                    ChaskisEventHandler karmaHandler = this.eventCreator.CreatePluginEventHandler(
                        "karmabot",
                        HandleKarmaQuery
                        );
                    this.handlers.Add(karmaHandler);
                }

                this.isLoaded = true;
            }
        }
コード例 #4
0
        // ---- Version Command Handler ----

        private void AddVersionHandler()
        {
            string versionCommand = "^[!@]" + this.ircConfig.Nick + @":?\s+version(\s+(?<pluginName>\w+))?";

            MessageHandlerConfig messageHandlerConfig = new MessageHandlerConfig
            {
                LineRegex  = versionCommand,
                LineAction = this.HandleVersionCommand
            };

            MessageHandler versionHandler = new MessageHandler(
                messageHandlerConfig
                );

            this.handlers.Add(versionHandler);

            ChaskisEventHandler chaskisHandler = this.chaskisEventCreator.CreatePluginEventHandler(
                this.HandleChaskisVersionCommand
                );

            this.handlers.Add(chaskisHandler);
        }
コード例 #5
0
        // -------- Functions --------

        /// <summary>
        /// Inits this plugin.
        /// </summary>
        /// <param name="pluginInit">The class that has information required for initing the plugin.</param>
        public void Init(PluginInitor initor)
        {
            string karmaBotRoot = Path.Combine(
                initor.ChaskisConfigPluginRoot,
                "KarmaBot"
                );

            string dbPath = Path.Combine(
                karmaBotRoot,
                "karmabot.ldb"
                );

            string configPath = Path.Combine(
                karmaBotRoot,
                "KarmaBotConfig.xml"
                );

            if (File.Exists(configPath) == false)
            {
                throw new FileNotFoundException(
                          "Can not open " + configPath
                          );
            }

            this.config       = XmlLoader.LoadKarmaBotConfig(configPath);
            this.dataBase     = new KarmaBotDatabase(dbPath);
            this.eventSender  = initor.ChaskisEventSender;
            this.eventCreator = initor.ChaskisEventCreator;

            {
                MessageHandlerConfig msgConfig = new MessageHandlerConfig
                {
                    LineRegex  = this.config.IncreaseCommandRegex,
                    LineAction = HandleIncreaseCommand
                };

                MessageHandler increaseHandler = new MessageHandler(
                    msgConfig
                    );
                this.handlers.Add(increaseHandler);
            }

            {
                MessageHandlerConfig msgConfig = new MessageHandlerConfig
                {
                    LineRegex  = this.config.DecreaseCommandRegex,
                    LineAction = HandleDecreaseCommand
                };

                MessageHandler decreaseCommand = new MessageHandler(
                    msgConfig
                    );
                this.handlers.Add(decreaseCommand);
            }

            {
                MessageHandlerConfig msgConfig = new MessageHandlerConfig
                {
                    LineRegex  = this.config.QueryCommand,
                    LineAction = HandleQueryCommand
                };

                MessageHandler queryCommand = new MessageHandler(
                    msgConfig
                    );
                this.handlers.Add(queryCommand);
            }

            {
                ChaskisEventHandler chaskisQuery = initor.ChaskisEventCreator.CreatePluginEventHandler(
                    this.HandleChaskisQueryCommand
                    );
                this.handlers.Add(chaskisQuery);
            }
        }