简单的MSN机器人

#
msnp.py: MSN messaging in Python

import msnp
import time
class MsnChatListener(msnp.ChatCallbacks):
    def message_received(self, passport_id, display_name, text, charset):
        print '%s: %s' % (passport_id, text)
        self.chat.send_message(text, charset)

class MsnListener(msnp.SessionCallbacks):
    def chat_started(self, chat):
        callbacks=MsnChatListener()
        chat.callbacks = callbacks
        callbacks.chat = chat
    def state_changed(self, state):
        if state == msnp.States.ONLINE:
            print 'You are now online.'
msn = msnp.Session(MsnListener())
msn.login(
[email='ipv9socket@hotmail.com']'ipv9socket@hotmail.com'[/email]
, '123456')
msn.sync_friend_list()
while True:
    msn.process(chats = True)
    time.sleep(1)