Browse Source

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.
master
ThoughtfulCerebral 6 years ago
committed by GitHub
parent
commit
c7ecdba13f
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 0 deletions
  1. +11
    -0
      TwitchBot.rb

+ 11
- 0
TwitchBot.rb View File

@ -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 =~ /^/

Loading…
Cancel
Save