ItChat
ItChat copied to clipboard
lack of time.sleep(1)
在提交前,请确保您已经检查了以下内容!
- [ ] 您可以在浏览器中登陆微信账号,但不能使用
itchat
登陆 - [ ] 我已经阅读并按文档 中的指引进行了操作
- [ ] 您的问题没有在issues报告,否则请在原有issue下报告
- [ ] 本问题确实关于
itchat
, 而不是其他项目. - [ ] 如果你的问题关于稳定性,建议尝试对网络稳定性要求极低的itchatmp项目
请使用itchat.run(debug=True)
运行,并将输出粘贴在下面:
[在这里粘贴完整日志]
您的itchat版本为:[在这里填写版本号]
。(可通过python -c "import itchat;print(itchat.__version__)"
获取)
其他的内容或者问题更详细的描述都可以添加在下面:
[您的内容]
while not isLoggedIn:
status = self.check_login()
if hasattr(qrCallback, '__call__'):
qrCallback(uuid=self.uuid, status=status, qrcode=qrStorage.getvalue())
if status == '200':
isLoggedIn = True
elif status == '201':
if isLoggedIn is not None:
logger.info('Please press confirm on your phone.')
isLoggedIn = None
elif status != '408':
break
# time.sleep(1)
这里 while 循环体 没有 time.sleep(1) 导致 请求 太频繁被微信拦截。
useful
这是来自QQ邮箱的假期自动回复邮件。 您好,我最近正在休假中,无法亲自回复您的邮件。我将在假期结束后,尽快给您回复。
您好,我已收到您的邮件,会尽快回复!
async版
elif status != '408':
payload = EventScanPayload(
status=ScanStatus.Cancel,
qrcode=f"https://login.weixin.qq.com/l/{self.uuid}"
)
event_stream.emit('scan', payload)
await asyncio.sleep(0.1)
break
await asyncio.sleep(1)
if isLoggedIn:
payload = EventScanPayload(
status=ScanStatus.Confirmed,
qrcode=f"https://login.weixin.qq.com/l/{self.uuid}"
)
LOCATION=$(pip3 show itchat | grep Location | cut -d ' ' -f 2)
sed -i '/isLoggedIn = False/ a\ time.sleep(15)' $LOCATION/itchat/components/login.py
sed -i '/isLoggedIn = False/ a\ asyncio.sleep(15)' $LOCATION/itchat/async_components/login.py
sed -i '/if isLoggedIn:/ i\ time.sleep(1)' $LOCATION/itchat/components/login.py
sed -i '/if isLoggedIn:/ i\ asyncio.sleep(1)' $LOCATION/itchat/async_components/login.py