//constructor public Pinger(TwitchChatBot myClient) { this.myClient = myClient; pingSender = new Thread(new ThreadStart(this.Run)); }
//main function static void Main(string[] args) { //Testing writing to line Console.WriteLine("Hello World!"); //New up a List of TwitchChatBot objects List <TwitchChatBot> chatBots = new List <TwitchChatBot>(); //add each channel to the list for (int i = 0; i < channels_to_join.Count; i++) { chatBots.Add(new TwitchChatBot(login_name, token, channels_to_join[i])); } //for each chatBot... for (int i = 0; i < chatBots.Count; i++) { //this chatBot TwitchChatBot chatBot = chatBots[i]; //Connect to Twitch IRC chatBot.Connect(); //Start Pinger Pinger pinger = new Pinger(chatBot); pinger.Start(); } //Read message until we quit while (true) { //for each chatBot... for (int i = 0; i < chatBots.Count; i++) { //this chatbot TwitchChatBot chatBot = chatBots[i]; //if we get disconnected, reconnect if (!chatBot.Client.Connected) { chatBot.Connect(); } //else we're connected else { //get the message that just came through string msg = chatBot.ReadMessage(); //did we receive a message? if (msg != "" && msg != null) { //write the raw message to the console Console.WriteLine(msg); //response string string toRespond = ""; //If PING respond with PONG if (msg.Length >= 4 && msg.Substring(0, 4) == "PING") { chatBot.SendPong(); } //Trim the message to just the chat message piece string msgTrimmed = trimMessage(msg); //Handling commands if (msgTrimmed.Length >= 6 && msgTrimmed.Substring(0, 6) == "!8ball") { toRespond = chatBot.Command_MagicEightBall(); } else if (msgTrimmed == "!age") { toRespond = chatBot.Command_Age(); } else if (msgTrimmed == "!discord") { toRespond = chatBot.Command_Discord(); } //Write response to console and send message to chat Console.WriteLine(toRespond); //Send the message to chat chatBot.SendMessage(toRespond); } } } } }