mirror of
https://github.com/KimigaiiWuyi/GenshinUID.git
synced 2025-05-12 06:55:58 +08:00
✨ nb端增加image和file的url支持 (#542)
This commit is contained in:
parent
cab2a876ec
commit
f5b550486a
@ -655,9 +655,18 @@ async def onebot_v12_send(
|
|||||||
)
|
)
|
||||||
await bot.call_api('send_message', **params)
|
await bot.call_api('send_message', **params)
|
||||||
elif image:
|
elif image:
|
||||||
img_bytes = base64.b64decode(image.replace('base64://', ''))
|
|
||||||
timestamp = time.time()
|
timestamp = time.time()
|
||||||
file_name = f'{target_id}_{timestamp}.png'
|
file_name = f'{target_id}_{timestamp}.png'
|
||||||
|
if image.startswith('link://'):
|
||||||
|
link = image.replace('link://', '')
|
||||||
|
up_data = await bot.call_api(
|
||||||
|
'upload_file',
|
||||||
|
type="url",
|
||||||
|
url=link,
|
||||||
|
name=f"{file_name}",
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
img_bytes = base64.b64decode(image.replace('base64://', ''))
|
||||||
up_data = await bot.call_api(
|
up_data = await bot.call_api(
|
||||||
'upload_file',
|
'upload_file',
|
||||||
type="data",
|
type="data",
|
||||||
@ -668,6 +677,15 @@ async def onebot_v12_send(
|
|||||||
await send_file_message(params, "image", file_id)
|
await send_file_message(params, "image", file_id)
|
||||||
elif file:
|
elif file:
|
||||||
file_name, file_content = file.split('|')
|
file_name, file_content = file.split('|')
|
||||||
|
if file_content.startswith('link://'):
|
||||||
|
link = file_content.replace('link://', '')
|
||||||
|
up_data = await bot.call_api(
|
||||||
|
'upload_file',
|
||||||
|
type="url",
|
||||||
|
url=link,
|
||||||
|
name=f"{file_name}",
|
||||||
|
)
|
||||||
|
else:
|
||||||
file_data = base64.b64decode(file_content)
|
file_data = base64.b64decode(file_content)
|
||||||
up_data = await bot.call_api(
|
up_data = await bot.call_api(
|
||||||
'upload_file',
|
'upload_file',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user