Beispiel #1
0
        static void Main(string[] args)
        {
            //to ignore untrusted SSL certificates, linux and mono love it ;)
            ServicePointManager.ServerCertificateValidationCallback = Network.Ssl.Validator;
            Console.CancelKeyPress += Console_CancelKeyPress;
            if (!File.Exists(Config.DbFile) || InitFromCode || args.Length > 0 && args[0] == "init")
            {
                try
                {
                    DbCore.Initialization();
                }
                catch (Exception e)
                {
                    Console.WriteLine("Unknown DBCore exception: " + e.Message + "\n" + e.InnerException);
                }
            }

            Console.WriteLine("Starting Bot...");
            try
            {
                if (!Directory.Exists(Config.DbDirPath))
                {
                    Directory.CreateDirectory(Config.DbDirPath);
                }
                Bot.HockeyBot.Start();
            }
            catch (Exception e)
            {
                Console.WriteLine("Unknown KLHockey Bot exception: " + e.Message + "\n" + e.InnerException);
                Console.WriteLine("Bot will be terminated.");
            }
        }
Beispiel #2
0
        private static void OnAdminCommandMessage(object sender, AdminMessageEventArgs args)
        {
            var command   = args.Command;
            var messageId = args.CurrentPoll.MessageId;
            var chatId    = args.Chat.Id;

            if (command == "admin_init")
            {
                try
                {
                    _db.Disconnect();
                    DbCore.Initialization();
                    _db       = new DbCore();
                    _commands = new CommandProcessor(_bot, _db);
                }
                catch (Exception e)
                {
                    Console.WriteLine("Unknown DBCore exception: " + e.Message + "\n" + e.InnerException);
                }
            }
        }