Skip to content

Instantly share code, notes, and snippets.

@rwaldron
Forked from wagenet/irc-counter.rb
Created March 16, 2011 21:44
Show Gist options
  • Save rwaldron/873373 to your computer and use it in GitHub Desktop.
Save rwaldron/873373 to your computer and use it in GitHub Desktop.
#!/usr/local/bin/ruby
require "socket"
irc = TCPSocket.open('irc.freenode.net', 6667)
irc.send("USER blah blah blah :blah blah\n", 0)
irc.send("NICK ChanScanBot\n", 0)
irc.send("JOIN #sproutcore\n", 0)
names = []
until irc.eof?
data = irc.gets
break if data =~ /^:\S+ 366/ # End of NAMES
if data =~ /^:\S+ 353/ # NAMES
names += data.split(':').last.split(' ')
end
end
names.delete_if{|n| n =~ /ChanScanBot/}
irc.send("QUIT\n", 0)
puts "#{names.count} Users"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment