plugins/chat_plugin.py
author Mikael Berthe <mikael@lilotux.net>
Sun, 20 May 2007 09:46:49 +0200
changeset 39 2123977057c5
parent 17 069f7fd5545d
permissions -rw-r--r--
Cleanup patch from Loic Berthe

#$ 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)