mirror of
https://github.com/LiteyukiStudio/LiteyukiBot.git
synced 2025-07-26 23:20:54 +00:00
feat: 愚人节快乐
This commit is contained in:
@ -22,7 +22,7 @@ from nonebot_plugin_alconna import on_alconna, Alconna, Args, Subcommand, Arparm
|
||||
|
||||
driver = get_driver()
|
||||
|
||||
markdown_image = False
|
||||
markdown_image = common_db.first(StoredConfig(), default=StoredConfig()).config.get("markdown_image", False)
|
||||
|
||||
cmd_liteyuki = on_alconna(
|
||||
Alconna(
|
||||
@ -156,7 +156,7 @@ async def _(bot: T_Bot, event: T_MessageEvent):
|
||||
|
||||
@Bot.on_calling_api
|
||||
async def test_for_md_image(bot: T_Bot, api: str, data: dict):
|
||||
if api in ["send_msg", "send_private_msg", "send_group_msg"] and markdown_image:
|
||||
if api in ["send_msg", "send_private_msg", "send_group_msg"] and markdown_image and data.get("user_id") != bot.self_id:
|
||||
if api == "send_msg" and data.get("message_type") == "private" or api == "send_private_msg":
|
||||
session_type = "private"
|
||||
session_id = data.get("user_id")
|
||||
|
@ -114,15 +114,31 @@ class Markdown:
|
||||
dict: response data
|
||||
|
||||
"""
|
||||
print("\n\n\n发送图片\n\n\n")
|
||||
if isinstance(image, str):
|
||||
async with aiofiles.open(image, "rb") as f:
|
||||
image = await f.read()
|
||||
|
||||
# 1.轻雪图床方案
|
||||
image_url = await liteyuki_api.upload_image(image)
|
||||
image_size = Image.open(io.BytesIO(image)).size
|
||||
image_md = Markdown.image(image_url, image_size)
|
||||
return await Markdown.send_md(image_md, bot, message_type=message_type, session_id=session_id, event=event, **kwargs)
|
||||
|
||||
# 2.此方案等林文轩修好后再用QQ图床,再嵌入markdown发送
|
||||
# image_message_id = (await bot.send_private_msg(
|
||||
# user_id=bot.self_id,
|
||||
# message=[
|
||||
# v11.MessageSegment.image(file=image)
|
||||
# ]
|
||||
# ))["message_id"]
|
||||
# await asyncio.sleep(3)
|
||||
# await bot.delete_msg(message_id=image_message_id)
|
||||
# image_message = await bot.get_msg(message_id=image_message_id)
|
||||
# image_url = (await bot.get_msg(message_id=image_message_id))["message"][0]["data"]["url"]
|
||||
# image_size = Image.open(io.BytesIO(image)).size
|
||||
# image_md = Markdown.image(image_url, image_size)
|
||||
# return await Markdown.send_md(image_md, bot, message_type=message_type, session_id=session_id, event=event, **kwargs)
|
||||
|
||||
@staticmethod
|
||||
async def get_image_url(image: bytes | str, bot: T_Bot) -> str:
|
||||
"""把图片上传到图床,返回链接
|
||||
|
Reference in New Issue
Block a user