Skip to content

Commit

Permalink
Merge pull request #27 from zhayujie/master
Browse files Browse the repository at this point in the history
up
  • Loading branch information
congxuma committed May 9, 2023
2 parents f97fe59 + 0bf06dd commit 95623a3
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 7 deletions.
6 changes: 4 additions & 2 deletions channel/wechatcom/wechatcomapp_channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ def send(self, reply: Reply, context: Context):
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)))
Expand All @@ -109,7 +110,8 @@ def send(self, reply: Reply, context: Context):
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)))
Expand Down
2 changes: 1 addition & 1 deletion channel/wechatmp/passive_reply.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import web
from wechatpy import parse_message
from wechatpy.replies import ImageReply, VoiceReply, create_reply

import textwrap
from bridge.context import *
from bridge.reply import *
from channel.wechatmp.common import *
Expand Down
2 changes: 1 addition & 1 deletion docker/Dockerfile.alpine.latest
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ RUN chmod +x /entrypoint.sh \

USER noroot

ENTRYPOINT ["docker/entrypoint.sh"]
ENTRYPOINT ["/entrypoint.sh"]
5 changes: 3 additions & 2 deletions lib/itchat/components/register.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
3 changes: 2 additions & 1 deletion translate/baidu/baidu_translate.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ def translate(self, query: str, from_lang: str = "", to_lang: str = "en") -> str
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
Expand Down

0 comments on commit 95623a3

Please sign in to comment.