Skip to content

Instantly share code, notes, and snippets.

@0x0dea
Created November 12, 2015 00:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 0x0dea/a715674678191e83bf5d to your computer and use it in GitHub Desktop.
Save 0x0dea/a715674678191e83bf5d to your computer and use it in GitHub Desktop.
require 'socket'
nick = 'foo'
channels = %w[#foo #bar]
s = TCPSocket.new 'irc.freenode.net', 6667
s.puts "NICK #{nick}"
s.puts "USER #{nick} 0 * :#{nick}"
s.puts "JOIN #{channels * ?,}"
loop do
msg = s.gets
next s.puts("PONG #$1") if msg[/PING (\S+)/]
/:(?<nick>[^!]+)\S+ PRIVMSG (?<channel>\S+) :(?<message>.+)/ =~ msg
s.puts "PRIVMSG #{channel} :#{nick}: #{message}"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment