コード例 #1
0
 def extract_contact(self):
     if not self.type_in(c.IPMSG_BR_ENTRY, c.IPMSG_ANSENTRY):
         contact = Contact(name=self.name, group='', host=self.host, addr=self.addr, login=self.name)
         contact.temporary = True
     else:
         contact = Contact(name=self.msg, group=self.group, host=self.host, addr=self.addr, login=self.name)
         contact.encrypt_opt = self.test(c.IPMSG_ENCRYPTOPT)
     return contact
コード例 #2
0
 def extract_contact_list(self):
     rslt = []
     if not self.type_in(c.IPMSG_ANSLIST):
         return []
     g_cnt, c_cnt, bunch = re.split('\x07', self.raw_msg, 2)
     raw_list = re.split('\x07', bunch)[:-1]
     while raw_list:
         raw = raw_list[:7]
         raw_list = raw_list[7:]
         tag = raw[2]
         addr = list(self.addr)
         addr[0] = raw[3]
         wtf = raw[4]
         name = self.to_unicode(raw[5])
         login = self.to_unicode(raw[0])
         group = self.to_unicode(raw[6])
         contact = Contact(name=name, group=group, host=raw[1], addr=tuple(addr), login=login)
         contact.encrypt_opt = (int(tag) & c.IPMSG_ENCRYPTOPT)
         rslt.append(contact)
     return rslt