mirror of
https://github.com/zhenxun-org/zhenxun_bot.git
synced 2025-12-15 14:22:55 +08:00
🚑 修复pydantic2情况下的商店模型构造
This commit is contained in:
parent
b548ea522b
commit
b9e08a6ad4
@ -4,7 +4,7 @@ from datetime import datetime, timedelta
|
|||||||
import inspect
|
import inspect
|
||||||
import time
|
import time
|
||||||
from types import MappingProxyType
|
from types import MappingProxyType
|
||||||
from typing import Any, ClassVar, Literal
|
from typing import Any, Literal
|
||||||
|
|
||||||
from nonebot.adapters import Bot, Event
|
from nonebot.adapters import Bot, Event
|
||||||
from nonebot.compat import model_dump
|
from nonebot.compat import model_dump
|
||||||
@ -65,15 +65,15 @@ class ShopParam(BaseModel):
|
|||||||
"""道具单次使用数量"""
|
"""道具单次使用数量"""
|
||||||
text: str
|
text: str
|
||||||
"""text"""
|
"""text"""
|
||||||
send_success_msg: ClassVar[bool] = True
|
send_success_msg: bool = True
|
||||||
"""是否发送使用成功信息"""
|
"""是否发送使用成功信息"""
|
||||||
max_num_limit: ClassVar[int] = 1
|
max_num_limit: int = 1
|
||||||
"""单次使用最大次数"""
|
"""单次使用最大次数"""
|
||||||
session: Uninfo | None = None
|
session: Uninfo | None = None
|
||||||
"""Uninfo"""
|
"""Uninfo"""
|
||||||
message: UniMsg
|
message: UniMsg
|
||||||
"""UniMessage"""
|
"""UniMessage"""
|
||||||
extra_data: ClassVar[dict[str, Any]] = {}
|
extra_data: dict[str, Any] = Field(default_factory=dict)
|
||||||
"""额外数据"""
|
"""额外数据"""
|
||||||
|
|
||||||
class Config:
|
class Config:
|
||||||
@ -384,10 +384,10 @@ class ShopManage:
|
|||||||
cls.uuid2goods[uuid] = Goods(
|
cls.uuid2goods[uuid] = Goods(
|
||||||
model=create_model(
|
model=create_model(
|
||||||
f"{uuid}_model",
|
f"{uuid}_model",
|
||||||
send_success_msg=send_success_msg,
|
|
||||||
max_num_limit=max_num_limit,
|
|
||||||
__base__=ShopParam,
|
__base__=ShopParam,
|
||||||
extra_data=kwargs,
|
send_success_msg=(bool, Field(default=send_success_msg)),
|
||||||
|
max_num_limit=(int, Field(default=max_num_limit)),
|
||||||
|
extra_data=(dict[str, Any], Field(default=kwargs)),
|
||||||
),
|
),
|
||||||
params=kwargs,
|
params=kwargs,
|
||||||
before_handle=before_handle,
|
before_handle=before_handle,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user