LiteyukiBot-TriM/liteyuki/plugins/liteyuki_markdowntest.py

58 lines
1.7 KiB
Python
Raw Normal View History

2024-03-19 20:38:25 +08:00
import nonebot
2024-03-24 22:04:51 +08:00
from nonebot import on_command
2024-03-19 20:38:25 +08:00
from nonebot.params import CommandArg
from nonebot.permission import SUPERUSER
from nonebot.plugin import PluginMetadata
2024-03-19 20:38:25 +08:00
2024-03-24 22:04:51 +08:00
from liteyuki.utils.ly_typing import T_Bot, T_MessageEvent, v11
2024-03-24 09:43:34 +08:00
from liteyuki.utils.message import send_markdown
2024-03-19 20:38:25 +08:00
md_test = on_command("mdts", aliases={"会话md"}, permission=SUPERUSER)
md_group = on_command("mdg", aliases={"群md"}, permission=SUPERUSER)
md_conv = on_command("md", block=False, permission=SUPERUSER)
2024-03-19 20:38:25 +08:00
placeholder = {
"[": "[",
"]": "]",
"&": "&",
",": ",",
"\n" : r"\n",
"\"" : r'\\\"'
2024-03-19 20:38:25 +08:00
}
@md_test.handle()
2024-03-19 20:38:25 +08:00
async def _(bot: T_Bot, event: T_MessageEvent, arg: v11.Message = CommandArg()):
await send_markdown(
str(arg),
bot,
message_type=event.message_type,
session_id=event.user_id if event.message_type == "private" else event.group_id
)
ignore_msg_ids = []
last_sent = None
@md_conv.handle()
2024-03-22 10:24:38 +08:00
async def _(bot: v11.Bot, event: T_MessageEvent, arg: v11.Message = CommandArg()):
if str(event.user_id) == str(bot.self_id) and str(bot.self_id) in ["2751454815"]:
nonebot.logger.info("开始处理:%s" % str(event.message_id))
2024-03-22 10:24:38 +08:00
data = await send_markdown(str(arg), bot, message_type=event.message_type,
session_id=event.user_id if event.message_type == "private" else event.group_id)
await bot.delete_msg(message_id=event.message_id)
__author__ = "snowykami"
__plugin_meta__ = PluginMetadata(
name="轻雪Markdown测试",
description="用于测试Markdown的插件",
usage="",
homepage="https://github.com/snowykami/LiteyukiBot",
2024-03-21 14:52:02 +08:00
extra={
"liteyuki": True,
2024-03-21 14:52:02 +08:00
}
)