Skip to content

Instantly share code, notes, and snippets.

@FiXato
Created October 2, 2009 11:43
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 FiXato/199680 to your computer and use it in GitHub Desktop.
Save FiXato/199680 to your computer and use it in GitHub Desktop.
get a list of nicknames used by a series of hosts from the UnrealIRCd connects log.
#!/usr/bin/env ruby
# A simple script to get a list of nicknames used by a series of hosts from the UnrealIRCd connects log.
require 'set'
CONNECTS_LOG_PATH = File.expand_path('~/UnrealIRCd/logs/connects.log')
hosts = ARGV
if hosts.size == 0
puts('Get a list of nicknames used by a series of hosts from the UnrealIRCd connects log.')
abort('Usage: get_nicks_by_hosts host1 [host2] [..] [hostn]')
end
def get_nick(line)
cols = line.split(' ')
return cols[7] if line.include?('JOIN')
return cols[7] if line.include?('PART')
return cols[8].split('!')[0] if line.include?('Connect')
return cols[9].split('!')[0] if line.include?('Disconnect')
end
used_nicks = Set.new
hosts.each do |host|
lines = `grep #{host} #{CONNECTS_LOG_PATH}`.squeeze(' ').strip.split("\n")
lines.each do |line|
if nick = get_nick(line)
used_nicks << nick
end
end
end
puts used_nicks.to_a.sort.join("\n")
nil
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment