__module_name__ = "ChanNotifier" __module_version__ = "1.0" __module_description__ = "Notifies on all activities on select channels" import xchat, os.path hook = None channels = [] def servmsg_cb(word , word_eol, userdata): global channels try: if channels.index(word[3]): do_notify() except ValueError: pass xchat.prnt(word_eol[0]) return None def load(): global hook, channels, __module_name__ preffile = "~/.xchat2/channotifiers.dat" FILE = open(os.path.expanduser(preffile), "r") while FILE: line = FILE.readline() channels.append(line) hook = xchat.hook_server("PRIVMSG", servmsg_cb) xchat.prnt("%s Loaded" % __module_name__) def unload_cb(userdata): global hook, channels, __module_name__ if hook is not None: xchat.unhook(hook) hook = None channels = [] xchat.prnt("%s Unloaded" % __module_name__) def do_notify(): print "I should be notifying now!" load() xchat.hook_unload(unload_cb)