my first xchat plugin

Wednesday 2009-03-18 05:54 PM EDT

#
# (C) 2009 Zoid Technologies. All Rights Reserved.
#
__module_name__ = "notifysysopwhenlongisonline" 
__module_version__ = "2009031801" 
__module_description__ = "module to look for the 'long' user on all networks and notify sysop"

import xchat

myhook = None 
 
def stop_cb(word, word_eol, userdata): 
  global myhook 
  if myhook is not None: 
    xchat.unhook(myhook) 
    myhook = None 
    print "Timeout removed!" 
                                  
def timeout_cb(userdata):
  notifies = xchat.get_list("notify")
  for n in notifies:
    if n.nick == "long":
      print "checking for 'long'...     (use /stop to disable): ",
      if n.flags == 1:
        print "[ONLINE]"
      else:
        print "[OFFLINE]"
  return 1 # Keep the timeout going 
                                           
myhook = xchat.hook_timer(120000, timeout_cb) 
xchat.hook_command("STOP", stop_cb) 

There is one critical thing to note about this plugin: without the __module_name__ and other symbols, xchat will crash violently and might even require a reboot, even on a Linux workstation. I do not know if this is purposeful or not, but be warned.

The plugin uses a callback that fires every 120 seconds and checks for a specific user. It can be disabled using the "/stop" command from xchat, or the messages can be removed (but the callback will still fire) by removing 'long' from the notify list.

Have a lot of fun....