Example #1
0
        public static void Main(string[] args)
        {
            if (Environment.UserInteractive)
            {
                IrcBot bot;

                if (args.Length > 0)
                {
                    switch (args[0])
                    {
                        case "--install":
                            ManagedInstallerClass.InstallHelper(new[] { Assembly.GetExecutingAssembly().Location });
                            return;
                        case "--uninstall":
                            ManagedInstallerClass.InstallHelper(new[] { "/u", Assembly.GetExecutingAssembly().Location });
                            return;
                        case "--simulator":

                            break;
                        case "--config":
                            Tool.Configure();
                            return;
                        case "--help":
                            return;
                        case "--plugin-command":
                            bot = new IrcBot();
                            var manager = new BotPluginManager(bot, "plugins");
                            manager.StartUp();
                            bot.CallExportedCommand(args[1], string.Concat(args.Skip(2)), manager);
                            manager.ShutDown();
                            return;
                    }
                }
                Tool.RunOnMono();

                do
                {
                    bot = GetBot();

                    if (bot == null)
                    {
                        break;
                    }

                } while (bot.Start());

                Settings.Default.Save();
            }
            else
            {

                try
                {
                    var servicesToRun = new ServiceBase[] { new ServiceEngine { Bot = GetBot() } };
                    ServiceBase.Run(servicesToRun);
                }
                catch (Exception exception)
                {
                    Log.Instance.Log(exception);
                }
            }
        }