//logic for actually monitoring channel. private void ControlLoop() { while (!exit) { string currentTextLine = _inputStream.ReadLine(); /* IRC commands come in one of these formats: * :NICK!USER@HOST COMMAND ARGS ... :DATA\r\n * :SERVER COMAND ARGS ... :DATA\r\n */ //Display received irc message Console.WriteLine(currentTextLine); //if (currentTextLine[0] != ':') continue; //Send pong reply to any ping messages if (currentTextLine.StartsWith("PING ")) { _outputStream.Write(currentTextLine.Replace("PING", "PONG") + "\r\n"); _outputStream.Flush(); } else if (currentTextLine[0] != ':') { continue; } else if (BotCommand.isPotentialCommand(currentTextLine)) { BotCommand command = new BotCommand(currentTextLine); TwitchChannel channel = _channels.Find(c => '#' + c.Name == command.Channel); foreach (ICommandHandler handler in _commandHandlers) { CommandHandlerResult result = handler.ProcessCommand(command, channel).Result; bool breakLoop = false; switch (result.ResultType) { case ResultType.Handled: breakLoop = true; break; case ResultType.HandledWithMessage: SendPrivmsg(result.Channel, result.Message); breakLoop = true; break; default: break; } if (breakLoop) { break; } } } } }