plugins/chat_plugin.py
changeset 0 93b25987d3e5
child 6 ad3de9374276
equal deleted inserted replaced
-1:000000000000 0:93b25987d3e5
       
     1 #$ neutron_plugin 01
       
     2 
       
     3 def chat_personal(type, source, body):
       
     4 	replies = ['What\'s that?', 'I don\'t understand.', 'Huh... Pardon?']
       
     5 	reply = random.choice(replies)
       
     6 	if type == 'public':
       
     7 		if source[1]:
       
     8 			smsg(type, source, reply)
       
     9 	elif type == 'private':
       
    10 		smsg(type, source, reply)
       
    11 
       
    12 def handler_chat_message(type, source, body):
       
    13 	if type == 'public':
       
    14 		firstword = string.split(body)[0]
       
    15 		if string.split(string.split(firstword, '_')[0], ':')[0].lower() == 'mcbot' and firstword[-1] == ':':
       
    16 			if len(string.split(body)) > 1:
       
    17 				parameters = body[(body.find(' ') + 1):]
       
    18 			else:
       
    19 				parameters = ''
       
    20 			chat_personal(type, source, parameters)
       
    21 	elif type == 'private':
       
    22 		if not COMMANDS.has_key(string.split(body)[0]):
       
    23 			chat_personal(type, source, body)
       
    24 
       
    25 register_message_handler(handler_chat_message)