plugins/chat_plugin.py
author Mikael Berthe <mikael@lilotux.net>
Mon, 07 May 2007 11:59:17 +0200
changeset 35 8daaa0b29b71
parent 17 069f7fd5545d
permissions -rw-r--r--
Enable log_plugin

#$ neutron_plugin 01

def chat_personal(type, source, body):
	replies = ['What\'s that?', 'I don\'t understand.', 'Huh... Pardon?']
	reply = random.choice(replies)
	if type == 'public':
		if source[1]:
			smsg(type, source, reply)
	elif type == 'private':
		smsg(type, source, reply)

def handler_chat_message(type, source, body):
	if type == 'public':
		firstword = string.split(body)[0]
		if string.split(string.split(firstword, '_')[0], ':')[0].lower() == 'mcbot' and firstword[-1] == ':':
			if len(string.split(body)) > 1:
				parameters = body[(body.find(' ') + 1):]
			else:
				parameters = ''
			chat_personal(type, source, parameters)
	elif type == 'private':
		if not COMMANDS.has_key(string.split(body)[0]):
			chat_personal(type, source, body)

#register_message_handler(handler_chat_message)