// -------- Functions -------- /// <summary> /// Initializes the plugin. This includes loading any configuration files, /// starting services, etc. Allowed to throw Exceptions. /// /// This function should be used to validates that the environment is good for the plugin. /// For example, it has all dependencies installed, config files are in the correct spot, etc. /// It should also load GetHandlers() with the handlers. /// </summary> /// <param name="pluginPath"> /// The absolute path to the plugin, including the file name. To just get /// the path to the plugin, call Path.GetDirectoryName on this argument. /// </param> /// <param name="ircConfig">The IRC config we are using.</param> public void Init(string pluginPath, IIrcConfig ircConfig) { string configPath = Path.Combine( Path.GetDirectoryName(pluginPath), "UserListBotConfig.xml" ); if (File.Exists(configPath) == false) { throw new FileNotFoundException( "Can not open " + configPath ); } this.ircConfig = ircConfig; this.userListConfig = XmlLoader.LoadConfig(configPath); // User query command: { MessageHandler userQueryHandler = new MessageHandler( this.userListConfig.Command.Replace("{%nick%}", this.ircConfig.Nick), this.HandleGetUsersCommand, this.userListConfig.Cooldown ); this.handlers.Add(userQueryHandler); } { AllHandler nameResponseHandler = new AllHandler(HandleNamesResponse); this.handlers.Add(nameResponseHandler); } { AllHandler endOfNamesHandler = new AllHandler(HandleEndOfNamesResponse); this.handlers.Add(endOfNamesHandler); } }