Skip to content

Commit

Permalink
🐛 login model compat
Browse files Browse the repository at this point in the history
  • Loading branch information
RF-Tar-Railt committed Dec 12, 2024
1 parent 437c374 commit ca48240
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
13 changes: 13 additions & 0 deletions nonebot/adapters/satori/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,19 @@ def id(self) -> str:
class Config:
extra = "allow"

@model_validator(mode="before")
def ensure_user(cls, values):
if isinstance(values, dict):
if "self_id" in values and "user" not in values:
values["user"] = {"id": values["self_id"]}
if "sn" not in values:
values["sn"] = values["user"]["id"]
if "adapter" not in values:
values["adapter"] = "satori"
if "status" not in values:
values["status"] = LoginStatus.ONLINE
return values


class LoginOnline(Login):
status: Literal[LoginStatus.ONLINE] = LoginStatus.ONLINE
Expand Down
2 changes: 1 addition & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def pytest_configure(config: pytest.Config) -> None:
config.stash[NONEBOT_INIT_KWARGS] = {
"driver": "~httpx+~websockets",
"log_level": "DEBUG",
"satori_clients": [{"host": "localhost", "port": "5500", "path": "", "token": "test_token"}],
# "satori_clients": [{"host": "localhost", "port": "5500", "path": "", "token": "test_token"}],
}


Expand Down

0 comments on commit ca48240

Please sign in to comment.