forked from bot/app
feat: 对部分消息回复用markdown进行了重新排版
This commit is contained in:
@ -4,22 +4,22 @@ from nonebot.adapters.onebot.v11 import MessageSegment
|
||||
from nonebot.exception import FinishedException
|
||||
from nonebot.params import CommandArg
|
||||
from nonebot.permission import SUPERUSER
|
||||
from nonebot.plugin import PluginMetadata
|
||||
|
||||
from src.utils.message import send_markdown
|
||||
from src.utils.typing import T_Message, T_Bot, v11, T_MessageEvent
|
||||
|
||||
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)
|
||||
|
||||
md_conv = on_command("md", block=False, permission=SUPERUSER)
|
||||
|
||||
placeholder = {
|
||||
"[": "[",
|
||||
"]": "]",
|
||||
"&": "&",
|
||||
",": ",",
|
||||
"\n": r"\n",
|
||||
"\"": r'\\\"'
|
||||
"[": "[",
|
||||
"]": "]",
|
||||
"&": "&",
|
||||
",": ",",
|
||||
"\n" : r"\n",
|
||||
"\"" : r'\\\"'
|
||||
}
|
||||
|
||||
|
||||
@ -30,17 +30,26 @@ async def _(bot: T_Bot, event: T_MessageEvent, arg: v11.Message = CommandArg()):
|
||||
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()
|
||||
async def _(bot: v11.Bot, event: v11.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))
|
||||
|
||||
data, fdata = await send_markdown(str(arg), bot, event.message_type,
|
||||
event.group_id if event.message_type == "group" else event.user_id)
|
||||
data = await send_markdown(str(arg), bot, event=event)
|
||||
await bot.delete_msg(message_id=event.message_id)
|
||||
|
||||
|
||||
nonebot.logger.info("已处理:%s, %s" % (str(data["message_id"]), str(fdata["message_id"])))
|
||||
__author__ = "snowykami"
|
||||
__plugin_meta__ = PluginMetadata(
|
||||
name="轻雪Markdown测试",
|
||||
description="用于测试Markdown的插件",
|
||||
usage="",
|
||||
homepage="https://github.com/snowykami/LiteyukiBot",
|
||||
)
|
@ -3,6 +3,7 @@ from typing import Optional
|
||||
import nonebot
|
||||
from nonebot import on_message
|
||||
from arclet.alconna import Arparma, Alconna, Args, Option, Subcommand, Arg
|
||||
from nonebot.plugin import PluginMetadata
|
||||
from nonebot_plugin_alconna import on_alconna
|
||||
from src.utils.data import LiteModel
|
||||
from src.utils.message import send_markdown
|
||||
@ -34,7 +35,7 @@ alc = Alconna(
|
||||
"add",
|
||||
Args["source", str],
|
||||
Args["target", str],
|
||||
Option("-b", Args["bidirectional", bool])
|
||||
Option("bidirectional", Args["bidirectional", bool])
|
||||
),
|
||||
Subcommand(
|
||||
"rm",
|
||||
@ -105,5 +106,14 @@ async def _(event: T_MessageEvent, bot: T_Bot):
|
||||
push_message = (
|
||||
f"> From {event.sender.nickname}@{push.source.session_type}.{push.source.session_id}\n> Bot {bot.self_id}\n\n"
|
||||
f"{msg_formatted}")
|
||||
await send_markdown(push_message, bot2, push.target.session_type, push.target.session_id)
|
||||
await send_markdown(push_message, bot2, event=event)
|
||||
return
|
||||
|
||||
|
||||
__author__ = "snowykami"
|
||||
__plugin_meta__ = PluginMetadata(
|
||||
name="轻雪事件推送",
|
||||
description="事件推送插件,支持单向和双向推送,支持跨Bot推送",
|
||||
usage="",
|
||||
homepage="https://github.com/snowykami/LiteyukiBot",
|
||||
)
|
@ -2,21 +2,22 @@ import nonebot.plugin
|
||||
from nonebot import on_command
|
||||
from nonebot.permission import SUPERUSER
|
||||
|
||||
from src.utils.typing import T_MessageEvent
|
||||
from src.utils.message import send_markdown
|
||||
from src.utils.typing import T_Bot, T_MessageEvent
|
||||
from src.utils.language import get_user_lang
|
||||
|
||||
list_plugins = on_command("list-plugin", aliases={"列出插件"}, priority=0)
|
||||
toggle_plugin = on_command("enable-plugin", aliases={"启用插件", "禁用插件", "disable-plugin"}, priority=0)
|
||||
list_plugins = on_command("list-plugin", aliases={"列出插件"}, priority=0, permission=SUPERUSER)
|
||||
toggle_plugin = on_command("enable-plugin", aliases={"启用插件", "禁用插件", "disable-plugin"}, priority=0, permission=SUPERUSER)
|
||||
|
||||
|
||||
@list_plugins.handle()
|
||||
async def _(event: T_MessageEvent):
|
||||
async def _(event: T_MessageEvent, bot: T_Bot):
|
||||
lang = get_user_lang(str(event.user_id))
|
||||
reply = lang.get("npm.loaded_plugins")
|
||||
reply = f"# {lang.get('npm.loaded_plugins')} | {lang.get('npm.total', TOTAL=len(nonebot.get_loaded_plugins()))} \n***"
|
||||
for plugin in nonebot.get_loaded_plugins():
|
||||
# 检查是否有 metadata 属性
|
||||
if plugin.metadata:
|
||||
reply += f"\n- {plugin.metadata.name}"
|
||||
reply += f"\n- **{plugin.metadata.name}**".replace('_', r'\_')
|
||||
else:
|
||||
reply += f"\n- {plugin.name}"
|
||||
await list_plugins.finish(reply)
|
||||
reply += f"\n- **{plugin.name}**".replace('_', r'\_')
|
||||
await send_markdown(reply, bot, event=event)
|
||||
|
@ -1 +1,11 @@
|
||||
from .profile_manager import *
|
||||
from nonebot.plugin import PluginMetadata
|
||||
|
||||
from .profile_manager import *
|
||||
|
||||
__author__ = "snowykami"
|
||||
__plugin_meta__ = PluginMetadata(
|
||||
name="轻雪用户管理",
|
||||
description="用户管理插件",
|
||||
usage="",
|
||||
homepage="https://github.com/snowykami/LiteyukiBot",
|
||||
)
|
Reference in New Issue
Block a user