示例#1
0
        static void Main(string[] args)
        {
            TwitchChatBot bot = new TwitchChatBot();

            bot.Connect();
            Console.ReadLine();
            bot.Disconnect();
        }
示例#2
0
        static void Main(string[] args)
        {
            TwitchChatBot bot = new TwitchChatBot();

            try
            {
                bot.Connect();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }


            do
            {
                String input = Console.ReadLine().ToLower();

                String argument = input.Substring(input.IndexOf(' ') + 1);

                String command = input.Substring(0, input.IndexOf(' '));

                switch (command)
                {
                case "volume":
                    bot.setVolume(Int32.Parse(argument));
                    break;

                case "rate":
                    bot.setRate(Int32.Parse(argument));
                    break;

                default:
                    break;
                }
            } while (true);
        }
示例#3
0
        static void Main(string[] args)
        {
            //Title of the console window
            Console.Title = "Simple Twitch Chat Bot " + version;

            // Turn off Quick Edit Mode
            DisableConsoleQuickEdit.SetQuickEdit(true);

            // SecurityProtocol SSL/TSL
            ServicePointManager.Expect100Continue = true;
            ServicePointManager.SecurityProtocol  = SecurityProtocolType.Tls12;

            //Load in information from external Config.txt source.
            LoadLocalization();

            try
            {
                if (data[0]["Host"] == string.Empty || data[0]["BotName"] == string.Empty || data[0]["BotName"] == string.Empty || data[0]["oAuthPassword"] == string.Empty || data[0]["ChannelName"] == string.Empty || data[0]["OnlineMode"] == string.Empty || data[0]["OnlineURL"] == string.Empty || data[0]["DEBUG"] == string.Empty)
                {
                    Console.WriteLine("Config.txt is not configured correctly. Message: Empty config entry found.");
                    Thread.Sleep(8000);
                    Environment.Exit(0);
                }

                if (data[0]["DEBUG"].ToUpper() == "TRUE")
                {
                    debug = true;
                }
                else
                {
                    debug = false;
                }

                // We create the chatbot object
                twitchChatBot = new TwitchChatBot(data[0]["Host"], Int32.Parse(data[0]["Port"]), data[0]["BotName"], data[0]["oAuthPassword"], data[0]["ChannelName"], data[0]["OnlineMode"], data[0]["OnlineURL"], true);
                Console.WriteLine("Client commands? Write \"help\" or \"commands\"");
            }
            catch (KeyNotFoundException e)
            {
                //This is the result of the external data being wrong.
                Console.WriteLine("Config.txt is not configured correctly. Message: " + e);
                Thread.Sleep(8000);
                Environment.Exit(0);
            }

            // This will keep the console window open and also be used as a command prompt.
            while (true)
            {
                switch (Console.ReadLine().ToLower()) // Catch input and convert to lowercase.
                {
                case "help":
                case "commands":
                    Console.Clear();
                    Console.WriteLine("\"help\", \"commands\" will show this console window.");
                    Console.WriteLine("\"reset\" will reset the counter and clear memory.");
                    Console.WriteLine("\"reconnect\" will reconnect the bot but keep data.");
                    Console.WriteLine("\"stats\", \"status\", \"count\" will print out data from the current session.");
                    Console.WriteLine("\"clear\" will clear the console.");
                    Console.WriteLine("\"upload\" will upload the statistics data to the server.(If online-mode is set \"TRUE\")");
                    Console.WriteLine("\"quit\", \"exit\" will shutdown the bot.");
                    break;

                case "reconnect":     // Reconnect and save data
                    Data bot_data = ObjectClone <Data>(twitchChatBot.data);
                    twitchChatBot.KillThreads();
                    twitchChatBot      = new TwitchChatBot(data[0]["Host"], Int32.Parse(data[0]["Port"]), data[0]["BotName"], data[0]["oAuthPassword"], data[0]["ChannelName"], data[0]["OnlineMode"], data[0]["OnlineURL"], true);
                    twitchChatBot.data = bot_data;
                    break;

                case "reset":
                    twitchChatBot.data = new Data();
                    Console.Clear();
                    Console.WriteLine("Program reset! Online stats are refreshed upon next !hungry command.");
                    break;

                case "stats":
                case "status":
                case "count":
                    Console.Clear();
                    Console.WriteLine("The word \"hungry\" has been said " + twitchChatBot.data.hungry.timesHungry.ToString() + " time(s). Total count of !hungry is " + twitchChatBot.data.hungry.timesHungryTotal.ToString() + ". This session: " + twitchChatBot.data.hungry.session_timesHungry.ToString() + " time(s) - Total: " + twitchChatBot.data.hungry.session_timesHungryTotal.ToString());
                    Console.WriteLine("Death has been registered " + twitchChatBot.data.hungry.timesHungry.ToString() + " time(s). Total count of death (command) is " + twitchChatBot.data.hungry.timesHungryTotal.ToString() + ". This session: " + twitchChatBot.data.deaths.session_deaths.ToString() + " time(s) - Total: " + twitchChatBot.data.deaths.session_deathsTotal.ToString());
                    break;

                case "clear":
                    Console.Clear();
                    break;

                case "upload":
                    Console.Clear();
                    if (twitchChatBot.connectionData.onlineMode)
                    {
                        twitchChatBot.SendData();
                    }
                    break;

                case "quit":
                case "exit":
                    Environment.Exit(0);
                    break;
                }
            }
        }