# 首先 你得 安装 itchat 包 命令: pip install itchat pillow
# 代码实现如下:
import itchat,re
from itchat.content import *
@itchat.msg_register([TEXT])
def text_reply(msg):
# 匹配任何文字和表情,然后自动回复(你好呀,美女)
match = re.search("(.*)",msg["Text"]).span()
if match:
itchat.send(("你好呀,美女"),msg["FromUserName"])
# 匹配 图片,语言,视频,分享,然后自动回复(嘿嘿,嘿嘿)
@itchat.msg_register([PICTURE,RECORDING,VIDEO,SHARING])
def other_reply(msg):
itchat.send(("嘿嘿,嘿嘿"),msg["FromUserName"])
if __name__ == "__main__":
itchat.auto_login(enableCmdQR=True,hotReload=True)
itchat.run()
# 打开微信扫一扫