Skip to content

Commit

Permalink
fix: bug
Browse files Browse the repository at this point in the history
  • Loading branch information
vivien8261 committed Dec 22, 2023
1 parent adb6787 commit bbe43e5
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions amiyabot/adapters/tencent/qqGroup/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit bbe43e5

Please sign in to comment.