Selaa lähdekoodia

Merge branch 'zhayujie:master' into master

develop
eks GitHub 1 vuosi sitten
vanhempi
commit
0cf8e3be73
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
2 muutettua tiedostoa jossa 19 lisäystä ja 2 poistoa
  1. +4
    -0
      channel/wechat/wechat_channel.py
  2. +15
    -2
      plugins/linkai/midjourney.py

+ 4
- 0
channel/wechat/wechat_channel.py Näytä tiedosto

@@ -192,10 +192,14 @@ class WechatChannel(ChatChannel):
logger.info("[WX] sendFile={}, receiver={}".format(reply.content, receiver))
elif reply.type == ReplyType.IMAGE_URL: # 从网络下载图片
img_url = reply.content
logger.debug(f"[WX] start download image, img_url={img_url}")
pic_res = requests.get(img_url, stream=True)
image_storage = io.BytesIO()
size = 0
for block in pic_res.iter_content(1024):
size += len(block)
image_storage.write(block)
logger.info(f"[WX] download image success, size={size}, img_url={img_url}")
image_storage.seek(0)
itchat.send_image(image_storage, toUserName=receiver)
logger.info("[WX] sendImage url={}, receiver={}".format(img_url, receiver))


+ 15
- 2
plugins/linkai/midjourney.py Näytä tiedosto

@@ -310,7 +310,7 @@ class MJBot:
# send img
reply = Reply(ReplyType.IMAGE_URL, task.img_url)
channel = e_context["channel"]
channel._send(reply, e_context["context"])
_send(channel, reply, e_context["context"])

# send info
trigger_prefix = conf().get("plugin_trigger_prefix", "$")
@@ -327,7 +327,7 @@ class MJBot:
text += f"\n\n🔄使用 {trigger_prefix}mjr 命令重新生成图片\n"
text += f"例如:\n{trigger_prefix}mjr {task.img_id}"
reply = Reply(ReplyType.INFO, text)
channel._send(reply, e_context["context"])
_send(channel, reply, e_context["context"])

self._print_tasks()
return
@@ -406,6 +406,19 @@ class MJBot:
return result


def _send(channel, reply: Reply, context, retry_cnt=0):
try:
channel.send(reply, context)
except Exception as e:
logger.error("[WX] sendMsg error: {}".format(str(e)))
if isinstance(e, NotImplementedError):
return
logger.exception(e)
if retry_cnt < 2:
time.sleep(3 + 3 * retry_cnt)
channel.send(reply, context, retry_cnt + 1)


def check_prefix(content, prefix_list):
if not prefix_list:
return None


Loading…
Peruuta
Tallenna