Bläddra i källkod

fix: compatible with python 3.7

master
lanvent 1 år sedan
förälder
incheckning
4f1ed197ce
3 ändrade filer med 9 tillägg och 5 borttagningar
  1. +4
    -2
      channel/wechatcom/wechatcomapp_channel.py
  2. +3
    -2
      lib/itchat/components/register.py
  3. +2
    -1
      translate/baidu/baidu_translate.py

+ 4
- 2
channel/wechatcom/wechatcomapp_channel.py Visa fil

@@ -93,7 +93,8 @@ class WechatComAppChannel(ChatChannel):
image_storage = io.BytesIO()
for block in pic_res.iter_content(1024):
image_storage.write(block)
if (sz := fsize(image_storage)) >= 10 * 1024 * 1024:
sz = fsize(image_storage)
if sz >= 10 * 1024 * 1024:
logger.info("[wechatcom] image too large, ready to compress, sz={}".format(sz))
image_storage = compress_imgfile(image_storage, 10 * 1024 * 1024 - 1)
logger.info("[wechatcom] image compressed, sz={}".format(fsize(image_storage)))
@@ -109,7 +110,8 @@ class WechatComAppChannel(ChatChannel):
logger.info("[wechatcom] sendImage url={}, receiver={}".format(img_url, receiver))
elif reply.type == ReplyType.IMAGE: # 从文件读取图片
image_storage = reply.content
if (sz := fsize(image_storage)) >= 10 * 1024 * 1024:
sz = fsize(image_storage)
if sz >= 10 * 1024 * 1024:
logger.info("[wechatcom] image too large, ready to compress, sz={}".format(sz))
image_storage = compress_imgfile(image_storage, 10 * 1024 * 1024 - 1)
logger.info("[wechatcom] image compressed, sz={}".format(fsize(image_storage)))


+ 3
- 2
lib/itchat/components/register.py Visa fil

@@ -25,8 +25,9 @@ def auto_login(self, hotReload=False, statusStorageDir='itchat.pkl',
self.useHotReload = hotReload
self.hotReloadDir = statusStorageDir
if hotReload:
if rval:=self.load_login_status(statusStorageDir,
loginCallback=loginCallback, exitCallback=exitCallback):
rval=self.load_login_status(statusStorageDir,
loginCallback=loginCallback, exitCallback=exitCallback)
if rval:
return
logger.error('Hot reload failed, logging in normally, error={}'.format(rval))
self.logout()


+ 2
- 1
translate/baidu/baidu_translate.py Visa fil

@@ -31,7 +31,8 @@ class BaiduTranslator(Translator):
while retry_cnt:
r = requests.post(self.url, params=payload, headers=headers)
result = r.json()
if errcode := result.get("error_code", "52000") != "52000":
errcode = result.get("error_code", "52000")
if errcode != "52000":
if errcode == "52001" or errcode == "52002":
retry_cnt -= 1
continue


Laddar…
Avbryt
Spara