本文整理汇总了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)
示例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
示例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"]
示例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('初始化完成,开始正常工作。')
示例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
示例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]
示例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') # 加载群聊
示例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') # 加载群聊
示例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()