예제 #1
0
    def strOfList(self, tinfo, cinfo=None):
        cl = self.List(tinfo, cinfo)

        if cl is None:
            return '错误:无法向 QQ 服务器获取联系人资料'

        if cinfo is None:
            cinfoStr = ''
        else:
            cinfoStr = '("%s")' % cinfo

        head = '%s%s:' % (rName(tinfo), cinfoStr)

        if not cl:
            return head + '空'

        result = [head]
        result.append('=' * 100)
        result.append('\t'.join(('类型', ) + CHSTAGS + EXCHSTAGS))
        result.append('=' * 100)

        for c in cl:
            l = [CTYPES[c.ctype]] + \
                [(getattr(c, tag[:-1], '') or '#') for tag in (TAGS+EXTAGS)]
            result.append('\t'.join(l))

        result.append('=' * 100)

        return '\n'.join(result)
예제 #2
0
def Fetch(self, tinfo):
    rname, ttype = rName(tinfo), tType(tinfo)
    INFO('正在获取 %s ...', rname)
    try:
        if ttype == 'buddy':
            table = fetchBuddyTable(self)
        elif ttype == 'group':
            table = fetchGroupTable(self)
        elif ttype == 'discuss':
            table = fetchDiscussTable(self)
        elif ttype == 'group-member':
            table = fetchGroupMemberTable(self, tinfo)
        else:
            table = fetchDiscussMemberTable(self, tinfo)
    except RequestError:
        table = None
    except:
        ERROR('', exc_info=True)
        table = None

    if table is None:
        ERROR('获取 %s 失败', rname)

    return table
예제 #3
0
def Fetch(self, tinfo):
    rname, ttype = rName(tinfo), tType(tinfo)
    INFO('##正在获取 %s ...', rname)
    try:
        if ttype == 'buddy':
            table = fetchBuddyTable(self)
        elif ttype == 'group':
            table = fetchGroupTable(self)
        elif ttype == 'discuss':
            table = fetchDiscussTable(self)
        elif ttype == 'group-member':
            table = fetchGroupMemberTable(self, tinfo)
        else:
            table = fetchDiscussMemberTable(self, tinfo)
    except RequestError:
        table = None
    except:
        ERROR('', exc_info=True)
        table = None
    
    if table is None:
        ERROR('##获取 %s 失败', rname)

    return table
예제 #4
0
    def strOfList(self, tinfo, cinfo=None):
        cl = self.List(tinfo, cinfo)

        if cl is None:
            return '错误:无法向 QQ 服务器获取联系人资料'

        if cinfo is None:
            cinfoStr = ''
        else:
            cinfoStr = '("%s")' % cinfo

        head = '%s%s:' % (rName(tinfo), cinfoStr)

        if not cl:
            return head + '空'

        pt = PrettyTable(('类型', ) + CHSTAGS + EXCHSTAGS)
        for c in cl:
            pt.addRow(
                [CTYPES[c.ctype]] + \
                [(getattr(c, tag[:-1], '') or '') for tag in (TAGS+EXTAGS)]
            )

        return head + '\n' + str(pt)
예제 #5
0
파일: display.py 프로젝트: pandolia/qqbot
    def strOfList(self, tinfo, cinfo=None):
        cl = self.List(tinfo, cinfo)
        
        if cl is None:
            return '错误:无法向 QQ 服务器获取联系人资料'
        
        if cinfo is None:
            cinfoStr = ''
        else:
            cinfoStr = '("%s")' % cinfo

        head = '%s%s:' % (rName(tinfo), cinfoStr)
        
        if not cl:
            return head + '空'

        pt = PrettyTable( ('类型',) + CHSTAGS + EXCHSTAGS )        
        for c in cl:
            pt.addRow(
                [CTYPES[c.ctype]] + \
                [(getattr(c, tag[:-1], '') or '') for tag in (TAGS+EXTAGS)]
            )
        
        return head + '\n' + str(pt)