Created
October 2, 2009 11:43
-
-
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.
This file contains hidden or 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
#!/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