diff --git a/liteyuki/__init__.py b/liteyuki/__init__.py index c96f3ed1..626919d5 100644 --- a/liteyuki/__init__.py +++ b/liteyuki/__init__.py @@ -33,7 +33,10 @@ __all__ = [ "logger", ] -__version__ = "6.3.9" # 测试版本号 +__version__ = "6.3.10" # 测试版本号 +# 6.3.10 +# 新增`on_command`装饰器 + # 6.3.9 # 更改了on语法 diff --git a/liteyuki/message/event.py b/liteyuki/message/event.py index d6221a5f..70975075 100644 --- a/liteyuki/message/event.py +++ b/liteyuki/message/event.py @@ -22,6 +22,7 @@ class MessageEvent: message_type: str, raw_message: str, session_id: str, + user_id: str, session_type: str, receive_channel: str, data: Optional[dict[str, Any]] = None, @@ -53,6 +54,7 @@ class MessageEvent: self.session_id = session_id self.session_type = session_type + self.user_id = user_id self.receive_channel = receive_channel diff --git a/liteyuki/message/on.py b/liteyuki/message/on.py index 595e3c6e..a450a85f 100644 --- a/liteyuki/message/on.py +++ b/liteyuki/message/on.py @@ -25,9 +25,7 @@ _queue: Queue = Queue() async def _(event: MessageEvent): current_priority = -1 for i, matcher in enumerate(_matcher_list): - # 刷屏 - logger.debug(f"Running matcher {matcher} for event: {event}") - + logger.info(f"Running matcher {matcher} for event: {event}") await matcher.run(event) # 同优先级不阻断,不同优先级阻断 if current_priority != matcher.priority: diff --git a/liteyuki/message/rule.py b/liteyuki/message/rule.py index 56c4c541..e2f32918 100644 --- a/liteyuki/message/rule.py +++ b/liteyuki/message/rule.py @@ -12,6 +12,9 @@ import inspect from typing import Optional, TypeAlias, Callable, Coroutine from liteyuki.message.event import MessageEvent +from liteyuki import get_config + +_superusers: list[str] = get_config("liteyuki.superusers", []) RuleHandlerFunc: TypeAlias = Callable[[MessageEvent], Coroutine[None, None, bool]] """规则函数签名""" @@ -42,3 +45,7 @@ class Rule: @Rule async def empty_rule(event: MessageEvent) -> bool: return True + +@Rule +async def is_su_rule(event: MessageEvent) -> bool: + return str(event.user_id) in _superusers diff --git a/liteyuki/plugins/liteecho.py b/liteyuki/plugins/liteecho.py new file mode 100644 index 00000000..c30b84fc --- /dev/null +++ b/liteyuki/plugins/liteecho.py @@ -0,0 +1,19 @@ +# -*- coding: utf-8 -*- +""" +Copyright (C) 2020-2024 LiteyukiStudio. All Rights Reserved + +@Time : 2024/8/22 下午12:31 +@Author : snowykami +@Email : snowykami@outlook.com +@File : liteecho.py +@Software: PyCharm +""" + +from liteyuki.message.on import on_startswith +from liteyuki.message.event import MessageEvent +from liteyuki.message.rule import is_su_rule + + +@on_startswith(["liteecho"], rule=is_su_rule).handle() +async def liteecho(event: MessageEvent): + event.reply(event.raw_message.strip()[8:].strip()) diff --git a/requirements.txt b/requirements.txt index 4071f33f..d794df01 100644 --- a/requirements.txt +++ b/requirements.txt @@ -18,6 +18,7 @@ psutil~=5.9.8 py-cpuinfo~=9.0.0 pydantic~=2.7.0 Pygments~=2.17.2 +pyppeteer~=2.0.0 pytz~=2024.1 PyYAML~=6.0.1 pillow~=10.0.0 diff --git a/src/liteyuki_plugins/liteyuki_docs.py b/src/liteyuki_plugins/liteyuki_docs.py new file mode 100644 index 00000000..8dc060bd --- /dev/null +++ b/src/liteyuki_plugins/liteyuki_docs.py @@ -0,0 +1,42 @@ +# -*- coding: utf-8 -*- +""" +Copyright (C) 2020-2024 LiteyukiStudio. All Rights Reserved + +@Time : 2024/8/22 下午2:17 +@Author : snowykami +@Email : snowykami@outlook.com +@File : liteyuki_docs.py +@Software: PyCharm +""" +from liteyuki import get_bot, logger +from liteyuki.utils import IS_MAIN_PROCESS +from liteyuki.plugin import PluginMetadata, PluginType + +from fastapi import FastAPI +import uvicorn + +__plugin_meta__ = PluginMetadata( + name="轻雪文档 Liteyuki Docs", + type=PluginType.SERVICE, +) + +docs_root_path = "docs/.vuepress/dist" + +app = FastAPI() + + +@app.get("/docs") +async def read_root(): + return { + "Hello": "World" + } + + +def start_server(): + logger.success("Docs server started.") + uvicorn.run(app, host="127.0.0.1", port=8000, ) + + +if IS_MAIN_PROCESS: + bot = get_bot() + bot.process_manager.add_target("liteyuki_docs_server", start_server) diff --git a/src/nonebot_plugins/liteyuki_status/api.py b/src/nonebot_plugins/liteyuki_status/api.py index 5363c605..beb7c85c 100644 --- a/src/nonebot_plugins/liteyuki_status/api.py +++ b/src/nonebot_plugins/liteyuki_status/api.py @@ -225,10 +225,20 @@ async def get_hardware_data() -> dict: pass swap = psutil.swap_memory() cpu_brand_raw = cpuinfo.get_cpu_info().get("brand_raw", "Unknown") - if "AMD" in cpu_brand_raw: + if "amd" in cpu_brand_raw.lower(): brand = "AMD" - elif "Intel" in cpu_brand_raw: + elif "intel" in cpu_brand_raw.lower(): brand = "Intel" + elif "apple" in cpu_brand_raw.lower(): + brand = "Apple" + elif "qualcomm" in cpu_brand_raw.lower(): + brand = "Qualcomm" + elif "mediatek" in cpu_brand_raw.lower(): + brand = "MediaTek" + elif "samsung" in cpu_brand_raw.lower(): + brand = "Samsung" + elif "nvidia" in cpu_brand_raw.lower(): + brand = "NVIDIA" else: brand = "Unknown" result = { diff --git a/src/nonebot_plugins/to_liteyuki.py b/src/nonebot_plugins/to_liteyuki.py index f8410385..c4da520c 100644 --- a/src/nonebot_plugins/to_liteyuki.py +++ b/src/nonebot_plugins/to_liteyuki.py @@ -31,6 +31,7 @@ async def _(bot: Bot, event: MessageEvent): raw_message=event.raw_message, data=event.dict(), bot_id=bot.self_id, + user_id=str(event.user_id), session_id=str(event.user_id if event.message_type == "private" else event.group_id), session_type=event.message_type, receive_channel="event_to_nonebot"