// Inserts data into the plugin instance on load, kicking off self-initialization in the process internal void Init(string name, IRCQueueBot q, ConnectionService cs, EventDispatcher disp) { _name = name; _q = q; _cs = cs; _disp = disp; SetupFilter(); }
static int Main(string[] args) { string userConfigFile = null; // Parse parameters foreach (var arg in args) { #if DEBUG if (arg == "-ircdebug") IrcDebugToStdError = true; #endif if (arg.StartsWith("-config=")) { userConfigFile = arg.Substring(8); } } // Get configuration loaded IniConfiguration conf; string confPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + Path.DirectorySeparatorChar + (userConfigFile ?? "settings.ini"); try { conf = new IniConfiguration(confPath); } catch (FileNotFoundException) { if (userConfigFile == null) { using (StreamWriter wr = new StreamWriter(new FileStream(confPath, FileMode.Append), Encoding.UTF8)) { wr.WriteLine(Properties.Resources.ConfigTemplate); } Console.Error.WriteLine("Configuration file settings.ini was not found. A new one has been created for you."); Console.Error.WriteLine("Edit it to suit your needs and try again."); } else { Console.Error.WriteLine("Specified configuration file was not found."); } return 1; } // Prepare main class _q = new IRCQueueBot(conf); try { _q.LoadServices(); } catch (Exception) { // Despite an exception thrown, some logging events may have made it into the queue. // Continuing normally, exiting only after the queue has been cleared. _q.Enqueue(new ExitErrorSignal()); } _q.Enqueue(new BotStartSignal()); // Hook up console cancel handler and exception reporter Console.CancelKeyPress += Console_CancelKeyPress; AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; // Enter main loop return _q.RunQueue(); }