import xchat
__module_name__ = 'autoaway'
__module_version__ = '0.1'
__module_description__ = 'auto-away when you say bbl, foo'

away_triggers = [ 'bbl', 'afk', 'brb', 'bbs', 'bbiab', 'bbiaw' ]
strip_words = [ 'well' ]

def bbl_cb(word, word_eol, userdata): 
	if len(word) >= 1 and (word[0].lower().strip(',-_') in away_triggers or word[-1].lower().strip(',-_') in away_triggers):
		if word[0].strip(',-_') in strip_words:
			away = word_eol[1]
		else:
			away = word_eol[0]
		xchat.command( "AWAY %s" % away )
	return xchat.EAT_NONE

xchat.hook_command("", bbl_cb)
