當前位置: 首頁>>代碼示例>>Python>>正文


Python itchat.get_friends方法代碼示例

本文整理匯總了Python中itchat.get_friends方法的典型用法代碼示例。如果您正苦於以下問題:Python itchat.get_friends方法的具體用法?Python itchat.get_friends怎麽用?Python itchat.get_friends使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在itchat的用法示例。


在下文中一共展示了itchat.get_friends方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: ShowFriends

# 需要導入模塊: import itchat [as 別名]
# 或者: from itchat import get_friends [as 別名]
def ShowFriends(self):
        friendslist = itchat.get_friends(update=True)[1:]
        global frind_dict
        for frind in friendslist:
            if (frind['RemarkName'] == ''):
                frind_dict[frind['NickName']] = frind['NickName']
                try:
                    self.d_Listname.insert(END, frind['NickName'])
                except:
                    q.put("您有好友的昵稱包含表情(emoji),超出此軟件的顯示範圍,您可以修改好友備注,去除emoji,請諒解。")
            else:
                frind_dict[frind['RemarkName']] = frind['NickName']
                try:
                    self.d_Listname.insert(END, frind['RemarkName'])
                except:
                    q.put("您有好友的昵稱包含表情(emoji),超出此軟件的顯示範圍,您可以修改好友備注,去除emoji,請諒解。")
        print(frind_dict) 
開發者ID:LyuDun,項目名稱:WeChatAssistant,代碼行數:19,代碼來源:WeChatAssistant.py

示例2: getFriendsInfo

# 需要導入模塊: import itchat [as 別名]
# 或者: from itchat import get_friends [as 別名]
def getFriendsInfo(self):
		try:
			itchat.auto_login(hotReload=True)
		except:
			itchat.auto_login(hotReload=True, enableCmdQR=True)
		friends = itchat.get_friends()
		friends_info = dict(
							province = self.getKeyInfo(friends, "Province"),
							city = self.getKeyInfo(friends, "City"),
							nickname = self.getKeyInfo(friends, "Nickname"),
							sex = self.getKeyInfo(friends, "Sex"),
							signature = self.getKeyInfo(friends, "Signature"),
							remarkname = self.getKeyInfo(friends, "RemarkName"),
							pyquanpin = self.getKeyInfo(friends, "PYQuanPin")
							)
		return friends_info 
開發者ID:CharlesPikachu,項目名稱:WechatHelper,代碼行數:18,代碼來源:analysisFriends.py

示例3: __init__

# 需要導入模塊: import itchat [as 別名]
# 或者: from itchat import get_friends [as 別名]
def __init__(self, roomNicks):
        global wxRooms, myUid
        itchat.auto_login(hotReload=True, enableCmdQR=2, exitCallback=wechatExit)
        all_rooms = itchat.get_chatrooms(update=True)
        for r in all_rooms:
            if r['NickName'] in roomNicks:
                wxRooms[r['UserName']] = r['NickName']
                wxRoomNicks[r['NickName']] = r['UserName']
                logger.info('Room {} found.'.format(r["NickName"]))
            else:
                logger.info('{}: {}'.format(r['UserName'], r['NickName']))

        friends = itchat.get_friends()
        myUid = friends[0]["UserName"] 
開發者ID:tuna,項目名稱:fishroom,代碼行數:16,代碼來源:wechat.py

示例4: init_data

# 需要導入模塊: import itchat [as 別名]
# 或者: from itchat import get_friends [as 別名]
def init_data():
    """ 初始化微信所需數據 """
    set_system_notice('登錄成功')
    itchat.get_friends(update=True)  # 更新好友數據。
    itchat.get_chatrooms(update=True)  # 更新群聊數據。

    init_wechat_config()  # 初始化所有配置內容

    # 提醒內容不為空時,啟動定時任務
    alarm_dict = config.get('alarm_info').get('alarm_dict')
    if alarm_dict:
        init_alarm(alarm_dict)  # 初始化定時任務

    print('初始化完成,開始正常工作。') 
開發者ID:sfyc23,項目名稱:EverydayWechat,代碼行數:16,代碼來源:main.py

示例5: get_city_by_uuid

# 需要導入模塊: import itchat [as 別名]
# 或者: from itchat import get_friends [as 別名]
def get_city_by_uuid(uid):
    """
    通過用戶的uid得到用戶的城市
    最好是與機器人是好友關係
    """
    itchat.get_friends(update=True)
    info = itchat.search_friends(userName=uid)
    # print('info:'+str(info))
    if not info:
        return None
    city = info.city
    # print('city:'+city)
    return city 
開發者ID:sfyc23,項目名稱:EverydayWechat,代碼行數:15,代碼來源:group_helper.py

示例6: get_friend

# 需要導入模塊: import itchat [as 別名]
# 或者: from itchat import get_friends [as 別名]
def get_friend(wechat_name, update=False):
    """
    根據用戶名獲取用戶數據
    :param wechat_name: str 用戶名
    :param update: bool 強製更新用戶數據
    :return: obj 單個好友信息
    """
    if update: itchat.get_friends(update=True)
    if not wechat_name: return None
    friends = itchat.search_friends(name=wechat_name)
    if not friends: return None
    return friends[0] 
開發者ID:sfyc23,項目名稱:EverydayWechat,代碼行數:14,代碼來源:itchat_helper.py

示例7: __init__

# 需要導入模塊: import itchat [as 別名]
# 或者: from itchat import get_friends [as 別名]
def __init__(self):
        self.user_count = 0
        self.selfUser = None
        self.user_dict = {}
        self.current_user = None    # 當前正在聊天的用戶
        self.room_dept = -1          # 用於記錄好友和群聊的分界點id
        self.cmd = Cmd(self)        # 初始化一個命令管理器, 此命令管理器管理所有的命令

        itchat.auto_login(hotReload=True,enableCmdQR = 2,exitCallback=itchat.logout) #登錄並記錄登錄狀態
        threading.Thread(target=itchat.run).start()             # 線程啟動run實現
        self.loadUserList(itchat.get_friends(),'f')             # 加載好友
        self.loadUserList(itchat.get_chatrooms(),'r')           # 加載群聊 
開發者ID:TheThreeDog,項目名稱:TouchFish,代碼行數:14,代碼來源:User.py

示例8: reloadUserList

# 需要導入模塊: import itchat [as 別名]
# 或者: from itchat import get_friends [as 別名]
def reloadUserList(self):
        '''
        重載好友列表,如果程序運行期間添加了好友或群聊,通過此命令刷新
        '''
        self.selfUser = None
        self.current_user = None
        self.user_dict = {}
        self.user_count = 0
        self.loadUserList(itchat.get_friends(),'f')             # 加載好友
        self.loadUserList(itchat.get_chatrooms(),'r')           # 加載群聊 
開發者ID:TheThreeDog,項目名稱:TouchFish,代碼行數:12,代碼來源:User.py

示例9: start

# 需要導入模塊: import itchat [as 別名]
# 或者: from itchat import get_friends [as 別名]
def start():
    @itchat.msg_register([TEXT, MAP, CARD, NOTE, SHARING,PICTURE, RECORDING, ATTACHMENT, VIDEO,FRIENDS])
    def recive_contact_msg(msg):
        contact_name = get_contact_name(msg)
        try:
            wechatMain.recive_message(msg,contact_name)
            notify('TWchat',"new message from: "+contact_name)
        except AttributeError:
            pass
    
    @itchat.msg_register(TEXT, isGroupChat=True)
    def recive_group_msg(msg):
        group_name = get_group_name(msg)
        try:
            wechatMain.recive_message(msg,group_name)
            notify('TWchat',"new message from: "+group_name)
        except AttributeError:
            pass
        return   

    def on_contact_item_click(button,info):
        wechatMain.chatListBox.addNewChat(info[0],info[1])
        wechatMain.set_current_chat(info[0],info[1])
        wechatMain.chatListBox.show_chat()
        return 
    def on_chat_item_click(button,info):
        wechatMain.set_current_chat(info[0],info[1])
        return
    palette = [
        ('left', 'black', 'light gray'),
        ('right', 'black', 'dark cyan'),
        ('button', 'dark green','black'),
        ('mybg', 'black','dark cyan'),
        ('tobg', 'dark blue','light gray'),
        ('edit', 'dark cyan','black'),
        ('bg', 'dark green', 'black'),]
    print ('''
 _____  _    _  _____  _   _   ___   _____ 
|_   _|| |  | |/  __ \| | | | / _ \ |_   _|
  | |  | |  | || /  \/| |_| |/ /_\ \  | |  
  | |  | |/\| || |    |  _  ||  _  |  | |  
  | |  \  /\  /| \__/\| | | || | | |  | |  
  \_/   \/  \/  \____/\_| |_/\_| |_/  \_/  
            ''')

    wechatMain = wegui.WechatMain(palette)
    itchat.auto_login(enableCmdQR=2,hotReload=True)
    itchat.run(blockThread=False)
    userInfo =itchat.web_init()['User']
    owner_id = userInfo['UserName']
    owner_name = userInfo['NickName']
    contactlist= itchat.get_friends(update=True)
    chatlist = itchat.get_chatrooms()
    #contactlist = sorted(contactlist,key=lambda x:(x['RemarkPYInitial'],x['PYInitial']))
    contactlist = sorted(contactlist,key=lambda x:(lazy_pinyin(get_name(x))))
    wechatMain.initUserInfo(owner_id,owner_name,on_contact_item_click,on_chat_item_click,contactlist,chatlist)
    wechatMain.bind_itchat(itchat)
    wechatMain.createLoop() 
開發者ID:huanglizhuo,項目名稱:TWchat,代碼行數:60,代碼來源:__init__.py


注:本文中的itchat.get_friends方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。