Coder Social home page Coder Social logo

why2lyj / itchat-uos Goto Github PK

View Code? Open in Web Editor NEW

This project forked from littlecodersh/itchat

679.0 8.0 141.0 1022 KB

复活Itchat,你只需要 pip install itchat-uos

Home Page: http://itchat.readthedocs.io

License: MIT License

Python 100.00%
wechat itchat

itchat-uos's Introduction

itchat-uos

itchat_vesion Downloads

2017年后,新注册的微信基本登录不了网页版,itchat-uos版本利用统信UOS的网页版微信,可以让你绕过网页微信的登录限制。

你只需要执行下条命令便能复活Itchat

pip install itchat-uos==1.5.0.dev0

祝各位好运 —— By Snow

更新 - 2023/02/10

目前使用 1.5.0.dev0 大多数使用者可能出现微信被官方封禁提醒,从已知收集的封禁情况,暂未有可解决方案。

猜测可能与近期ChatGPT结合本仓库实现个性化机器人导致相关封禁,请合理,谨慎使用本仓库。

itchat

Gitter py27 py35 English version

itchat是一个开源的微信个人号接口,使用python调用微信从未如此简单。

使用不到三十行的代码,你就可以完成一个能够处理所有信息的微信机器人。

当然,该api的使用远不止一个机器人,更多的功能等着你来发现,比如这些

该接口与公众号接口itchatmp共享类似的操作方式,学习一次掌握两个工具。

如今微信已经成为了个人社交的很大一部分,希望这个项目能够帮助你扩展你的个人的微信号、方便自己的生活。

安装

可以通过本命令安装itchat:

pip install itchat-uos

简单入门实例

有了itchat,如果你想要给文件传输助手发一条信息,只需要这样:

import itchat

itchat.auto_login()

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

如果你想要回复发给自己的文本消息,只需要这样:

import itchat

@itchat.msg_register(itchat.content.TEXT)
def text_reply(msg):
    return msg.text

itchat.auto_login()
itchat.run()

一些进阶应用可以在下面的开源机器人的源码和进阶应用中看到,或者你也可以阅览文档

试一试

这是一个基于这一项目的开源小机器人,百闻不如一见,有兴趣可以尝试一下。

由于好友数量实在增长过快,自动通过好友验证的功能演示暂时关闭。

QRCode

截屏

file-autoreply login-page

进阶应用

特殊的字典使用方式

通过打印itchat的用户以及注册消息的参数,可以发现这些值都是字典。

但实际上itchat精心构造了相应的消息、用户、群聊、公众号类。

其所有的键值都可以通过这一方式访问:

@itchat.msg_register(TEXT)
def _(msg):
    # equals to print(msg['FromUserName'])
    print(msg.fromUserName)

属性名为键值首字母小写后的内容。

author = itchat.search_friends(nickName='LittleCoder')[0]
author.send('greeting, littlecoder!')

各类型消息的注册

通过如下代码,微信已经可以就日常的各种信息进行获取与回复。

import itchat, time
from itchat.content import *

@itchat.msg_register([TEXT, MAP, CARD, NOTE, SHARING])
def text_reply(msg):
    msg.user.send('%s: %s' % (msg.type, msg.text))

@itchat.msg_register([PICTURE, RECORDING, ATTACHMENT, VIDEO])
def download_files(msg):
    msg.download(msg.fileName)
    typeSymbol = {
        PICTURE: 'img',
        VIDEO: 'vid', }.get(msg.type, 'fil')
    return '@%s@%s' % (typeSymbol, msg.fileName)

@itchat.msg_register(FRIENDS)
def add_friend(msg):
    msg.user.verify()
    msg.user.send('Nice to meet you!')

@itchat.msg_register(TEXT, isGroupChat=True)
def text_reply(msg):
    if msg.isAt:
        msg.user.send(u'@%s\u2005I received: %s' % (
            msg.actualNickName, msg.text))

itchat.auto_login(True)
itchat.run(True)

命令行二维码

通过以下命令可以在登陆的时候使用命令行显示二维码:

itchat.auto_login(enableCmdQR=True)

部分系统可能字幅宽度有出入,可以通过将enableCmdQR赋值为特定的倍数进行调整:

# 如部分的linux系统,块字符的宽度为一个字符(正常应为两字符),故赋值为2
itchat.auto_login(enableCmdQR=2)

默认控制台背景色为暗色(黑色),若背景色为浅色(白色),可以将enableCmdQR赋值为负值:

itchat.auto_login(enableCmdQR=-1)

退出程序后暂存登陆状态

通过如下命令登陆,即使程序关闭,一定时间内重新开启也可以不用重新扫码。

itchat.auto_login(hotReload=True)

用户搜索

使用search_friends方法可以搜索用户,有四种搜索方式:

  1. 仅获取自己的用户信息
  2. 获取特定UserName的用户信息
  3. 获取备注、微信号、昵称中的任何一项等于name键值的用户
  4. 获取备注、微信号、昵称分别等于相应键值的用户

其中三、四项可以一同使用,下面是示例程序:

# 获取自己的用户信息,返回自己的属性字典
itchat.search_friends()
# 获取特定UserName的用户信息
itchat.search_friends(userName='@abcdefg1234567')
# 获取任何一项等于name键值的用户
itchat.search_friends(name='littlecodersh')
# 获取分别对应相应键值的用户
itchat.search_friends(wechatAccount='littlecodersh')
# 三、四项功能可以一同使用
itchat.search_friends(name='LittleCoder机器人', wechatAccount='littlecodersh')

关于公众号、群聊的获取与搜索在文档中有更加详细的介绍。

附件的下载与发送

itchat的附件下载方法存储在msg的Text键中。

发送的文件的文件名(图片给出的默认文件名)都存储在msg的FileName键中。

下载方法接受一个可用的位置参数(包括文件名),并将文件相应的存储。

@itchat.msg_register([PICTURE, RECORDING, ATTACHMENT, VIDEO])
def download_files(msg):
    msg.download(msg.fileName)
    itchat.send('@%s@%s' % (
        'img' if msg['Type'] == 'Picture' else 'fil', msg['FileName']),
        msg['FromUserName'])
    return '%s received' % msg['Type']

如果你不需要下载到本地,仅想要读取二进制串进行进一步处理可以不传入参数,方法将会返回图片的二进制串。

@itchat.msg_register([PICTURE, RECORDING, ATTACHMENT, VIDEO])
def download_files(msg):
    with open(msg.fileName, 'wb') as f:
        f.write(msg.download())

用户多开

使用如下命令可以完成多开的操作:

import itchat

newInstance = itchat.new_instance()
newInstance.auto_login(hotReload=True, statusStorageDir='newInstance.pkl')

@newInstance.msg_register(itchat.content.TEXT)
def reply(msg):
    return msg.text

newInstance.run()

退出及登陆完成后调用特定方法

登陆完成后的方法需要赋值在loginCallback中。

而退出后的方法需要赋值在exitCallback中。

import time

import itchat

def lc():
    print('finish login')
def ec():
    print('exit')

itchat.auto_login(loginCallback=lc, exitCallback=ec)
time.sleep(3)
itchat.logout()

若不设置loginCallback的值,则将会自动删除二维码图片并清空命令行显示。

常见问题与解答

Q: 如何通过这个包将自己的微信号变为控制器?

A: 有两种方式:发送、接受自己UserName的消息;发送接收文件传输助手(filehelper)的消息

Q: 为什么我发送信息的时候部分信息没有成功发出来?

A: 有些账号是天生无法给自己的账号发送信息的,建议使用filehelper代替。

作者

LittleCoder: 构架及维护Python2 Python3版本。

tempdban: 协议、构架及日常维护。

Chyroc: 完成第一版本的Python3构架。

类似项目

youfou/wxpy: 优秀的api包装和配套插件,微信机器人/优雅的微信个人号API

liuwons/wxBot: 类似的基于Python的微信机器人

zixia/wechaty: 基于Javascript(ES6)的微信个人账号机器人NodeJS框架/库

sjdy521/Mojo-Weixin: 使用Perl语言编写的微信客户端框架,可通过插件提供基于HTTP协议的api接口供其他语言调用

HanSon/vbot: 基于PHP7的微信个人号机器人,通过实现匿名函数可以方便地实现各种自定义的功能

yaphone/itchat4j: 用Java扩展个人微信号的能力

kanjielu/jeeves: 使用springboot开发的微信机器人

问题和建议

如果有什么问题或者建议都可以在这个Issue和我讨论

或者也可以在gitter上交流:Gitter

当然也可以加入我们新建的QQ群讨论:549762872, 205872856

itchat-uos's People

Contributors

big2cat avatar cc2cc avatar congbo avatar jtr109 avatar littlecodersh avatar lx0758 avatar lyleshaw avatar mymusise avatar royxiang avatar sphynx-henryay avatar sunyi00 avatar tempdban avatar up9cloud avatar whalechen avatar why2lyj avatar wj-mcat avatar wwj718 avatar xiaowuyz avatar xmcp avatar youfou avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

itchat-uos's Issues

添加好友的itchat.add_friend找不到

在提交前,请确保您已经检查了以下内容!

  • 您可以在浏览器中登陆微信账号,但不能使用itchat登陆
  • 我已经阅读并按文档 中的指引进行了操作
  • 您的问题没有在issues报告,否则请在原有issue下报告
  • 本问题确实关于itchat, 而不是其他项目.
  • 如果你的问题关于稳定性,建议尝试对网络稳定性要求极低的itchatmp项目

请使用itchat.run(debug=True)运行,并将输出粘贴在下面:

Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/itchat/components/register.py", line 60, in configured_reply
    r = replyFn(msg)
  File "/Volumes/Data/Code/Haoyuan/ChatGPT/chatgpt-on-wechat/channel/wechat/wechat_channel.py", line 34, in add_friend
    itchat.add_friend(**msg['Text'])
  File "/usr/local/lib/python3.9/site-packages/itchat/storage/templates.py", line 158, in verify
    return self.core.add_friend(**self.verifyDict)
AttributeError: 'Core' object has no attribute 'add_friend'

您的itchat版本为:1.5.0.dev

其他的内容或者问题更详细的描述都可以添加在下面:

[您的内容]

登录报错,KeyError: wxsid

在提交前,请确保您已经检查了以下内容!

  • 您可以在浏览器中登陆微信账号,但不能使用itchat登陆
  • 我已经阅读并按文档 中的指引进行了操作
  • 您的问题没有在issues报告,否则请在原有issue下报告
  • 本问题确实关于itchat, 而不是其他项目.
  • 如果你的问题关于稳定性,建议尝试对网络稳定性要求极低的itchatmp项目

请使用itchat.run(debug=True)运行,并将输出粘贴在下面:

无法运行到这一步

[在这里粘贴完整日志]

您的itchat版本为:1.4.1。(可通过python -c "import itchat;print(itchat.__version__)"获取)

其他的内容或者问题更详细的描述都可以添加在下面:

报错内容:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.8/dist-packages/itchat/components/login.py", line 55, in login
    status = self.check_login()
  File "/usr/local/lib/python3.8/dist-packages/itchat/components/login.py", line 141, in check_login
    if process_login_info(self, r.text):
  File "/usr/local/lib/python3.8/dist-packages/itchat/components/login.py", line 183, in process_login_info
    core.loginInfo['wxsid'] = core.loginInfo['BaseRequest']['Sid'] = cookies["wxsid"]
KeyError: 'wxsid'

如果我浏览器登录不了,这种方式可以用么

在提交前,请确保您已经检查了以下内容!

  • 您可以在浏览器中登陆微信账号,但不能使用itchat登陆
  • 我已经阅读并按文档 中的指引进行了操作
  • 您的问题没有在issues报告,否则请在原有issue下报告
  • 本问题确实关于itchat, 而不是其他项目.
  • 如果你的问题关于稳定性,建议尝试对网络稳定性要求极低的itchatmp项目

请使用itchat.run(debug=True)运行,并将输出粘贴在下面:

[在这里粘贴完整日志]

您的itchat版本为:[在这里填写版本号]。(可通过python -c "import itchat;print(itchat.__version__)"获取)

其他的内容或者问题更详细的描述都可以添加在下面:

[您的内容]

微信好友四百多,提示:Loading the contact, this may take a little while.,微信好友发信息,就会无法获取到对手ID信息,并且报错

在提交前,请确保您已经检查了以下内容!

  • 您可以在浏览器中登陆微信账号,但不能使用itchat登陆
  • 我已经阅读并按文档 中的指引进行了操作
  • 您的问题没有在issues报告,否则请在原有issue下报告
  • 本问题确实关于itchat, 而不是其他项目.
  • 如果你的问题关于稳定性,建议尝试对网络稳定性要求极低的itchatmp项目

请使用itchat.run(debug=True)运行,并将输出粘贴在下面:

Please scan the QR code to log in.
Please press confirm on your phone.
Loading the contact, this may take a little while.
TERM environment variable not set.
Login successfully as Home
Start auto replying.
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/itchat/components/register.py", line 60, in configured_reply
    r = replyFn(msg)
  File "/Users/niezhenchao/Desktop/chatgpt-on-wechat/channel/wechat/wechat_channel.py", line 21, in handler_single_msg
    WechatChannel().handle(msg)
  File "/Users/niezhenchao/Desktop/chatgpt-on-wechat/channel/wechat/wechat_channel.py", line 46, in handle
    other_user_id = msg['User']['UserName']     # 对手方id
KeyError: 'UserName'


您的itchat版本为:[在这里填写版本号]。(可通过python -c "import itchat;print(itchat.__version__)"获取)

其他的内容或者问题更详细的描述都可以添加在下面:

[您的内容]

试用了,非常棒。不过,可以收到微信好友的信息,收到不来自企业微信好友的信息是怎么回事呢?

在提交前,请确保您已经检查了以下内容!

  • 您可以在浏览器中登陆微信账号,但不能使用itchat登陆
  • 我已经阅读并按文档 中的指引进行了操作
  • 您的问题没有在issues报告,否则请在原有issue下报告
  • 本问题确实关于itchat, 而不是其他项目.
  • 如果你的问题关于稳定性,建议尝试对网络稳定性要求极低的itchatmp项目

请使用itchat.run(debug=True)运行,并将输出粘贴在下面:

[在这里粘贴完整日志]

您的itchat版本为:[在这里填写版本号]。(可通过python -c "import itchat;print(itchat.__version__)"获取)

其他的内容或者问题更详细的描述都可以添加在下面:

[您的内容]

问一下这个如何使用,和源库一样使用吗?安装后,import itchat报错未找到,import itchat_uos没有

在提交前,请确保您已经检查了以下内容!

  • 您可以在浏览器中登陆微信账号,但不能使用itchat登陆
  • 我已经阅读并按[文档][document] 中的指引进行了操作
  • 您的问题没有在[issues][issues]报告,否则请在原有issue下报告
  • 本问题确实关于itchat, 而不是其他项目.
  • 如果你的问题关于稳定性,建议尝试对网络稳定性要求极低的[itchatmp][itchatmp]项目

请使用itchat.run(debug=True)运行,并将输出粘贴在下面:

[在这里粘贴完整日志]

您的itchat版本为:[在这里填写版本号]。(可通过python -c "import itchat;print(itchat.__version__)"获取)

其他的内容或者问题更详细的描述都可以添加在下面:

[您的内容]

问一下这个如何使用,和源库一样使用吗?安装后,import itchat报错未找到,import itchat_uos没有

微信提示异地设备登陆提醒后登陆超时

在提交前,请确保您已经检查了以下内容!

  • 您可以在浏览器中登陆微信账号,但不能使用itchat登陆
  • 我已经阅读并按文档 中的指引进行了操作
  • 您的问题没有在issues报告,否则请在原有issue下报告
  • 本问题确实关于itchat, 而不是其他项目.
  • 如果你的问题关于稳定性,建议尝试对网络稳定性要求极低的itchatmp项目

请使用itchat.run(debug=True)运行,并将输出粘贴在下面:

Getting uuid of QR code.
Downloading QR code.
Please scan the QR code to log in.
Please press confirm on your phone.
Log in time out, reloading QR code.
Getting uuid of QR code.
Downloading QR code.
Please scan the QR code to log in.

您的itchat版本为:[在这里填写版本号]。(可通过python -c "import itchat;print(itchat.__version__)"获取)

其他的内容或者问题更详细的描述都可以添加在下面:

微信提示异地设备登陆提醒 继续登陆需要5s,然后4s左右Log in time out, reloading QR code.手机确定登陆后无反应。

无法登录

无法登录
报错
core.loginInfo['wxsid'] = core.loginInfo['BaseRequest']['Sid'] = cookies["wxsid"]
KeyError: 'wxsid'

收不到企业微信账号发来的消息

在提交前,请确保您已经检查了以下内容!

  • 您可以在浏览器中登陆微信账号,但不能使用itchat登陆
  • 我已经阅读并按文档 中的指引进行了操作
  • 您的问题没有在issues报告,否则请在原有issue下报告
  • 本问题确实关于itchat, 而不是其他项目.
  • 如果你的问题关于稳定性,建议尝试对网络稳定性要求极低的itchatmp项目

请使用itchat.run(debug=True)运行,并将输出粘贴在下面:

[在这里粘贴完整日志]

您的itchat版本为:[在这里填写版本号]。(可通过python -c "import itchat;print(itchat.__version__)"获取)

其他的内容或者问题更详细的描述都可以添加在下面:

[您的内容]

出现No module named 'itchat.content'问题!1.5.0.dev版本

在提交前,请确保您已经检查了以下内容!

  • 您可以在浏览器中登陆微信账号,但不能使用itchat登陆
  • 我已经阅读并按文档 中的指引进行了操作
  • 您的问题没有在issues报告,否则请在原有issue下报告
  • 本问题确实关于itchat, 而不是其他项目.
  • 如果你的问题关于稳定性,建议尝试对网络稳定性要求极低的itchatmp项目

请使用itchat.run(debug=True)运行,并将输出粘贴在下面:

[在这里粘贴完整日志]

您的itchat版本为:[在这里填写版本号]。(可通过python -c "import itchat;print(itchat.__version__)"获取)

其他的内容或者问题更详细的描述都可以添加在下面:

在itchat文件下的__init__.py中未引入 content.py
增加
from . import content
就可以解决上述问题。建议fix it。

list index out of range

在提交前,请确保您已经检查了以下内容!

  • 您可以在浏览器中登陆微信账号,但不能使用itchat登陆
  • 我已经阅读并按文档 中的指引进行了操作
  • 您的问题没有在issues报告,否则请在原有issue下报告
  • 本问题确实关于itchat, 而不是其他项目.
  • 如果你的问题关于稳定性,建议尝试对网络稳定性要求极低的itchatmp项目

请使用itchat.run(debug=True)运行,并将输出粘贴在下面:

Traceback (most recent call last):
  File "/root/WechatForwardBot/main.py", line 22, in <module>
    itchat.auto_login(True)
  File "/usr/local/lib/python3.11/dist-packages/itchat_uos-1.5.0.dev0-py3.11.egg/itchat/components/register.py", line 31, in auto_login
  File "/usr/local/lib/python3.11/dist-packages/itchat_uos-1.5.0.dev0-py3.11.egg/itchat/components/login.py", line 60, in login
  File "/usr/local/lib/python3.11/dist-packages/itchat_uos-1.5.0.dev0-py3.11.egg/itchat/components/login.py", line 152, in check_login
  File "/usr/local/lib/python3.11/dist-packages/itchat_uos-1.5.0.dev0-py3.11.egg/itchat/components/login.py", line 197, in process_login_info
IndexError: list index out of range

您的itchat版本为:[在这里填写版本号]。(可通过python -c "import itchat;print(itchat.__version__)"获取)

其他的内容或者问题更详细的描述都可以添加在下面:

[您的内容]

Refactor the components design

Description

All of itchat method is encapsulated into split module, eg: contact, login, message, hotreload, which is attached to the Core object. Because all of submodule in components module is in the same class: Core, so we can pack all of methods into one Object: AsyncItchat which is the async-based itchat.

Design

In this case, all of methods in components is in same class and there are so many common codes can be refactored. I believe if this change has been done, it will make code smaller and more elegant.

通过分享名片加的好友,不能使用 itchat.accept_friend() 方法通过

最新版本,通过分享名片加的好友,不能使用 itchat.accept_friend() 方法通过

正确返回: "{'BaseResponse': {'Ret': 0, 'ErrMsg': '请求成功', 'RawMsg': '请求成功'}}"  -> 成功添加
错误返回: "{'BaseResponse': {'Ret': 1, 'ErrMsg': '', 'RawMsg': ''}}"    -> 失败添加
错误返回: "{'BaseResponse': {'Ret': -1, 'ErrMsg': '', 'RawMsg': ''}}" -> 通过分享名片加的好友,返回这个

requests.exceptions.ConnectionError

在提交前,请确保您已经检查了以下内容!

[ x ] 您可以在浏览器中登陆微信账号,但不能使用itchat登陆

[ x ] 我已经阅读并按文档 中的指引进行了操作

[ x ] 您的问题没有在issues报告,否则请在原有issue下报告

[ x ] 本问题确实关于itchat, 而不是其他项目.

[ x ] 如果你的问题关于稳定性,建议尝试对网络稳定性要求极低的itchatmp项目

请使用itchat.run(debug=True)运行,并将输出粘贴在下面:

Traceback (most recent call last):
  File "/home/V01/extittivns03/.pyenv/versions/3.10.8/lib/python3.10/site-packages/urllib3/connectionpool.py", line 703, in urlopen
    httplib_response = self._make_request(
  File "/home/V01/extittivns03/.pyenv/versions/3.10.8/lib/python3.10/site-packages/urllib3/connectionpool.py", line 386, in _make_request
    self._validate_conn(conn)
  File "/home/V01/extittivns03/.pyenv/versions/3.10.8/lib/python3.10/site-packages/urllib3/connectionpool.py", line 1042, in _validate_conn
    conn.connect()
  File "/home/V01/extittivns03/.pyenv/versions/3.10.8/lib/python3.10/site-packages/urllib3/connection.py", line 414, in connect
    self.sock = ssl_wrap_socket(
  File "/home/V01/extittivns03/.pyenv/versions/3.10.8/lib/python3.10/site-packages/urllib3/util/ssl_.py", line 449, in ssl_wrap_socket
    ssl_sock = _ssl_wrap_socket_impl(
  File "/home/V01/extittivns03/.pyenv/versions/3.10.8/lib/python3.10/site-packages/urllib3/util/ssl_.py", line 493, in _ssl_wrap_socket_impl
    return ssl_context.wrap_socket(sock, server_hostname=server_hostname)
  File "/home/V01/extittivns03/.pyenv/versions/3.10.8/lib/python3.10/ssl.py", line 513, in wrap_socket
    return self.sslsocket_class._create(
  File "/home/V01/extittivns03/.pyenv/versions/3.10.8/lib/python3.10/ssl.py", line 1071, in _create
    self.do_handshake()
  File "/home/V01/extittivns03/.pyenv/versions/3.10.8/lib/python3.10/ssl.py", line 1342, in do_handshake
    self._sslobj.do_handshake()
ConnectionResetError: [Errno 104] Connection reset by peer

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/V01/extittivns03/.pyenv/versions/3.10.8/lib/python3.10/site-packages/requests/adapters.py", line 489, in send
    resp = conn.urlopen(
  File "/home/V01/extittivns03/.pyenv/versions/3.10.8/lib/python3.10/site-packages/urllib3/connectionpool.py", line 787, in urlopen
    retries = retries.increment(
  File "/home/V01/extittivns03/.pyenv/versions/3.10.8/lib/python3.10/site-packages/urllib3/util/retry.py", line 550, in increment
    raise six.reraise(type(error), error, _stacktrace)
  File "/home/V01/extittivns03/.pyenv/versions/3.10.8/lib/python3.10/site-packages/urllib3/packages/six.py", line 769, in reraise
    raise value.with_traceback(tb)
  File "/home/V01/extittivns03/.pyenv/versions/3.10.8/lib/python3.10/site-packages/urllib3/connectionpool.py", line 703, in urlopen
    httplib_response = self._make_request(
  File "/home/V01/extittivns03/.pyenv/versions/3.10.8/lib/python3.10/site-packages/urllib3/connectionpool.py", line 386, in _make_request
    self._validate_conn(conn)
  File "/home/V01/extittivns03/.pyenv/versions/3.10.8/lib/python3.10/site-packages/urllib3/connectionpool.py", line 1042, in _validate_conn
    conn.connect()
  File "/home/V01/extittivns03/.pyenv/versions/3.10.8/lib/python3.10/site-packages/urllib3/connection.py", line 414, in connect
    self.sock = ssl_wrap_socket(
  File "/home/V01/extittivns03/.pyenv/versions/3.10.8/lib/python3.10/site-packages/urllib3/util/ssl_.py", line 449, in ssl_wrap_socket
    ssl_sock = _ssl_wrap_socket_impl(
  File "/home/V01/extittivns03/.pyenv/versions/3.10.8/lib/python3.10/site-packages/urllib3/util/ssl_.py", line 493, in _ssl_wrap_socket_impl
    return ssl_context.wrap_socket(sock, server_hostname=server_hostname)
  File "/home/V01/extittivns03/.pyenv/versions/3.10.8/lib/python3.10/ssl.py", line 513, in wrap_socket
    return self.sslsocket_class._create(
  File "/home/V01/extittivns03/.pyenv/versions/3.10.8/lib/python3.10/ssl.py", line 1071, in _create
    self.do_handshake()
  File "/home/V01/extittivns03/.pyenv/versions/3.10.8/lib/python3.10/ssl.py", line 1342, in do_handshake
    self._sslobj.do_handshake()
urllib3.exceptions.ProtocolError: ('Connection aborted.', ConnectionResetError(104, 'Connection reset by peer'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/V01/extittivns03/.pyenv/versions/3.10.8/lib/python3.10/site-packages/itchat/utils.py", line 134, in test_connect
    r = requests.get(config.BASE_URL)
  File "/home/V01/extittivns03/.pyenv/versions/3.10.8/lib/python3.10/site-packages/requests/api.py", line 73, in get
    return request("get", url, params=params, **kwargs)
  File "/home/V01/extittivns03/.pyenv/versions/3.10.8/lib/python3.10/site-packages/requests/api.py", line 59, in request
    return session.request(method=method, url=url, **kwargs)
  File "/home/V01/extittivns03/.pyenv/versions/3.10.8/lib/python3.10/site-packages/requests/sessions.py", line 587, in request
    resp = self.send(prep, **send_kwargs)
  File "/home/V01/extittivns03/.pyenv/versions/3.10.8/lib/python3.10/site-packages/requests/sessions.py", line 701, in send
    r = adapter.send(request, **kwargs)
  File "/home/V01/extittivns03/.pyenv/versions/3.10.8/lib/python3.10/site-packages/requests/adapters.py", line 547, in send
    raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', ConnectionResetError(104, 'Connection reset by peer'))

You can't get access to internet or wechat domain, so exit.

Process finished with exit code 0

您的itchat版本为:[1.5.0.dev]。(可通过python -c "import itchat;print(itchat.__version__)"获取)

操作系统版本: Ubantu 20.04 tls

其他的内容或者问题更详细的描述都可以添加在下面:

代码:

import itchat
from itchat.content import TEXT


@itchat.msg_register(TEXT)
def text_reply(msg):
    return msg.text


itchat.auto_login(enableCmdQR=2)
itchat.run(True)

如何使用async登录

在提交前,请确保您已经检查了以下内容!

  • 您可以在浏览器中登陆微信账号,但不能使用itchat登陆
  • 我已经阅读并按文档 中的指引进行了操作
  • 您的问题没有在issues报告,否则请在原有issue下报告
  • 本问题确实关于itchat, 而不是其他项目.
  • 如果你的问题关于稳定性,建议尝试对网络稳定性要求极低的itchatmp项目

请使用itchat.run(debug=True)运行,并将输出粘贴在下面:

AttributeError: 'NoneType' object has no attribute 'Waiting'

您的itchat版本为:1.5.0.dev。(可通过python -c "import itchat;print(itchat.__version__)"获取)

其他的内容或者问题更详细的描述都可以添加在下面:

如何使用async版本的[ItChat-UOS]
运行以下代码报错:AttributeError: 'NoneType' object has no attribute 'Waiting'

async def main():
    await itchat.auto_login()

EventScanPayload, ScanStatus参数应该填入什么?
(已加入ITCHAT_UOS_ASYNC=True环境变量)

不能验证通过好友

在提交前,请确保您已经检查了以下内容!

  • 您可以在浏览器中登陆微信账号,但不能使用itchat登陆
  • 我已经阅读并按[文档][document] 中的指引进行了操作
  • 您的问题没有在[issues][issues]报告,否则请在原有issue下报告
  • 本问题确实关于itchat, 而不是其他项目.
  • 如果你的问题关于稳定性,建议尝试对网络稳定性要求极低的[itchatmp][itchatmp]项目

请使用itchat.run(debug=True)运行,并将输出粘贴在下面:

Start auto replying.
@b1ea7c607f098733b46498e1835a5d34
Request to send a text message to @b1ea7c607f098733b46498e1835a5d34: Nice to meet you!
{'BaseResponse': {'Ret': -1, 'ErrMsg': '', 'RawMsg': ''}}

您的itchat版本为:1.4.1。(可通过python -c "import itchat;print(itchat.__version__)"获取)

其他的内容或者问题更详细的描述都可以添加在下面:

不能验证通过好友
代码如下:
import itchat
from itchat.content import *
if name == 'main':
@itchat.msg_register(FRIENDS)
def add_friend(msg):
print(msg.user.UserName)
# print(itchat.add_friend(msg.user.UserName, 3))
print(msg.user.verify())
msg.user.send('Nice to meet you!')
itchat.auto_login(hotReload=True)
itchat.run(debug=True)

上传代码缩进没有了,我贴一张图吧
微信截图_20211204145159
[document]: http://itchat.readthedocs.io/zh/latest/
[issues]: https://github.com/littlecodersh/itchat/issues
[itchatmp]: https://github.com/littlecodersh/itchatmp

确定登录的时间怎么修改使其变长

现在微信扫码登录后会有新设备登录提醒,有5s的等待时间,如果没有及时点击继续登录,程序将会再次生成二维码,这对运行慢的手机不太友好,所以请问这个重新生成二维码的时间能手动修改吗

无法自动添加好友

用的代码是

@itchat.msg_register(FRIENDS)
def add_friend(msg):
print(msg)
msg.user.verify()
msg.user.send('很高兴认识你')
出错提示如下:
File "/home/jd/.local/lib/python3.10/site-packages/itchat/components/register.py", line 60, in configured_reply
r = replyFn(msg)
File "/home/jd/wechat/wechatbot.py", line 57, in add_friend
msg.user.verify()
File "/home/jd/.local/lib/python3.10/site-packages/itchat/storage/templates.py", line 158, in verify
return self.core.add_friend(**self.verifyDict)
AttributeError: 'Core' object has no attribute 'add_friend'. Did you mean: 'get_friends'?
说没有add_friend 这个属性

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.