zhayujie/chatgpt-on-wechat

Log in time out, reloading QR code. 二维码一直刷新,手机来不及登录

jamesocy opened this issue · 49 comments

无限Log in time out, reloading QR code.
无论切换网络环境还是切换账号,手速再快都会超时。

itchat的一个已知问题,参考 littlecodersh/ItChat#970why2lyj/ItChat-UOS#14

临时方案可以在 itchat/components/login.py 的 login() 函数中,在进入 while not isLoggedIn 循环前增加一个time.sleep(15)

image

如何找到 itchat 源码并修改?

1.先找到安装路径

pip3 show itchat-uos

输出的Location字段就是安装路径, 在我的ubuntu服务器上该值是 /usr/local/lib/python3.7/site-packages
image

源码的完整路径为:/usr/local/lib/python3.7/site-packages/itchat/components/login.py

注意:pip3 必须属于 用来启动程序的python,否则修改无效。有多版本python的环境需要注意这一点。

2. 修改代码

修改login.py 中的 login函数,在 while not isLoggedIn 循环前加上一个sleep(15), 代码在第59行。

可以登录了,但是又遇到了bot不回复的问题

可以登录了,但是又遇到了bot不回复的问题

可以贴下日志,或者直接加我哈

华为云部署的,是不是要开放什么端口?

image

请问这个二维码通过微信扫不出来有什么好办法解决吗

二维码手机扫码确认后,就出现 Log in time out, reloading QR code.
Getting uuid of QR code.
Downloading QR code.

无限Log in time out, reloading QR code. 无论切换网络环境还是切换账号,手速再快都会超时。
这个要如何解决呢,一直是这样的

image
二维码中间有一些乱码,扫描没反应咋整

image

请问这个二维码通过微信扫不出来有什么好办法解决吗

@heyanfeng 你这个解决了么,咋搞的

登录之后,给微信发信息并没有回复啊

在命令行的二维码出现乱码时,可以要程序根目录里找到QR.png文件,直接打开扫码即可

我写了一个自动修改itchat/components/login.py的bash 脚本

#!/bin/bash

# Define the file name and the line number
pack_dir="$(pip3 show itchat-uos | grep "Location" | awk '{print $2}')"
file_name="${pack_dir}/itchat/components/login.py"
line_number=59

# Define the line of code to be inserted
code="time.sleep(15)"
line_of_code="\ \ \ \ \ \ \ \ $code"

# Use the sed command to insert the line
sed -i "${line_number}i ${line_of_code}" "${file_name}"

# Define the start and end line numbers
start_line=50
end_line=70

# Use the sed command to print the desired lines
sed -n "${start_line},${end_line}p" "${file_name}"

手速只要快,二维码不是事

大佬这个我换了个远程端shh窗口就好了

生成的二维码是空格和'\u2005'拼接的,总体是个长方形,比例不对

安装 itchat-uos 后

Please scan the QR code to log in.
Please press confirm on your phone.
[ERROR][2023-02-13 12:44:44][app.py:19] - App startup failed!
[ERROR][2023-02-13 12:44:44][app.py:20] - list index out of range
Traceback (most recent call last):
File "app.py", line 17, in
channel.startup()
File "/root/chatgpt-on-wechat/channel/wechat/wechat_channel.py", line 37, in startup
itchat.auto_login(enableCmdQR=2)
File "/usr/local/lib/python3.7/dist-packages/itchat/components/register.py", line 36, in auto_login
loginCallback=loginCallback, exitCallback=exitCallback)
File "/usr/local/lib/python3.7/dist-packages/itchat/components/login.py", line 61, in login
status = self.check_login()
File "/usr/local/lib/python3.7/dist-packages/itchat/components/login.py", line 152, in check_login
if process_login_info(self, r.text):
File "/usr/local/lib/python3.7/dist-packages/itchat/components/login.py", line 197, in process_login_info
skey = re.findall('(.*?)', r.text, re.S)[0]
IndexError: list index out of range

image
请问这个二维码通过微信扫不出来有什么好办法解决吗

@heyanfeng 你这个解决了么,咋搞的

我的笔记本是这样,台式电脑是正常的

image

请问这个二维码通过微信扫不出来有什么好办法解决吗

在wechat_channel.py中将enableCmdQR=2就好了,等于3就这样

[ERROR][2023-02-14 17:09:35][open_ai_bot.py:89] - module 'openai' has no attribute 'Image'
Traceback (most recent call last):
File "/root/chatgpt-on-wechat/bot/openai/open_ai_bot.py", line 72, in create_img
response = openai.Image.create(

怎么解决?

我的登录出现以下报错,扫描还是登录不了,197 行代码到底什么错误?看不懂
Please scan the QR code to log in.
Please press confirm on your phone.
[ERROR][2023-02-15 09:52:16][app.py:19] - App startup failed!
[ERROR][2023-02-15 09:52:16][app.py:20] - list index out of range
Traceback (most recent call last):
File "app.py", line 17, in
channel.startup()
File "/root/chatgpt-on-wechat/channel/wechat/wechat_channel.py", line 37, in startup
itchat.auto_login(enableCmdQR=2)
File "/usr/local/lib/python3.8/dist-packages/itchat/components/register.py", line 35, in auto_login
self.login(enableCmdQR=enableCmdQR, picDir=picDir, qrCallback=qrCallback,
File "/usr/local/lib/python3.8/dist-packages/itchat/components/login.py", line 61, in login
status = self.check_login()
File "/usr/local/lib/python3.8/dist-packages/itchat/components/login.py", line 152, in check_login
if process_login_info(self, r.text):
File "/usr/local/lib/python3.8/dist-packages/itchat/components/login.py", line 197, in process_login_info
skey = re.findall('(.*?)', r.text, re.S)[0]
IndexError: list index out of range

Please scan the QR code to log in. Please press confirm on your phone. [ERROR][2023-02-13 12:44:44][app.py:19] - App startup failed! [ERROR][2023-02-13 12:44:44][app.py:20] - list index out of range Traceback (most recent call last): File "app.py", line 17, in channel.startup() File "/root/chatgpt-on-wechat/channel/wechat/wechat_channel.py", line 37, in startup itchat.auto_login(enableCmdQR=2) File "/usr/local/lib/python3.7/dist-packages/itchat/components/register.py", line 36, in auto_login loginCallback=loginCallback, exitCallback=exitCallback) File "/usr/local/lib/python3.7/dist-packages/itchat/components/login.py", line 61, in login status = self.check_login() File "/usr/local/lib/python3.7/dist-packages/itchat/components/login.py", line 152, in check_login if process_login_info(self, r.text): File "/usr/local/lib/python3.7/dist-packages/itchat/components/login.py", line 197, in process_login_info skey = re.findall('(.*?)', r.text, re.S)[0] IndexError: list index out of range

微信实名验证下就好了

docker部署的如何找到login.py修改?

在 Dockerfile.alpine 文件 && pip install --upgrade openai 下面加一行

RUN sed -i "59i \ \ \ \ \ \ \ \ time.sleep(15)" /usr/local/lib/python3.7/site-packages/itchat/components/login.py

我的登录出现以下报错,扫描还是登录不了,197 行代码到底什么错误?看不懂 Please scan the QR code to log in. Please press confirm on your phone. [ERROR][2023-02-15 09:52:16][app.py:19] - App startup failed! [ERROR][2023-02-15 09:52:16][app.py:20] - list index out of range Traceback (most recent call last): File "app.py", line 17, in channel.startup() File "/root/chatgpt-on-wechat/channel/wechat/wechat_channel.py", line 37, in startup itchat.auto_login(enableCmdQR=2) File "/usr/local/lib/python3.8/dist-packages/itchat/components/register.py", line 35, in auto_login self.login(enableCmdQR=enableCmdQR, picDir=picDir, qrCallback=qrCallback, File "/usr/local/lib/python3.8/dist-packages/itchat/components/login.py", line 61, in login status = self.check_login() File "/usr/local/lib/python3.8/dist-packages/itchat/components/login.py", line 152, in check_login if process_login_info(self, r.text): File "/usr/local/lib/python3.8/dist-packages/itchat/components/login.py", line 197, in process_login_info skey = re.findall('(.*?)', r.text, re.S)[0] IndexError: list index out of range

微信实名认证之后,登录成功,然后愉快的玩了2天,第3天微信给出了警告,严禁微信挂载非官方认证的插件运行,并临时限制了微信的功能,重新解除限制之后,再次扫码登录就出现机器人经常回复断线的情况了。很担心再次封号。

image 二维码中间有一些乱码,扫描没反应咋整

把二维码切屏,然后用编辑软件调整一下高度,就可以扫描了;记得调整二维码显示时间,否则来不及,估计调整到30秒则可

""pip3 必须属于 用来启动程序的python,否则修改无效。有多版本python的环境需要注意这一点""求大佬 怎么查看用来启动的python,怎么修改启动python

[root@VM-16-11-centos chatgpt-on-wechat]# python3 --version
Python 3.6.8
[root@VM-16-11-centos chatgpt-on-wechat]# python --version
bash: python: command not found
[root@VM-16-11-centos chatgpt-on-wechat]# python2 --version
Python 2.7.5
[root@VM-16-11-centos chatgpt-on-wechat]# which python
/usr/bin/which: no python in (/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin)
[root@VM-16-11-centos chatgpt-on-wechat]# whereis python
python: /usr/bin/python3.6m /usr/bin/python3.6 /usr/bin/python /usr/bin/python.bak /usr/bin/python2.7 /usr/lib/python3.6 /usr/lib/python2.7 /usr/lib64/python3.6 /usr/lib64/python2.7 /etc/python /usr/local/lib/python3.6 /usr/include/python3.6m /usr/include/python2.7 /usr/share/man/man1/python.1.gz
[root@VM-16-11-centos chatgpt-on-wechat]# echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin
[root@VM-16-11-centos chatgpt-on-wechat]# ls -l $(which python3)
lrwxrwxrwx 1 root root 9 Apr 1 2022 /usr/bin/python3 -> python3.6
[7] Done nohup python3 app.py
[root@VM-16-11-centos chatgpt-on-wechat]# python3 -c "import sys; print(sys.prefix)"
/usr

[root@VM-16-11-centos chatgpt-on-wechat]# export PATH=/usr/bin:$PATH
##我已经将python3添加到path中了,但是 执行上面脚本添加15秒时间仍是不管用,超级快就刷下一个QR了

Please scan the QR code to log in. Please press confirm on your phone. [ERROR][2023-02-13 12:44:44][app.py:19] - App startup failed! [ERROR][2023-02-13 12:44:44][app.py:20] - list index out of range Traceback (most recent call last): File "app.py", line 17, in channel.startup() File "/root/chatgpt-on-wechat/channel/wechat/wechat_channel.py", line 37, in startup itchat.auto_login(enableCmdQR=2) File "/usr/local/lib/python3.7/dist-packages/itchat/components/register.py", line 36, in auto_login loginCallback=loginCallback, exitCallback=exitCallback) File "/usr/local/lib/python3.7/dist-packages/itchat/components/login.py", line 61, in login status = self.check_login() File "/usr/local/lib/python3.7/dist-packages/itchat/components/login.py", line 152, in check_login if process_login_info(self, r.text): File "/usr/local/lib/python3.7/dist-packages/itchat/components/login.py", line 197, in process_login_info skey = re.findall('(.*?)', r.text, re.S)[0] IndexError: list index out of range

我也是这样,什么情况?

很显然是OpenAI.com服务器报过来的错误,服务器太忙了,有时候会这样的

Please scan the QR code to log in. Please press confirm on your phone. [ERROR][2023-02-13 12:44:44][app.py:19] - App startup failed! [ERROR][2023-02-13 12:44:44][app.py:20] - list index out of range Traceback (most recent call last): File "app.py", line 17, in channel.startup() File "/root/chatgpt-on-wechat/channel/wechat/wechat_channel.py", line 37, in startup itchat.auto_login(enableCmdQR=2) File "/usr/local/lib/python3.7/dist-packages/itchat/components/register.py", line 36, in auto_login loginCallback=loginCallback, exitCallback=exitCallback) File "/usr/local/lib/python3.7/dist-packages/itchat/components/login.py", line 61, in login status = self.check_login() File "/usr/local/lib/python3.7/dist-packages/itchat/components/login.py", line 152, in check_login if process_login_info(self, r.text): File "/usr/local/lib/python3.7/dist-packages/itchat/components/login.py", line 197, in process_login_info skey = re.findall('(.*?)', r.text, re.S)[0] IndexError: list index out of range

我也是这样,什么情况?

#8 (comment)

docker部署的如何找到login.py修改?

在docker file 中执行我写的bash脚本

itchat的一个已知问题,参考 littlecodersh/ItChat#970why2lyj/ItChat-UOS#14

临时方案可以在 itchat/components/login.py 的 login() 函数中,在进入 while not isLoggedIn 循环前增加一个time.sleep(15)

image

如何找到 itchat 源码并修改?

1.先找到安装路径

pip3 show itchat-uos

输出的Location字段就是安装路径, 在我的ubuntu服务器上该值是 /usr/local/lib/python3.7/site-packages image

源码的完整路径为:/usr/local/lib/python3.7/site-packages/itchat/components/login.py

注意:pip3 必须属于 用来启动程序的python,否则修改无效。有多版本python的环境需要注意这一点。

2. 修改代码

修改login.py 中的 login函数,在 while not isLoggedIn 循环前加上一个sleep(15), 代码在第59行。

========================================================================
#回复:修改login.py 中的 login函数,在 while not isLoggedIn 循环前加上一个sleep(15), 代码在第59行。
添加这个会报错。个人的做法是搜索login.py文件中两处time.sleep(1),把它们都改成time.sleep(5),问题解决。

这个在自家电脑搭建好了,一直使用,会导致在哪个环节扣费吗?

LOCATION=$(pip3 show itchat-uos | 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

littlecodersh/ItChat#971

Please scan the QR code to log in.
Please press confirm on your phone.
[ERROR][2023-03-05 10:33:51][app.py:19] - App startup failed!
[ERROR][2023-03-05 10:33:51][app.py:20] - mismatched tag: line 64, column 4
Traceback (most recent call last):
File "app.py", line 17, in
channel.startup()
File "/root/chatgpt-on-wechat/channel/wechat/wechat_channel.py", line 37, in startup
itchat.auto_login(enableCmdQR=2)
File "/usr/local/lib/python3.8/dist-packages/itchat/components/register.py", line 35, in auto_login
self.login(enableCmdQR=enableCmdQR, picDir=picDir, qrCallback=qrCallback,
File "/usr/local/lib/python3.8/dist-packages/itchat/components/login.py", line 53, in login
status = self.check_login()
File "/usr/local/lib/python3.8/dist-packages/itchat/components/login.py", line 137, in check_login
if process_login_info(self, r.text):
File "/usr/local/lib/python3.8/dist-packages/itchat/components/login.py", line 172, in process_login_info
for node in xml.dom.minidom.parseString(r.text).documentElement.childNodes:
File "/usr/lib/python3.8/xml/dom/minidom.py", line 1969, in parseString
return expatbuilder.parseString(string)
File "/usr/lib/python3.8/xml/dom/expatbuilder.py", line 925, in parseString
return builder.parseString(string)
File "/usr/lib/python3.8/xml/dom/expatbuilder.py", line 223, in parseString
parser.Parse(string, True)
xml.parsers.expat.ExpatError: mismatched tag: line 64, column 4

image
各位遇到过吗

image 各位遇到过吗

同问,我也是

登录之后,给微信发信息并没有回复啊

微信没有返回,有解决吗

改了第59行代码,正常运行了几天。但是今天突然不行,第59行代码改了,还是timeout,怎么解决啊?

风控了吗

image
微信可以登录上去,当时一直只回复我连接不到你的网络,我用的是阿里云服务器,ip填了,端口那里没填,请问这样是什么问题

docker部署的如何找到login.py修改?

在docker file 中执行我写的bash脚本

容器中执行报错了:
WARNING: Package(s) not found: itchat-uos
sed: can't read /itchat/components/login.py: No such file or directory
sed: can't read /itchat/components/login.py: No such file or directory

Qsrass commented

docker部署的如何找到login.py修改?

在docker file 中执行我写的bash脚本

容器中执行报错了: WARNING: Package(s) not found: itchat-uos sed: can't read /itchat/components/login.py: No such file or directory sed: can't read /itchat/components/login.py: No such file or directory

应该是Bash权限问题,我也遇到了

Qsrass commented

群晖docker 修改login.py 的已知方案是在 SSH中打开 /volume1/@docker/btrfs/subvolumes 目录,使用 du -h –max-depth=0 * 查询目录下所有的文件及大小,查询输出信息找到对应的文件目录,进去修改login.py 。如果你进入的目录下没有login.py 或者打开是空文件则目录错误,继续寻找。
如何确认成功修改?直接在ssh中进入容器,使用bash vi /usr/local/lib/python3.7/site-packages/itchat/components/login.py 查看内部信息。
建议按照FunTeng的建议修改:
#回复:修改login.py 中的 login函数,在 while not isLoggedIn 循环前加上一个sleep(15), 代码在第59行。
添加这个会报错。个人的做法是搜索login.py文件中两处time.sleep(1),把它们都改成time.sleep(5),问题解决。

image

请问这个二维码通过微信扫不出来有什么好办法解决吗
同级目录下有个qr的图片直接扫就行

Qsrass commented

itchat的一个已知问题,参考 littlecodersh/ItChat#970why2lyj/ItChat-UOS#14

临时方案可以在 itchat/components/login.py 的 login() 函数中,在进入 while not isLoggedIn 循环前增加一个time.sleep(15)

image

如何找到 itchat 源码并修改?

1.先找到安装路径

pip3 show itchat-uos

输出的Location字段就是安装路径, 在我的ubuntu服务器上该值是 /usr/local/lib/python3.7/site-packages image

源码的完整路径为:/usr/local/lib/python3.7/site-packages/itchat/components/login.py

注意:pip3 必须属于 用来启动程序的python,否则修改无效。有多版本python的环境需要注意这一点。

2. 修改代码

修改login.py 中的 login函数,在 while not isLoggedIn 循环前加上一个sleep(15), 代码在第59行。

修改后报错:

Getting uuid of QR code.
Downloading QR code.
Please scan the QR code to log in.
Traceback (most recent call last):
File "D:\pycode\test_code\itchat\test.py", line 10, in
itchat.auto_login()
File "D:\Software\miniconda3\envs\itchat\lib\site-packages\itchat\components\register.py", line 35, in auto_login
self.login(enableCmdQR=enableCmdQR, picDir=picDir, qrCallback=qrCallback,
File "D:\Software\miniconda3\envs\itchat\lib\site-packages\itchat\components\login.py", line 56, in login
status = self.check_login()
File "D:\Software\miniconda3\envs\itchat\lib\site-packages\itchat\components\login.py", line 142, in check_login
if process_login_info(self, r.text):
File "D:\Software\miniconda3\envs\itchat\lib\site-packages\itchat\components\login.py", line 184, in process_login_info
core.loginInfo['wxsid'] = core.loginInfo['BaseRequest']['Sid'] = cookies["wxsid"]
KeyError: 'wxsid'

我是在windows10的pycharm中测试的代码
import itchat

itchat.auto_login()

itchat.send('Hello, filehelper', toUserName='filehelper')

请问这个错误应该怎么解决啊?