diff --git a/channel/wechatcom/wechatcomapp_channel.py b/channel/wechatcom/wechatcomapp_channel.py index 72804e4..1a08596 100644 --- a/channel/wechatcom/wechatcomapp_channel.py +++ b/channel/wechatcom/wechatcomapp_channel.py @@ -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))) diff --git a/lib/itchat/components/register.py b/lib/itchat/components/register.py index b8bbc29..e76f2c4 100644 --- a/lib/itchat/components/register.py +++ b/lib/itchat/components/register.py @@ -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() diff --git a/translate/baidu/baidu_translate.py b/translate/baidu/baidu_translate.py index bf0a721..a871766 100644 --- a/translate/baidu/baidu_translate.py +++ b/translate/baidu/baidu_translate.py @@ -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