# pip install -U wxpy
from wxpy import *
# 扫码登陆
bot = Bot()
# 初始化图灵机器人 (API key 申请: http://tuling123.com),并认证
# '6b61f29cdb694a8eb18c84ed97beb750' '20ee91ffc00f42298bb02f7f290bf74d'
tuling = Tuling(api_key='759e94b5631f4cc9d9de36b1a3e0811')
# 设置不自动回复的群和好友
boring_group = bot.groups().search('明日科技')[0]
boring_group1 = bot.groups().search('明日科技')[0]
jt = bot.friends().search('Z')[0]
# 打印所有群
mygroup=bot.groups()
print(mygroup)
# 不自动回复指定的群消息和好友消息
@bot.register([boring_group, boring_group1, jt])
def ignore(msg):
print('ignore is running')
print(msg)
# 啥也不做
return
# 打印指定的群消息
@bot.register([boring_group, boring_group1])
def just_print(msg):
print(msg)
print('just_print is running')
# 回复@的群聊消息和个人消息
@bot.register(msg_types=TEXT) # 注册消息类型为文本消息
def auto_reply(msg):
print('auto_reply is running')
if isinstance(msg.chat, Group) and not msg.is_at: # 判断是否是@的消息和个人消息
return # 如果不是@消息,什么也不做
else:
# tuling.do_reply(msg) # 图灵自动回复消息
print(msg) # 打印消息
print(tuling.do_reply(msg)) # 打印并回复消息
# return '收到消息:{}({})'.format(msg.text, msg.type) # 回复消息:收到消息:内容
embed() # 堵塞线程,并进入 Python 命令行
微信聊天机器人.zip
版权申诉
195 浏览量
2024-02-22
17:22:03
上传
评论
收藏 2KB ZIP 举报
徐浪老师
- 粉丝: 6609
- 资源: 6880
最新资源
- mmexport1719378951919.mp4
- 6276666222777
- 网络攻防对抗课程设计高分报告.docx
- web网页html版基于深度学习的墙体裂缝有无裂缝识别-含图片数据集.zip
- web网页html版基于深度学习python的鞋面缺陷识别-含图片数据集.zip
- utlog.sqlite
- web网页html版基于卷积神经网络对不同柑橘病变识别-含图片数据集.zip
- web网页html版基于python深度学习识别水面漂浮垃圾-含图片数据集.zip
- web网页html版基于python-CNN卷积神经网络识别花卉是否绽放-含图片数据集.zip
- web网页html版基于python-CNN卷积神经网络识别花卉是否枯萎-含图片数据集.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈