Hitchat

Latest version: v1.1.1

Safety actively analyzes 631030 Python packages for vulnerabilities to keep your Python projects secure.

Scan your dependencies

Page 2 of 3

1.2.28

你可以这样测试:

首先成功登陆一次:

python
import itchat
itchat.auto_login(True)


之后在手机上将该登录状态登出。(模拟各类登出)

之后重新运行登陆,你将不需要扫码直接在手机上获得登陆推送。

python
import itchat
itchat.auto_login(True)
itchat.send('Login without qrcode!', 'filehelper')


在上次登陆后没有通过其他途径登陆该微信的情况下,再次登录将不再需要扫码,直接收到登陆推送。

1.2.22

Exceptions in registered functions will now be shown in warning level.
When wechat domain is not available, exceptions will also be shown in warning level.

1.2.16

这个问题简而言之就是退了一个用户,之后本地不会删除该用户。

这里给出一个群聊人数监控的示例:

python
coding=utf8
import logging

import itchat
from itchat.content import *

logger = logging.getLogger('itchat')
groupName = u'萝卜群'
groupMemberCount = -1
groupUserName = None

itchat.auto_login(True)

group = itchat.search_chatrooms(name=groupName)[0]
if not group['MemberList']:
logger.info('no member list detected')
group = itchat.update_chatroom(group['UserName'])
groupMemberCount = len(group['MemberList'])
groupUserName = group['UserName']
logger.info('%s: %s' % (groupName, groupMemberCount))

itchat.msg_register(SYSTEM)
def detect_member(msg):
global groupMemberCount
if msg['SystemInfo'] != 'chatrooms':
logger.info(msg['SystemInfo'])
elif groupUserName not in msg['Text']:
logger.info(msg['Text'])
else:
newGroup = itchat.search_chatrooms(userName=groupUserName)
logger.info('%s member updated: %s -> %s' %(
groupName, groupMemberCount, len(newGroup['MemberList'])))
groupMemberCount = len(newGroup['MemberList'])

itchat.run(True)

1.2.12

更新了大文件的上传

这个不用多说了吧,你试试大文件就好了

更新了新的发送协议

微信更新了附件的发送协议,所以我也更新了一下

1.2.10

增强了pkl的版本兼容

这样在itchat更新的时候就不需要手动删除pkl了,我也不用因为修改pkl的内容导致bug而被吐槽。

增加了qrCallback

好像很久以前就有说需要增加二维码的回调,但以前都是建议不使用auto_login,自定义登录过程。
现在auto_login里面的功能多了之后,还是给加上qrCallback吧。
需要注意的是,如果使用了qrCallback,系统默认不会再存储二维码并显示,这些内容全都交给qrCallback。

可以通过如下程序测试:

python
import logging

import itchat

itchat.set_logging(loggingLevel=logging.DEBUG)

def qrCallback(uuid, status, qrcode):
if status == '0':
with open('qr.jpg', 'wb') as f:
f.write(qrcode)
itchat.utils.print_qr('qr.jpg')
print('** qr callback **')
print('%s: %s' % (uuid, status))
print('qr size: %s' % len(qrcode))
print('*****************')

itchat.auto_login(True, qrCallback=qrCallback)

itchat.run(debug=True)


qrCallback必须接受三个参数,uuid status qrcode。
uuid和qrcode分别对应qrcode的uuid以及二进制图片。
status有0, 200, 201, 400, 408(都是字符串形式),对应为:
- 0 - 获取到图片
- 200 - 登陆成功
- 201 - 需要在手机端确认登录
- 400 - 二维码失效
- 408 - 二维码尚未被扫描也未失效

这里给出一个使用这个功能通过网页显示二维码的示例:[源码](https://gist.github.com/littlecodersh/da5ad98728627c25963da67b0180453d)

修复了因为群聊没有self键导致群聊消息遗漏的问题

好像也没什么好说的,之后如果发现一些奇怪的问题,记得这样调试:

python
itchat.run(debug=True)

1.2.8

修复了通讯录混乱问题

本来由于对于webwxsync(`itchat.get_msg()`)返回的用户信息全部默认为群聊,导致了该问题。

目前已经修复,使用如下代码测试,记得删一下itchat.pkl之后测试:

python
import logging, sys

import itchat
from itchat.content import *

itchat.set_logging(loggingLevel=logging.DEBUG)

itchat.auto_login(True)

itchat.msg_register(FRIENDS)
def add_friend(msg):
itchat.add_friend(**msg['Text'])

itchat.msg_register(TEXT)
def check_contact(msg):
print('** Contact check begin **')
for member in itchat.get_friends():
if '' in member['UserName']:
print('Fake member: %s' % member['NickName'])
for chatroom in itchat.get_chatrooms():
if '' not in chatroom['UserName']:
print('Fake chatroom: %s' % member['NickName'])
print('** Contact check finish **')

itchat.run()


为每个发送消息增加了logging信息

为了方便之后的调试与交流,每个发送操作都会产生带参数的logging信息。

可以通过如下代码测试:

python
import itchat
from itchat.content import *

itchat.auto_login(True)

itchat.msg_register([PICTURE, RECORDING, ATTACHMENT, VIDEO])
def download_files(msg):
msg['Text'](msg['FileName'])
return '%s%s' % ({'Picture': 'img', 'Video': 'vid'}.get(
msg['Type'], 'fil'), msg['FileName'])

itchat.run(debug=True)


修复了好友列表首位非自己的问题

这就是我手滑,原谅我,同样记得删除itchat.pkl之后测试。

Page 2 of 3

© 2024 Safety CLI Cybersecurity Inc. All Rights Reserved.