2024-12-17 13:25:30 +08:00
|
|
|
from typing import TYPE_CHECKING, Any
|
|
|
|
|
|
|
|
from nonebot.adapters import Bot, Event
|
|
|
|
from nonebot.matcher import Matcher
|
|
|
|
from nonebot.typing import T_State
|
|
|
|
from pydantic import BaseModel
|
|
|
|
|
|
|
|
if TYPE_CHECKING:
|
|
|
|
from .caller import Caller
|
|
|
|
|
|
|
|
|
|
|
|
class SessionContext(BaseModel):
|
|
|
|
"""依赖注入会话上下文
|
|
|
|
|
|
|
|
Args:
|
|
|
|
BaseModel (_type_): _description_
|
|
|
|
"""
|
|
|
|
|
|
|
|
bot: Bot
|
|
|
|
event: Event
|
|
|
|
matcher: Matcher
|
2025-02-24 01:19:26 +08:00
|
|
|
# state: T_State
|
2024-12-17 13:25:30 +08:00
|
|
|
caller: Any = None
|
|
|
|
|
|
|
|
class Config:
|
|
|
|
arbitrary_types_allowed = True
|
|
|
|
|
|
|
|
|
|
|
|
class SessionContextDepends(BaseModel):
|
|
|
|
bot: str | None = None
|
|
|
|
event: str | None = None
|
|
|
|
matcher: str | None = None
|
2025-02-24 01:19:26 +08:00
|
|
|
# state: str | None = None
|
2024-12-17 13:25:30 +08:00
|
|
|
caller: str | None = None
|