mirror of
https://github.com/LiteyukiStudio/LiteyukiBot.git
synced 2024-11-11 05:17:24 +08:00
Changes
This commit is contained in:
parent
9585910623
commit
15c751b1c8
2
main.py
2
main.py
@ -10,7 +10,7 @@ driver = nonebot.get_driver()
|
||||
for adapter in adapters:
|
||||
driver.register_adapter(adapter)
|
||||
|
||||
nonebot.load_plugin("src.plugins.liteyuki_plugin_main")
|
||||
nonebot.load_plugin("src.liteyuki_main")
|
||||
|
||||
if __name__ == "__main__":
|
||||
nonebot.run()
|
||||
|
0
src/__init__.py
Normal file
0
src/__init__.py
Normal file
@ -9,8 +9,5 @@ THIS_PLUGIN_NAME = os.path.basename(os.path.dirname(__file__))
|
||||
RESOURCE_PATH = "src/resources"
|
||||
load_resource_from_dir(RESOURCE_PATH)
|
||||
|
||||
for plugin_dir in os.listdir("src/plugins"):
|
||||
if plugin_dir != THIS_PLUGIN_NAME:
|
||||
nonebot.plugin.load_plugin(f"src.plugins.{plugin_dir}")
|
||||
|
||||
nonebot.plugin.load_plugins("src/plugins")
|
||||
nonebot.plugin.load_plugins("plugins")
|
97
src/plugins/liteyuki_markdowntest.py
Normal file
97
src/plugins/liteyuki_markdowntest.py
Normal file
@ -0,0 +1,97 @@
|
||||
import nonebot
|
||||
from nonebot import on_command
|
||||
from nonebot.adapters.onebot.v11 import MessageSegment
|
||||
from nonebot.params import CommandArg
|
||||
from nonebot.permission import SUPERUSER
|
||||
|
||||
from src.utils.adapter 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)
|
||||
|
||||
placeholder = {
|
||||
"[": "[",
|
||||
"]": "]",
|
||||
"&": "&",
|
||||
",": ",",
|
||||
"\n" : r"\n",
|
||||
"\"" : r'\\\"'
|
||||
}
|
||||
|
||||
@md_test.handle()
|
||||
async def _(bot: T_Bot, event: T_MessageEvent, arg: v11.Message = CommandArg()):
|
||||
arg = str(arg).replace("\\", "\\\\").replace("\n", "\\n")
|
||||
print(arg)
|
||||
for k, v in placeholder.items():
|
||||
arg = arg.replace(k, v)
|
||||
sfm = await bot.call_api(
|
||||
api="send_private_forward_msg",
|
||||
user_id=bot.self_id,
|
||||
messages=[
|
||||
{
|
||||
"type": "node",
|
||||
"data": {
|
||||
"name": "Liteyuki",
|
||||
"uin": bot.self_id,
|
||||
"content": [
|
||||
{
|
||||
"type": "markdown",
|
||||
"data": {
|
||||
"content": '{"content":"%s"}' % arg
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
},
|
||||
]
|
||||
)
|
||||
await md_test.finish(
|
||||
message=v11.Message(
|
||||
MessageSegment(
|
||||
type="longmsg",
|
||||
data={
|
||||
"id": sfm["forward_id"]
|
||||
}
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
@md_group.handle()
|
||||
async def _(bot: T_Bot, event: T_MessageEvent, arg: v11.Message = CommandArg()):
|
||||
group_id, arg = str(arg).split(" ", 1)
|
||||
print(arg)
|
||||
for k, v in placeholder.items():
|
||||
arg = arg.replace(k, v)
|
||||
nonebot.logger.info("Markdown 测试")
|
||||
sfm = await bot.call_api(
|
||||
api="send_private_forward_msg",
|
||||
user_id=bot.self_id,
|
||||
messages=[
|
||||
{
|
||||
"type": "node",
|
||||
"data": {
|
||||
"name": "Liteyuki",
|
||||
"uin": bot.self_id,
|
||||
"content": [
|
||||
{
|
||||
"type": "markdown",
|
||||
"data": {
|
||||
"content": '{"content":"%s"}' % arg
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
},
|
||||
]
|
||||
)
|
||||
await bot.send_group_msg(
|
||||
message=v11.Message(
|
||||
MessageSegment(
|
||||
type="longmsg",
|
||||
data={
|
||||
"id": sfm["forward_id"]
|
||||
}
|
||||
)
|
||||
),
|
||||
group_id=group_id
|
||||
)
|
@ -2,7 +2,7 @@ import nonebot.plugin
|
||||
from nonebot import on_command
|
||||
from nonebot.permission import SUPERUSER
|
||||
|
||||
from src.utils.adapter import MessageEvent
|
||||
from src.utils.adapter import T_MessageEvent
|
||||
from src.utils.language import get_user_lang
|
||||
|
||||
list_plugins = on_command("list-plugin", aliases={"列出插件"}, priority=0)
|
||||
@ -10,7 +10,7 @@ toggle_plugin = on_command("enable-plugin", aliases={"启用插件", "禁用插
|
||||
|
||||
|
||||
@list_plugins.handle()
|
||||
async def _(event: MessageEvent):
|
||||
async def _(event: T_MessageEvent):
|
||||
lang = get_user_lang(str(event.user_id))
|
||||
reply = lang.get("npm.loaded_plugins")
|
||||
for plugin in nonebot.get_loaded_plugins():
|
||||
|
@ -1,7 +1,7 @@
|
||||
from nonebot import on_command
|
||||
from nonebot.params import CommandArg
|
||||
|
||||
from src.utils.adapter import Bot, Message, MessageEvent
|
||||
from src.utils.adapter import T_Bot, T_Message, T_MessageEvent
|
||||
from src.utils.data_manager import User, user_db
|
||||
from src.utils.language import get_user_lang
|
||||
|
||||
@ -16,7 +16,7 @@ attr_cmd = on_command("profile", aliases={"个人设置"}, priority=0)
|
||||
|
||||
|
||||
@attr_cmd.handle()
|
||||
async def _(bot: Bot, event: MessageEvent, args: Message = CommandArg()):
|
||||
async def _(bot: T_Bot, event: T_MessageEvent, args: T_Message = CommandArg()):
|
||||
user = user_db.first(User, "user_id = ?", str(event.user_id), default=User(user_id=str(event.user_id)))
|
||||
ulang = get_user_lang(str(event.user_id))
|
||||
|
||||
|
@ -1,9 +1,9 @@
|
||||
from nonebot.adapters.onebot import v11, v12
|
||||
|
||||
|
||||
Bot = v11.Bot | v12.Bot
|
||||
GroupMessageEvent = v11.GroupMessageEvent | v12.GroupMessageEvent
|
||||
PrivateMessageEvent = v11.PrivateMessageEvent | v12.PrivateMessageEvent
|
||||
MessageEvent = v11.MessageEvent | v12.MessageEvent
|
||||
T_Bot = v11.Bot | v12.Bot
|
||||
T_GroupMessageEvent = v11.GroupMessageEvent | v12.GroupMessageEvent
|
||||
T_PrivateMessageEvent = v11.PrivateMessageEvent | v12.PrivateMessageEvent
|
||||
T_MessageEvent = v11.MessageEvent | v12.MessageEvent
|
||||
|
||||
Message = v11.Message | v12.Message
|
||||
T_Message = v11.Message | v12.Message
|
||||
|
@ -12,7 +12,7 @@ class BasicConfig(BaseModel):
|
||||
port: int = 20216
|
||||
superusers: list[str] = []
|
||||
command_start: list[str] = ["/", ""]
|
||||
nickname: set[str] = {"Liteyuki"}
|
||||
nickname: list[str] = ["liteyuki"]
|
||||
|
||||
|
||||
def load_from_yaml(file: str) -> dict:
|
||||
|
Loading…
Reference in New Issue
Block a user