From d80c4a7c906803d17b92dc820109fe946c799196 Mon Sep 17 00:00:00 2001 From: snowyServer Date: Sat, 27 Apr 2024 21:38:37 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20pydantic=20v2=20=E6=94=AF=E6=8C=81=20fi?= =?UTF-8?q?x:=20=E8=87=AA=E5=8A=A8=E6=9B=B4=E6=96=B0=E5=90=8E=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=E4=BE=9D=E8=B5=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- liteyuki/liteyuki_main/core.py | 1 + liteyuki/plugins/liteyuki_eventpush.py | 13 +++++++------ liteyuki/utils/base/data_manager.py | 12 ++++++------ requirements.txt | 2 +- 4 files changed, 15 insertions(+), 13 deletions(-) diff --git a/liteyuki/liteyuki_main/core.py b/liteyuki/liteyuki_main/core.py index 8eb4802..1ca6767 100644 --- a/liteyuki/liteyuki_main/core.py +++ b/liteyuki/liteyuki_main/core.py @@ -293,6 +293,7 @@ async def _(bot: T_Bot): async def every_day_update(): if get_config("auto_update", default=True): result, logs = update_liteyuki() + pip.main(["install", "-r", "requirements.txt"]) if result: await broadcast_to_superusers(f"Liteyuki updated: ```\n{logs}\n```") nonebot.logger.info(f"Liteyuki updated: {logs}") diff --git a/liteyuki/plugins/liteyuki_eventpush.py b/liteyuki/plugins/liteyuki_eventpush.py index 12bc001..a92075d 100644 --- a/liteyuki/plugins/liteyuki_eventpush.py +++ b/liteyuki/plugins/liteyuki_eventpush.py @@ -12,7 +12,7 @@ from arclet.alconna import Arparma, Alconna, Args, Option, Subcommand class Node(LiteModel): - TABLE_NAME = "node" + TABLE_NAME: str = "node" bot_id: str = "" session_type: str = "" session_id: str = "" @@ -22,7 +22,7 @@ class Node(LiteModel): class Push(LiteModel): - TABLE_NAME = "push" + TABLE_NAME: str = "push" source: Node = Node() target: Node = Node() inde: int = 0 @@ -106,9 +106,10 @@ async def _(event: T_MessageEvent, bot: T_Bot): for line in str(event.message).split("\n"): msg_formatted += f"**{line.strip()}**\n" 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 md.send_md(push_message, bot2, message_type=push.target.session_type, session_id=push.target.session_id) + f"> From {event.sender.nickname}@{push.source.session_type}.{push.source.session_id}\n> Bot {bot.self_id}\n\n" + f"{msg_formatted}") + await md.send_md(push_message, bot2, message_type=push.target.session_type, + session_id=push.target.session_id) return @@ -119,6 +120,6 @@ __plugin_meta__ = PluginMetadata( usage="", homepage="https://github.com/snowykami/LiteyukiBot", extra={ - "liteyuki": True, + "liteyuki": True, } ) diff --git a/liteyuki/utils/base/data_manager.py b/liteyuki/utils/base/data_manager.py index 35bb2a1..7b4b48c 100644 --- a/liteyuki/utils/base/data_manager.py +++ b/liteyuki/utils/base/data_manager.py @@ -18,7 +18,7 @@ memory_database = { class User(LiteModel): - TABLE_NAME = "user" + TABLE_NAME:str = "user" user_id: str = Field(str(), alias="user_id") username: str = Field(str(), alias="username") profile: dict[str, str] = Field(dict(), alias="profile") @@ -27,7 +27,7 @@ class User(LiteModel): class Group(LiteModel): - TABLE_NAME = "group_chat" + TABLE_NAME: str = "group_chat" # Group是一个关键字,所以这里用GroupChat group_id: str = Field(str(), alias="group_id") group_name: str = Field(str(), alias="group_name") @@ -37,26 +37,26 @@ class Group(LiteModel): class InstalledPlugin(LiteModel): - TABLE_NAME = "installed_plugin" + TABLE_NAME: str = "installed_plugin" module_name: str = Field(str(), alias="module_name") version: str = Field(str(), alias="version") class GlobalPlugin(LiteModel): - TABLE_NAME = "global_plugin" + TABLE_NAME: str = "global_plugin" liteyuki: bool = Field(True, alias="liteyuki") # 是否为LiteYuki插件 module_name: str = Field(str(), alias="module_name") enabled: bool = Field(True, alias="enabled") class StoredConfig(LiteModel): - TABLE_NAME = "stored_config" + TABLE_NAME :str= "stored_config" config: dict = {} class TempConfig(LiteModel): """储存临时键值对的表""" - TABLE_NAME = "temp_data" + TABLE_NAME: str = "temp_data" data: dict = {} diff --git a/requirements.txt b/requirements.txt index a64241c..5e00d34 100644 --- a/requirements.txt +++ b/requirements.txt @@ -14,7 +14,7 @@ packaging~=23.1 playwright~=1.17.2 psutil~=5.9.8 py-cpuinfo~=9.0.0 -pydantic~=1.10.14 +pydantic~=2.7.0 Pygments~=2.17.2 pytz~=2024.1 PyYAML~=6.0.1