Skip to content

Commit

Permalink
🐛 version 0.12.6
Browse files Browse the repository at this point in the history
fix model_validator
  • Loading branch information
RF-Tar-Railt committed Sep 22, 2024
1 parent 2646f94 commit bfa5385
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
24 changes: 14 additions & 10 deletions nonebot/adapters/satori/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,8 +246,9 @@ def get_message(self) -> Message:

@model_validator(mode="before")
def generate_message(cls, values):
values["_message"] = Message.from_satori_element(parse(values["message"]["content"]))
values["original_message"] = deepcopy(values["_message"])
if isinstance(values, dict):
values["_message"] = Message.from_satori_element(parse(values["message"]["content"]))
values["original_message"] = deepcopy(values["_message"])
return values

@property
Expand Down Expand Up @@ -405,7 +406,8 @@ def get_session_id(self) -> str:

@model_validator(mode="before")
def generate_message(cls, values):
values["_message"] = Message.from_satori_element(parse(values["message"]["content"]))
if isinstance(values, dict):
values["_message"] = Message.from_satori_element(parse(values["message"]["content"]))
return values

@property
Expand Down Expand Up @@ -526,11 +528,12 @@ def get_event_description(self) -> str:

@model_validator(mode="before")
def generate_message(cls, values):
cmd = values["argv"]["name"]
if values["argv"].get("arguments", []):
cmd += " ".join(values["argv"]["arguments"])
values["_message"] = Message(cmd)
values["original_message"] = deepcopy(values["_message"])
if isinstance(values, dict):
cmd = values["argv"]["name"]
if values["argv"].get("arguments", []):
cmd += " ".join(values["argv"]["arguments"])
values["_message"] = Message(cmd)
values["original_message"] = deepcopy(values["_message"])
return values

def convert(self):
Expand Down Expand Up @@ -576,8 +579,9 @@ class InteractionCommandMessageEvent(InteractionCommandEvent):

@model_validator(mode="before")
def generate_message(cls, values):
values["_message"] = Message.from_satori_element(parse(values["message"]["content"]))
values["original_message"] = deepcopy(values["_message"])
if isinstance(values, dict):
values["_message"] = Message.from_satori_element(parse(values["message"]["content"]))
values["original_message"] = deepcopy(values["_message"])
return values

@override
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "nonebot-adapter-satori"
version = "0.12.5"
version = "0.12.6"
description = "Satori Protocol Adapter for Nonebot2"
authors = [
{name = "RF-Tar-Railt",email = "rf_tar_railt@qq.com"},
Expand Down

0 comments on commit bfa5385

Please sign in to comment.