Skip to content

Instantly share code, notes, and snippets.

@wycats
Forked from wagenet/irc-counter.rb
Created January 6, 2011 18:29
Show Gist options
  • Save wycats/768303 to your computer and use it in GitHub Desktop.
Save wycats/768303 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require "socket"
puts "Connecting to IRC..."
irc = TCPSocket.open('irc.freenode.net', 6667)
irc.send("USER blah blah blah :blah blah\n", 0)
irc.send("NICK ChanScanBot\n", 0)
puts "Joining #sproutcore"
irc.send("JOIN #sproutcore\n", 0)
puts "Getting list of active users"
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/}
puts "Disconnecting"
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