模块 liteyuki.session.models
本模块使用了nonebot-plugin-uninfo的部分模型定义 MIT License
Copyright (c) 2024 RF-Tar-Railt
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
class SceneType(int, Enum)
attr PRIVATE = 0
attr GROUP = 1
attr GUILD = 2
attr CHANNEL_TEXT = 3
attr CHANNEL_CATEGORY = 4
attr CHANNEL_VOICE = 5
class User(BaseModel)
attr id: str = NO_DEFAULT
attr name: str | None = None
attr nick: str | None = None
attr avatar: str | None = None
attr gender: str | None = None
class Scene(BaseModel)
attr id: str = NO_DEFAULT
attr type: SceneType = NO_DEFAULT
attr name: str | None = None
attr avatar: str | None = None
attr parent: 'Scene | None' = None
class Role(BaseModel)
attr id: str = NO_DEFAULT
attr level: int | None = None
attr name: str | None = None
class Member(BaseModel)
attr user: User = NO_DEFAULT
attr nickname: str | None = None
attr role: Role | None = None
attr mute: bool | None = None
attr joined_at: datetime | None = None
class Session(BaseModel)
func session_id(self)
源代码 或 在GitHub上查看
@property
def session_id(self):
if self.scope == SceneType.PRIVATE:
return f'{self.scope}:{self.user.id}'
elif self.scope in (SceneType.GROUP, SceneType.GUILD, SceneType.CHANNEL_TEXT, SceneType.CHANNEL_VOICE, SceneType.CHANNEL_CATEGORY):
return f'{self.scope}:{self.scene.id}'
else:
raise ValueError('Invalid SceneType')
func target_id(self)
源代码 或 在GitHub上查看
@property
def target_id(self):
if self.scope == SceneType.PRIVATE:
return f'{self.scope}:{self.user.id}'
elif self.scope in (SceneType.GROUP, SceneType.GUILD, SceneType.CHANNEL_TEXT, SceneType.CHANNEL_VOICE, SceneType.CHANNEL_CATEGORY):
return f'{self.scope}:{self.scene.id}:{self.user.id}'