From a96d64fe880780b0d9787c0772a6e2e2c6757fd2 Mon Sep 17 00:00:00 2001 From: Soulter <905617992@qq.com> Date: Mon, 4 Sep 2023 10:14:46 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8Dqq=E9=A2=91=E9=81=93?= =?UTF-8?q?=E4=B8=8B=E6=97=A0=E6=B3=95=E5=8F=91=E9=80=81=E5=9B=BE=E7=89=87?= =?UTF-8?q?=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- model/platform/qqchan.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/model/platform/qqchan.py b/model/platform/qqchan.py index b73e35fce..7a93ddc73 100644 --- a/model/platform/qqchan.py +++ b/model/platform/qqchan.py @@ -54,8 +54,13 @@ class QQChan(): # gocq-频道SDK兼容层(收) def gocq_compatible_receive(self, message: Message) -> NakuruGuildMessage: ngm = NakuruGuildMessage() - ngm.self_id = message.mentions[0].id - ngm.self_tiny_id = message.mentions[0].id + try: + ngm.self_id = message.mentions[0].id + ngm.self_tiny_id = message.mentions[0].id + except: + ngm.self_id = 0 + ngm.self_tiny_id = 0 + ngm.sub_type = "normal" ngm.message_id = message.id ngm.guild_id = int(message.channel_id) @@ -98,6 +103,14 @@ class QQChan(): print(plain_text, image_path) + if image_path is not None: + msg_ref = None + if image_path.startswith("http"): + pic_res = requests.get(image_path, stream = True) + if pic_res.status_code == 200: + image = PILImage.open(io.BytesIO(pic_res.content)) + image_path = gu.save_temp_img(image) + try: reply_res = asyncio.run_coroutine_threadsafe(message.raw_message.reply(content=str(plain_text), message_reference = msg_ref, file_image=image_path), self.client.loop) reply_res.result()