Source code for mirai_core.models.entity

from pydantic import BaseModel
from typing import Optional
from enum import Enum


[docs]class Friend(BaseModel): id: int nickname: Optional[str] remark: Optional[str] def __repr__(self): return f"<Friend id={self.id} nickname='{self.nickname}' remark='{self.remark}'>"
[docs] def get_avatar_url(self) -> str: return f'http://q4.qlogo.cn/g?b=qq&nk={self.id}&s=140'
[docs]class Permission(Enum): Member = "MEMBER" Administrator = "ADMINISTRATOR" Owner = "OWNER"
[docs]class Group(BaseModel): id: int name: str permission: Permission def __repr__(self): return f"<Group id={self.id} name='{self.name}' permission={self.permission.name}>"
[docs] def get_avatar_url(self) -> str: return f'https://p.qlogo.cn/gh/{self.id}/{self.id}_1/140'
[docs]class Member(BaseModel): id: int memberName: str permission: Permission group: Group def __repr__(self): return f"<GroupMember id={self.id} group={self.group} permission={self.permission} group={self.group.id}>"
[docs] def get_avatar_url(self) -> str: return f'http://q4.qlogo.cn/g?b=qq&nk={self.id}&s=140'
[docs]class MemberChangeableSetting(BaseModel): name: str specialTitle: str
[docs] def modify(self, **kwargs): for i in ("name", "kwargs"): if i in kwargs: setattr(self, i, kwargs[i]) return self
[docs]class GroupSetting(BaseModel): name: str announcement: str confessTalk: bool allowMemberInvite: bool autoApprove: bool anonymousChat: bool
[docs] def modify(self, **kwargs): for i in ("name", "announcement", "confessTalk", "allowMemberInvite", "autoApprove", "anonymousChat" ): if i in kwargs: setattr(self, i, kwargs[i]) return self