wxauto
wxauto copied to clipboard
请问大佬可不可以监听微信群最新消息呢
比如实时监听某个微信群最新消息, 如果消息中出现了某个关键词就发出提醒 from wxauto import * wx = WeChat() msgs = wx.GetLastMessage while True: if msgs == wx.GetLastMessage: continue else: msgs = wx.GetLastMessage # 后续对最新msgs进行处理 # ...
不知道这样写可不可以, 还是有更好的监听函数可以直接调用呢, 请大佬教我
wxauto是页面模拟操作,不太适合做监控服务,可以看一下后台版本wxautoapi:https://github.com/cluic/wxautoapi 希望有所帮助,感谢支持
可以监听微信群最新消息,你可以这样操作指定某个微信群持续监听,将里面的信息取出,需要自己对最后的信息进行关键词的匹配。提供参考如下
import json
wx =WeChat() order=1
who = "学习交流" wx.ChatWith(who) # 打开聊天窗口
while True:
#更新会话列表
wx.GetSessionList()
msgs=wx.GetLastMessage
if order != msgs :
#width, hight=2540,1440 #屏幕尺寸大小
#img=ImageGrab.grab((0,0,width,hight)) #截取整个屏幕
#imgData =img.getdata #序列化数据
#print("123123")
#调用青山机器人
# text = requests.get("http://api.qingyunke.com/api.php?key=free&appid=0&msg="+msgs[1]+"").text
#解析js数据
#result=json.loads(text)
order=msgs
print(msgs[0],msgs[1])
#print(result["content"])
who = msgs[0]
#wx.ChatWith(who)
#wx.SendMsg(result["content"])
"order != msgs"这句有问题,order[1] != msgs[1]会好点,order初始值应该是3个元素的列表