import xchat

version = "1.0.2"

## XChat port of Tollef Fog Heen's contentless ping script
__module_name__ = "ContentlessPing"
__module_version__ = version
__module_description__ = "Respond to contentless pings with contentless pongs"
__module_author__ = "dann frazier"

import re

PongMsg = "You sent me a contentless ping. This is a contentless pong. Please provide a bit of information about what you want and I'll respond when I am around."

def privping(word, word_eol, userdata):
	if len(word) == 2 and word[1] == "ping":
		xchat.command("msg %s %s" % (word[0], PongMsg))

def pubping(word, word_eol, userdata):
	tome = re.compile("^%s[:,]?\s*ping$" % (xchat.get_info('nick')))
	if tome.match(word[1]):
		xchat.command("msg %s %s" % (word[0], PongMsg))
		
xchat.hook_print("Channel Msg Hilight", pubping)
xchat.hook_print("Private Message to Dialog", privping)

## Untested
#xchat.hook_print("Channel Message", pubping)
# xchat.hook_print("Private Message", pubping)
		 
print "ContentlessPing", version, "loaded."

