python itchat教程_Python itchat.get_friends方法代码示例

# 需要导入模块: 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()

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值