Chinaunix首页 | 论坛 | 博客
  • 博客访问: 212801
  • 博文数量: 70
  • 博客积分: 2050
  • 博客等级: 大尉
  • 技术积分: 700
  • 用 户 组: 普通用户
  • 注册时间: 2006-07-15 21:42
文章分类

全部博文(70)

文章存档

2013年(1)

2011年(5)

2010年(3)

2009年(9)

2008年(17)

2007年(6)

2006年(29)

我的朋友

分类: Python/Ruby

2006-07-20 12:44:21

#
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(, '123456')
msn.sync_friend_list()
while True:
    msn.process(chats = True)
    time.sleep(1)
阅读(991) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~