Skip to content

Instantly share code, notes, and snippets.

@0x0dea
Last active August 29, 2015 14:23
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/9057ec28096c2fe8dc69 to your computer and use it in GitHub Desktop.
Save 0x0dea/9057ec28096c2fe8dc69 to your computer and use it in GitHub Desktop.
Hangman autoclicker for #ruby-offtopic (when the category is ruby)
require 'socket'
s = TCPSocket.new 'irc.freenode.net', 6667
s.puts "NICK slowlag"
s.puts "USER slowlag 0 * :slowlag"
s.puts "JOIN #ruby-offtopic"
all = File.read('all').split("\n")
can = all.dup
loop do
msg = s.gets.force_encoding('utf-8')
next s.puts("PONG #$1") if msg[/PING (\S+)/]
next unless msg[/^:DeBot/]
next can = all.dup if msg[/won!/]
msg[/:(\S+) \[(\S*)\] (\d)/]
next can.select! { |c| c.size == $1.size } if $3 == ?0
cs = $1.delete(?␣) + $2
rx = $1.gsub ?␣, "[^#{cs}]"
can.select! { |c| c[/^#{rx}$/i] }
s.puts "PRIVMSG #ruby-offtopic :DeBot: #{can[0]}" if can.size == 1
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment