Python 微信机器人-用itchat库向好友发送名片、转发名

2022-09-04  本文已影响0人  netppp

https://blog.51cto.com/lanzao/3233634

先看效果图:
我发给机器人的名片,它存了下来,然后再发送给我。

itchat.content.CARD 就是名片类型,当微信接收到名片就会触发。
itchat.send_raw_msg() 就是发送名片。
只要记录 msg[‘MsgType’] 和 msg[‘Content’] 的值就可以保存名片信息。
msg[‘FromUserName’] 是指定把名片发送给谁。

!/user/bin/env python

-- coding:utf-8 --

import itchat

接收名片

@itchat.msg_register(itchat.content.CARD, isFriendChat = True)
def send_card(msg):
itchat.send_raw_msg(msg['MsgType'], msg['Content'], msg['FromUserName'])

itchat.auto_login(hotReload = True)
itchat.run()

上一篇 下一篇

猜你喜欢

热点阅读