Comments (6)
bot = Bot()
print("开始运行")
groups = bot.groups()
group = groups.search('xxx打卡群')[0]
url = "https://xxxx/api/message"
while 1:
try:
res = requests.get(url)
res.encoding = "utf-8"
data = res.json()
message = data['data']
if message:
group.send(message)
else:
print("暂无打卡消息")
except Exception:
print("请求发生错误")
time.sleep(2)
功能很简单,循环请求接口,如果有新的消息 就通过group.send()方法把消息发送的微信群里,
但是不到一天自己就退出登录了,请问代码要怎么改
from wxpy.
两种方法:
1、循环给另一个微信号发消息,这样微信不会强制下线。晚上有无消息时间段过长微信服务器就会强制微信下线
2、登录时开始缓存认证,并把登录写在一个函数中。调用bot函数时把logout设为自身,也就是退出时立马重新登录,不过这时候需要在微信上确认登录
from wxpy.
两种方法:
1、循环给另一个微信号发消息,这样微信不会强制下线。晚上有无消息时间段过长微信服务器就会强制微信下线
2、登录时开始缓存认证,并把登录写在一个函数中。调用bot函数时把logout设为自身,也就是退出时立马重新登录,不过这时候需要在微信上确认登录
我试过了第一种方法,每隔几分钟就往另一个群 发送一条消息,还是会退出登录
from wxpy.
两种方法:
1、循环给另一个微信号发消息,这样微信不会强制下线。晚上有无消息时间段过长微信服务器就会强制微信下线
2、登录时开始缓存认证,并把登录写在一个函数中。调用bot函数时把logout设为自身,也就是退出时立马重新登录,不过这时候需要在微信上确认登录我试过了第一种方法,每隔几分钟就往另一个群 发送一条消息,还是会退出登录
那就不知道怎么回事了。我的机器人账号自从加了每5分钟发一条消息后,印象中就有一次启动了自动重启功能。自上次更新已经连续工作一周没有任何问题
from wxpy.
我有个打卡的微信号非常稳定,只要手机端微信保持在线,有时持续一个月都没问题。但是另一个微信号涉及大量新群聊和大量信息转发就很容易掉线,怀疑有可能由于客户端耗电过多,被安卓系统电量的策略限制?具体没有仔细研究,感觉跟本地客户端的活跃以及微信服务端的校验规则都有关系
from wxpy.
两种方法:
1、循环给另一个微信号发消息,这样微信不会强制下线。晚上有无消息时间段过长微信服务器就会强制微信下线
2、登录时开始缓存认证,并把登录写在一个函数中。调用bot函数时把logout设为自身,也就是退出时立马重新登录,不过这时候需要在微信上确认登录
第2个是怎么搞? 什么意思?
from wxpy.
Related Issues (20)
- 完全沒有辦法給自己發訊息,求救
- 我尝试微信群同步信息的功能,但是图片和视频有时同步不成功,有没有办法。 HOT 1
- 微信群同步文本视频图片信息,但是信息顺序错乱,有没有办法。 HOT 1
- 基于pc微信做吗?
- 微信群接收一条消息后怎样暂停接收该微信群的其他消息,等处理完后重新开启对该微信群的消息接收 HOT 1
- 无法接受到群消息
- 互助讨论群 HOT 1
- wxpy 在python3.8下出错。 HOT 3
- Cannot auto reply with @bot.register()
- 【研发必看!!!】做机器人,小助手,营销系统,客服系统,监管系统的可以 看下这个API方案 https://www.wkteam.cn/ HOT 1
- Support for ItChat 1.3+
- 是不是不能用了? HOT 4
- send_video 为什么报错raise ResponseError(err_code=err_code, err_msg=err_msg)
- 【研发必看!!!】做机器人,小助手,营销系统,客服系统,监管系统的可以 看下这个API方案 https://www.wkteam.cn/
- 微信扫码后出现,“KeyError:pass_ticket"
- 散了吧,微信已屏蔽 HOT 3
- 【研发必看!!!】做机器人,小助手,营销系统,客服系统,监管系统的可以 看下这个API方案 https://www.wkteam.cn/ #458
- 曝光一个是骗子~大家小心!!!【往事随风】【绝版先生】 HOT 2
- 现在能用什么办法监控到微信群消息吗
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from wxpy.