Python itchat 模块,get_friends() 实例源码

我们从Python开源项目中,提取了以下8个代码示例,用于说明如何使用itchat.get_friends()

项目:base_function    作者:Rockyzsu    | 项目源码 | 文件源码
def testcase1():
    id='@5493580a22c9ba5db849ba33d0911d3d'
    content=datetime.datetime.now().strftime("%H:%M:%S")
    itchat.auto_login(hotReload=True)
    #itchat.auto_login()
    itchat.send(content,toUserName='filehelper')
    account=itchat.get_friends(u'wwwei')
    print account
    print type(account)
    for i in account:
        #print type(i)
        #print i
        if i[u'PYQuanPin']==u'????':
            print i['UserName']
            #print i
    #itchat.send(content, toUserName=id)

    print 'done'
项目:WXHeadImage    作者:zhaokefei    | 项目源码 | 文件源码
def get_friend_imgs(save_path, get_img_nums=100):
    # ????????
    if os.path.exists(save_path):
        save_path = input(u'????????????????: ')
    os.mkdir(save_path)
    # ??????
    friends = itchat.get_friends()
    if get_img_nums > len(friends):
        get_img_nums = len(friends)
        print(u'?????????????????????? %s' % len(friends))
    for num, friend in enumerate(friends):
        friend_name = friend['NickName'] or friend['UserName']
        # ???????????????
        friend_name = re.sub(r'[\s+]', '_', friend_name)
        friend_img = itchat.get_head_img(userName=friend['UserName'])
        with open(save_path + '/' + friend_name + str(num+1).zfill(3) + '.jpg', 'wb') as f:
            print(u'???? %s ???, ???? %s ?' % (friend_name, get_img_nums-num))
            f.write(friend_img)
        if num > get_img_nums:
            print(u'%s ???????' % get_img_nums)
            break
项目:base_function    作者:Rockyzsu    | 项目源码 | 文件源码
def testcase2():
    itchat.auto_login(hotReload=True)
    print itchat.get_friends()
项目:stock    作者:Rockyzsu    | 项目源码 | 文件源码
def push_wechat(name, real_price, real_percent, type):
    name=u'wwwei'
    itchat.auto_login(hotReload=True)
    account=itchat.get_friends(name)
    for i in account:
        if i[u'PYQuanPin']==name:
            toName=i['UserName']
    content=name+' ' + str(real_price)+' '+ str(real_percent)+' percent '+ type
    itchat.send(content,toUserName=toName)
项目:wbot    作者:PY-Learning    | 项目源码 | 文件源码
def get_friends(update=False):
        ''' fetch friends list
            for options
                - update: if not set, local value will be returned
            for results
                - a list of friends' info dicts will be returned
            it is defined in components/contact.py
        '''
        return itchat.get_friends(update)
项目:jubi_api    作者:Rockyzsu    | 项目源码 | 文件源码
def __init__(self, send='wechat'):
        cfg = Toolkit.getUserData('data.cfg')
        self.public_key = cfg['public_key']
        self.private_key = cfg['private_key']
        self.send=send
        from_mail = cfg['from_mail']
        password = cfg['password']
        to_mail = cfg['to_mail']
        smtp_server = 'smtp.qq.com'

        self.server = smtp_server
        self.username = from_mail.split("@")[0]
        self.from_mail = from_mail
        self.password = password
        self.to_mail = to_mail
        self.coin_list=['IFC','DOGE','EAC','DNC','MET','ZET','SKT','YTC','PLC','LKC',
                        'JBC','MRYC','GOOC','QEC','PEB','XRP','NXT','WDC','MAX','ZCC',
                        'HLB','RSS','PGC','RIO','XAS','TFC','BLK','FZ','ANS','XPM','VTC',
                        'KTC','VRC','XSGS','LSK','PPC','ETC','GAME','LTC','ETH','BTC']
        # ???????????????
        # ????????
        if self.send == 'msn':

            try:
                self.smtp = smtplib.SMTP_SSL(port=465)
                self.smtp.connect(self.server)
                self.smtp.login(self.username, self.password)
            except smtplib.SMTPException, e:
                print e
                return 0

        if send=='wechat':
            self.w_name=u'wwwei'
            #self.w_name1=u'wwwei'
            itchat.auto_login(hotReload=True)
            account=itchat.get_friends(self.w_name)
            for i in account:
                if i[u'PYQuanPin']==self.w_name:
                    self.toName= i['UserName']
                    #print self.toName
项目:wbot    作者:ciknight    | 项目源码 | 文件源码
def text_reply(msg):
    nickName = itchat.search_friends(userName=msg['FromUserName']).get('NickName', 'Unknown')
    logging.info('{}-{} send: {}'.format(nickName, msg['FromUserName'], msg['Content']))
    if msg["FromUserName"] == itchat.get_friends()[0]["UserName"]:
        # dont replay self
        return

    # if invite
    if faq.invite_key in msg['Text'].upper():
        # TODO Modify add_member_into_chatroom
        invite_friend = [{'UserName': msg['FromUserName']}]
        grouproom = itchat.search_chatrooms(name=faq.group_name)
        grouproom = grouproom and grouproom[0] or None
        result = itchat.add_member_into_chatroom(grouproom.get('UserName'),
                invite_friend, useInvitation=True)

        # invite success
        if result['BaseResponse']['Ret'] == 0:
            logging.info('invite user {}-{} successful'.format(nickName, msg['FromUserName']))
        else:
            logging.error('invite user {}-{} failed'.format(nickName, msg['FromUserName']))
            itchat.send(REPLAY_ERROR_TEXT, msg['FromUserName'])
    else:
        # else TuLing replay
        replay_text = tuling.replay_text(msg['Text'],
                msg['FromUserName']) or REPLAY_ERROR_TEXT
        logging.info('tuling replay user {}-{}: {}'.format(nickName, msg['FromUserName'], replay_text))
        itchat.send(replay_text, msg['FromUserName'])

    # TODO can not return Bool
    return
项目:stock    作者:Rockyzsu    | 项目源码 | 文件源码
def __init__(self, send=None):
        cfg = Toolkit.getUserData('data.cfg')
        self.public_key = cfg['public_key']
        self.private_key = cfg['private_key']
        self.send=send
        from_mail = cfg['from_mail']
        password = cfg['password']
        to_mail = cfg['to_mail']
        smtp_server = 'smtp.qq.com'

        self.server = smtp_server
        self.username = from_mail.split("@")[0]
        self.from_mail = from_mail
        self.password = password
        self.to_mail = to_mail
        self.coin_list=['IFC','DOGE','EAC','DNC','MET','ZET','SKT','YTC','PLC','LKC',
                        'JBC','MRYC','GOOC','QEC','PEB','XRP','NXT','WDC','MAX','ZCC',
                        'HLB','RSS','PGC','RIO','XAS','TFC','BLK','FZ','ANS','XPM','VTC',
                        'KTC','VRC','XSGS','LSK','PPC','ETC','GAME','LTC','ETH','BTC']
        # ???????????????
        # ????????
        if self.send == 'msn':

            try:
                self.smtp = smtplib.SMTP_SSL(port=465)
                self.smtp.connect(self.server)
                self.smtp.login(self.username, self.password)
            except smtplib.SMTPException, e:
                print e
                return 0

        if send=='wechat':
            self.w_name=u'wwwei'
            self.w_name1=u'aiweichuangyi'
            itchat.auto_login(hotReload=True)
            account=itchat.get_friends(self.w_name)
            for i in account:
                if i[u'PYQuanPin']==self.w_name:
                    self.toName= i['UserName']
                    #print self.toName
                if i[u'PYQuanPin']==self.w_name1:
                    self.toName1= i['UserName']
                    #print self.toName