forked from bot/app
✨ [nonebot-plugin]状态提供更多品牌的cpu支持
This commit is contained in:
parent
a7d0560932
commit
2eb5aae23f
@ -33,7 +33,10 @@ __all__ = [
|
||||
"logger",
|
||||
]
|
||||
|
||||
__version__ = "6.3.9" # 测试版本号
|
||||
__version__ = "6.3.10" # 测试版本号
|
||||
# 6.3.10
|
||||
# 新增`on_command`装饰器
|
||||
|
||||
# 6.3.9
|
||||
# 更改了on语法
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
@ -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:
|
||||
|
@ -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
|
||||
|
19
liteyuki/plugins/liteecho.py
Normal file
19
liteyuki/plugins/liteecho.py
Normal file
@ -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())
|
@ -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
|
||||
|
42
src/liteyuki_plugins/liteyuki_docs.py
Normal file
42
src/liteyuki_plugins/liteyuki_docs.py
Normal file
@ -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)
|
@ -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 = {
|
||||
|
@ -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"
|
||||
|
Loading…
Reference in New Issue
Block a user