From bbe43e54a86fa3cec171c6bef6d7ebb502025aac Mon Sep 17 00:00:00 2001 From: Vivien <34387011+vivien8261@users.noreply.github.com> Date: Fri, 22 Dec 2023 15:10:29 +0800 Subject: [PATCH] fix: bug --- amiyabot/adapters/tencent/qqGroup/builder.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/amiyabot/adapters/tencent/qqGroup/builder.py b/amiyabot/adapters/tencent/qqGroup/builder.py index da26556..b072d93 100644 --- a/amiyabot/adapters/tencent/qqGroup/builder.py +++ b/amiyabot/adapters/tencent/qqGroup/builder.py @@ -37,6 +37,8 @@ class QQGroupChainBuilderOptions: class QQGroupChainBuilder(ChainBuilder, metaclass=Singleton): def __init__(self, options: QQGroupChainBuilderOptions): + create_dir(options.resource_path) + self.server = HttpServer(options.host, options.port, **options.http_server_options) self.server.add_static_folder('/resource', options.resource_path) @@ -118,13 +120,16 @@ async def insert_media(url: str, file_type: int = 1): if url.startswith('http'): res = await api.upload_file(chain.data.channel_openid, file_type, url) if res: - file_info = res.json['file_info'] + if 'file_info' in res.json: + file_info = res.json['file_info'] - payload.msg_type = 7 - payload.media = {'file_info': file_info} + payload.msg_type = 7 + payload.media = {'file_info': file_info} - payload_list.append(payload) - payload = GroupPayload(msg_id=chain.data.message_id) + payload_list.append(payload) + payload = GroupPayload(msg_id=chain.data.message_id) + else: + log.warning('file upload fail.') if isinstance(chain.builder, QQGroupChainBuilder): chain.builder.remove_file(url)