美文网首页
Python 微信机器人-用itchat库向好友发送名片、转发名

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

作者: netppp | 来源:发表于2022-09-04 23:40 被阅读0次

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()

相关文章

网友评论

      本文标题:Python 微信机器人-用itchat库向好友发送名片、转发名

      本文链接:https://www.haomeiwen.com/subject/vqzbnrtx.html