Itchat

Latest version: v1.3.10

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

Scan your dependencies

Page 1 of 3

1.3.9

修复synccheck中BadStatusLine及503导致的错误。

synccheck会返回一些例如这样的值:

bash
6f:00:0a:14:d0:9e:f7:90:f3:8d:32:ac:c2:81:aa:c8:d3:aa:bb:0a:14:d0:9e:f7:90:f3:8d:32:ac:c2:81:aa:c8:d3
6f:00:8a:9c:09:74:e4:d8:e0:14:bf:96:3a:56:a0:64:1b:cc:dd:8a:9c:09:74:e4:d8:e0:14:bf:96:3a:56:a0:64:1b


涵义还没有头绪。

1.3.7

增加了消息撤回方法,示例如下:

python
import itchat

itchat.auto_login(True)

user = itchat.search_friends(nickName='LittleCoder')[0]
r = user.send('hi')
msgId = r['MsgID']
r = itchat.revoke(msgId, user.userName)

itchat.run()

1.3.5

如果两个类互相引用将导致无法被正常回收,所以采取这种形式:

python
from weakref import ref

class D(object):
def __init__(self, name):
self.name = name
def __del__(self):
print('[deleted]: %s' % self.name)

class T(D):
property
def pointer(self):
return getattr(self, '_pointer', lambda: None)()
pointer.setter
def pointer(self, value):
self._pointer = ref(value)

def fn():
t, d = T('t'), D('d')
t.pointer, d.pointer = d, t

if __name__ == '__main__':
fn()
print('end')


在itchat中主要解决这样两个问题:

你需要对照该版本和前版本的结果比较差别。

python
from weakref import ref

from itchat.storage import templates

def fn():
chatroom = templates.Chatroom()
chatroom.memberList.append({})
m = chatroom.memberList[0]
return ref(m), ref(chatroom)

if __name__ == '__main__':
a, b = fn()
print(a(), b())


python
from weakref import ref

from itchat import Core

def fn():
r = Core()
return ref(r)

r = fn()
print(r())

1.3.1

主要更改
* 更新用户、群、公众号的oop操作
* 在注册方法的返回值中增加User键值,存放发送者的类
* 将注册方法的返回值改为可以通过__getattr__访问
* 另,所有新操作不影响旧的字典的使用方式

oop操作

python
import itchat

user = itchat.get_friends()[0]
user.send('hi')


同样,群和公众号也是这样访问。

注册方法返回值增加User

python
import itchat

itchat.msg_register(itchat.content.TEXT)
def _(msg):
msg['User'].send('hi')

itchat.auto_login(True)
itchat.run()


返回值通过__getattr__访问

python
import itchat

itchat.msg_register(itchat.content.TEXT)
def _(msg):
msg.user.send('hi')

itchat.auto_login(True)
itchat.run()


发送文件类

python
import itchat

itchat.auto_login(True)

with open('t.pdf', 'rb') as f:
r = itchat.send_file('test.pdf', 'filehelper', file_=f)
equals to:
r = itchat.send_file('t.pdf', 'filehelper')
print(r)

with open('t.png', 'rb') as f:
r = itchat.send_image(f, 'filehelper')
equals to:
r = itchat.send_image('t.png', 'filehelper')
print(r)

with open('t.mp4', 'rb') as f:
r = itchat.send_video(f, 'filehelper')
equals to:
r = itchat.send_video('t.mp4', 'filehelper')
print(r)

itchat.run()

1.2.31

获取用户头像:
python
import itchat, shutil

itchat.auto_login(True)

r = itchat.get_head_img(picDir='tmp.unknown')
print(r)
if 'PostFix' in r:
shutil.move('tmp.unknown', 'tmp.%s' % r['PostFix'])


获取聊天图片:
python
import itchat, shutil

itchat.auto_login(True)

itchat.msg_register(itchat.content.PICTURE)
def download(msg):
r = msg['Text']('tmp.unknown')
print(r)
if 'PostFix' in r:
shutil.move('tmp.unknown', 'tmp.%s' % r['PostFix'])

itchat.run()

1.2.29

python
import itchat

def qrCallback(uuid, status, qrcode):
if status == '400':
itchat.logout()

itchat.auto_login(True, qrCallback=qrCallback)

if itchat.originInstance.alive:
itchat.run()
else:
print('qrcode timeout and exit')

Page 1 of 3

© 2024 Safety CLI Cybersecurity Inc. All Rights Reserved.