Пример #1
0
 def fetchForever(self):
     try:
         INFO('已在后台运行 fetchForever 方法,每隔 5 分钟获取一次联系人资料')
         while True:
             time.sleep(300)
             yield Message('fetchcomplete', contacts=self.fetch())
     finally:
         WARN('fetchForever方法出错,停止在后台获取联系人资料')
Пример #2
0
 def fetchForever(self):
     INFO('已在后台运行 fetchForever 方法,每隔 5 分钟获取一次联系人资料')
     while True:
         time.sleep(300)
         try:
             contacts = self.fetch()
         except QSession.Error:
             WARN(' fetchForever 方法出错')
         else:
             yield Message('fetchcomplete', contacts=contacts)
Пример #3
0
    def onPollComplete(self, message):
        ctype, fromUin, memberUin, content = message.result

        if ctype == 'timeout':
            self.Process(Message('polltimeout'))
            return

        try:
            contact = self.Get(ctype, uin=fromUin)[0]
        except IndexError:
            contact = QContact(ctype, uin=fromUin, name='##UNKNOWN', qq='')

        if ctype == 'buddy':
            memberName = ''
            INFO('来自 %s 的消息: "%s"' % (str(contact), content))
        else:
            memberName = contact.GetMemberName(memberUin)
            INFO('来自 %s[成员“%s”] 的消息: "%s"' % \
                 (str(contact), memberName, content))

        self.Process(
            QQMessage(contact, memberUin, memberName, content, self.SendTo))
Пример #4
0
 def pollForever(self):
     try:
         while True:
             yield Message('pollcomplete', result=self.poll())
     finally:
         yield Message('stop', code=1)