Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

up #27

Merged
merged 5 commits into from
May 9, 2023
Merged

up #27

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -4,7 +4,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