From c7ecdba13fb19812e0cd83b798abbcf8db8db249 Mon Sep 17 00:00:00 2001 From: ThoughtfulCerebral Date: Wed, 14 Mar 2018 11:47:48 +0100 Subject: [PATCH] Fixed bot disconnecting and not reading chat. I forgot to add a reply to Twitch's IRC "PING" message. If the bot doesn't reply to it, then the bot won't be able to read chat or reply / type in chat. Fixed it by sending back "PONG :tmi.twitch.tv\r\n" to Twitch. --- TwitchBot.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/TwitchBot.rb b/TwitchBot.rb index b62b036..bcda2ef 100644 --- a/TwitchBot.rb +++ b/TwitchBot.rb @@ -67,6 +67,17 @@ Thread.start do ready[0].each do |s| line = s.gets + # Respond to Twitch IRC "PING" Message + if line.index("PING") == 0 + line.strip! + socket.puts("PONG :tmi.twitch.tv\r\n") + log.info("[IRC Message]: " + line) + log.info("[IRC Response]: PONG :tmi.twitch.tv") + puts("-".bold.red*line.length) + puts "[Twitch] ".bold.cyan + "IRC: ".bold.yellow + line.bold.green + puts "[Response] ".bold.cyan + "IRC: ".bold.yellow + "PONG :tmi.twitch.tv".bold.green + puts("-".bold.red*line.length) + end match = line.match(/^:(.+)!(.+)PRIVMSG ##{CHANNEL} :(.+)$/) message = match && match[3] if message =~ /^/