// -------- 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); } }