// -------- Functions -------- /// <summary> /// Inits this plugin. /// </summary> /// <param name="pluginPath">Path to the plugin DLL</param> /// <param name="ircConfig">The IRC config being used.</param> public void Init(string pluginPath, IIrcConfig ircConfig) { string dbPath = Path.Combine( Path.GetDirectoryName(pluginPath), "karmabot.db" ); string configPath = Path.Combine( Path.GetDirectoryName(pluginPath), "KarmaBotConfig.xml" ); if (File.Exists(configPath) == false) { throw new FileNotFoundException( "Can not open " + configPath ); } this.config = XmlLoader.LoadKarmaBotConfig(configPath); this.dataBase = new KarmaBotDatabase(dbPath); MessageHandler increaseHandler = new MessageHandler( this.config.IncreaseCommandRegex, HandleIncreaseCommand ); MessageHandler decreaseCommand = new MessageHandler( this.config.DecreaseCommandRegex, HandleDecreaseCommand ); MessageHandler queryCommand = new MessageHandler( this.config.QueryCommand, HandleQueryCommand ); this.handlers.Add(increaseHandler); this.handlers.Add(decreaseCommand); this.handlers.Add(queryCommand); }
// -------- 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); } }