Last active
August 29, 2015 14:23
-
-
Save 0x0dea/9057ec28096c2fe8dc69 to your computer and use it in GitHub Desktop.
Hangman autoclicker for #ruby-offtopic (when the category is ruby)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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