Giter Club home page Giter Club logo

Comments (6)

wtf-boy avatar wtf-boy commented on May 26, 2024

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.

xflyyxfl avatar xflyyxfl commented on May 26, 2024

两种方法:
1、循环给另一个微信号发消息,这样微信不会强制下线。晚上有无消息时间段过长微信服务器就会强制微信下线
2、登录时开始缓存认证,并把登录写在一个函数中。调用bot函数时把logout设为自身,也就是退出时立马重新登录,不过这时候需要在微信上确认登录

from wxpy.

wtf-boy avatar wtf-boy commented on May 26, 2024

两种方法:
1、循环给另一个微信号发消息,这样微信不会强制下线。晚上有无消息时间段过长微信服务器就会强制微信下线
2、登录时开始缓存认证,并把登录写在一个函数中。调用bot函数时把logout设为自身,也就是退出时立马重新登录,不过这时候需要在微信上确认登录

我试过了第一种方法,每隔几分钟就往另一个群 发送一条消息,还是会退出登录

from wxpy.

xflyyxfl avatar xflyyxfl commented on May 26, 2024

两种方法:
1、循环给另一个微信号发消息,这样微信不会强制下线。晚上有无消息时间段过长微信服务器就会强制微信下线
2、登录时开始缓存认证,并把登录写在一个函数中。调用bot函数时把logout设为自身,也就是退出时立马重新登录,不过这时候需要在微信上确认登录

我试过了第一种方法,每隔几分钟就往另一个群 发送一条消息,还是会退出登录

那就不知道怎么回事了。我的机器人账号自从加了每5分钟发一条消息后,印象中就有一次启动了自动重启功能。自上次更新已经连续工作一周没有任何问题

from wxpy.

Cyrus-Jiang avatar Cyrus-Jiang commented on May 26, 2024

我有个打卡的微信号非常稳定,只要手机端微信保持在线,有时持续一个月都没问题。但是另一个微信号涉及大量新群聊和大量信息转发就很容易掉线,怀疑有可能由于客户端耗电过多,被安卓系统电量的策略限制?具体没有仔细研究,感觉跟本地客户端的活跃以及微信服务端的校验规则都有关系

from wxpy.

nicholas-tsia avatar nicholas-tsia commented on May 26, 2024

两种方法:
1、循环给另一个微信号发消息,这样微信不会强制下线。晚上有无消息时间段过长微信服务器就会强制微信下线
2、登录时开始缓存认证,并把登录写在一个函数中。调用bot函数时把logout设为自身,也就是退出时立马重新登录,不过这时候需要在微信上确认登录

第2个是怎么搞? 什么意思?

from wxpy.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.