#!/usr/bin/python2.4 # # irc_channel_info.py - v0.1 # Copyright (c) 2008 - Rich Burridge - Sun Microsystems Inc. # All Rights Reserved. # # Usage: # python irc_channel_info.py < freenode-channels.txt > channel_info.txt # # where freenode-channels.txt is the output from the XChat application when # doing: Server->List of Channels... ->Save List... # # Script to generate something more readable from the output of the # /list command at irc.freenode.net import sys def main(): for line in sys.stdin.readlines(): if line.startswith("#"): # Determine which separator best breaks up the information. seps = [ "|", "::", "," ] for sep in seps: tokens = line.split(sep) if len(tokens) >= 2: break # Create a list of items with URL links. to_print = [] for token in tokens[1:]: if (token.find("http://") != -1) or \ (token.find("https://") != -1) or \ (token.find("ftp://") != -1): to_print.append(token) # Print out the results with very simple formatting. if len(to_print) != 0: print "%s\n" % tokens[0] for item in to_print: print "\t%s" % item print if __name__ == "__main__": main()