跳转至

relationship

Client 🔗

Bases: AriadneBaseModel

指示其他客户端

Source code in src/graia/ariadne/model/relationship.py
327
328
329
330
331
332
333
334
335
336
337
338
class Client(AriadneBaseModel):
    """
    指示其他客户端
    """

    id: int
    """客户端 ID"""

    platform: str
    """平台字符串表示"""

    __kind: Optional[Literal["OtherClient"]] = Field(None, alias="kind")

id: int instance-attribute 🔗

客户端 ID

platform: str instance-attribute 🔗

平台字符串表示

Friend 🔗

Bases: AriadneBaseModel

描述 Tencent QQ 中的好友.

Source code in src/graia/ariadne/model/relationship.py
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
class Friend(AriadneBaseModel):
    """描述 Tencent QQ 中的好友."""

    id: int
    """QQ 号"""

    nickname: str
    """昵称"""

    remark: str
    """自行设置的代称"""

    __kind: Optional[Literal["Friend"]] = Field(None, alias="kind")

    def __int__(self):
        return self.id

    def __str__(self) -> str:
        return f"{self.remark}({self.id})"

    def __eq__(self, other: Any) -> bool:
        return isinstance(other, (Friend, Member, Stranger)) and self.id == other.id

    async def get_profile(self) -> "Profile":
        """获取该好友的 Profile

        Returns:
            Profile: 该好友的 Profile 对象
        """
        from ..app import Ariadne

        return await Ariadne.current().get_friend_profile(self)

    async def get_avatar(self, size: Literal[640, 140] = 640) -> bytes:
        """获取该好友的头像

        Args:
            size (Literal[640, 140]): 头像尺寸

        Returns:
            bytes: 好友头像的二进制内容.
        """
        from ..app import Ariadne

        async with Ariadne.service.client_session.get(
            f"https://q2.qlogo.cn/headimg_dl?dst_uin={self.id}&spec={size}"
        ) as resp:
            return await resp.read()

id: int instance-attribute 🔗

QQ 号

nickname: str instance-attribute 🔗

昵称

remark: str instance-attribute 🔗

自行设置的代称

get_avatar(size=640) async 🔗

获取该好友的头像

Parameters:

Name Type Description Default
size Literal[640, 140]

头像尺寸

640

Returns:

Name Type Description
bytes bytes

好友头像的二进制内容.

Source code in src/graia/ariadne/model/relationship.py
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
async def get_avatar(self, size: Literal[640, 140] = 640) -> bytes:
    """获取该好友的头像

    Args:
        size (Literal[640, 140]): 头像尺寸

    Returns:
        bytes: 好友头像的二进制内容.
    """
    from ..app import Ariadne

    async with Ariadne.service.client_session.get(
        f"https://q2.qlogo.cn/headimg_dl?dst_uin={self.id}&spec={size}"
    ) as resp:
        return await resp.read()

get_profile() async 🔗

获取该好友的 Profile

Returns:

Name Type Description
Profile Profile

该好友的 Profile 对象

Source code in src/graia/ariadne/model/relationship.py
225
226
227
228
229
230
231
232
233
async def get_profile(self) -> "Profile":
    """获取该好友的 Profile

    Returns:
        Profile: 该好友的 Profile 对象
    """
    from ..app import Ariadne

    return await Ariadne.current().get_friend_profile(self)

Group 🔗

Bases: AriadneBaseModel

描述 Tencent QQ 中的群组.

Source code in src/graia/ariadne/model/relationship.py
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
class Group(AriadneBaseModel):
    """描述 Tencent QQ 中的群组."""

    id: int
    """群号"""

    name: str
    """群名"""

    account_perm: MemberPerm = Field(..., alias="permission")
    """你在群中的权限"""

    __kind: Optional[Literal["Group"]] = Field(None, alias="kind")

    def __int__(self):
        return self.id

    def __str__(self) -> str:
        return f"{self.name}({self.id})"

    def __eq__(self, other: Any) -> bool:
        return isinstance(other, Group) and self.id == other.id

    async def get_config(self) -> "GroupConfig":
        """获取该群组的 Config

        Returns:
            Config: 该群组的设置对象.
        """
        from ..app import Ariadne

        return await Ariadne.current().get_group_config(self)

    async def modify_config(self, config: "GroupConfig") -> None:
        """修改该群组的 Config

        Args:
            config (GroupConfig): 经过修改后的群设置对象.
        """
        from ..app import Ariadne

        return await Ariadne.current().modify_group_config(self, config)

    async def get_avatar(self, cover: Optional[int] = None) -> bytes:
        """获取该群组的头像
        Args:
            cover (Optional[int]): 群封面标号 (若为 None 则获取该群头像, 否则获取该群封面)

        Returns:
            bytes: 群头像的二进制内容.
        """
        from ..app import Ariadne

        cover = (cover or 0) + 1
        rider = await Ariadne.service.http_interface.request(
            "GET", f"http://p.qlogo.cn/gh/{self.id}/{self.id}_{cover}/"
        )
        return await rider.io().read()

account_perm: MemberPerm = Field(..., alias='permission') class-attribute instance-attribute 🔗

你在群中的权限

id: int instance-attribute 🔗

群号

name: str instance-attribute 🔗

群名

get_avatar(cover=None) async 🔗

获取该群组的头像 Args: cover (Optional[int]): 群封面标号 (若为 None 则获取该群头像, 否则获取该群封面)

Returns:

Name Type Description
bytes bytes

群头像的二进制内容.

Source code in src/graia/ariadne/model/relationship.py
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
async def get_avatar(self, cover: Optional[int] = None) -> bytes:
    """获取该群组的头像
    Args:
        cover (Optional[int]): 群封面标号 (若为 None 则获取该群头像, 否则获取该群封面)

    Returns:
        bytes: 群头像的二进制内容.
    """
    from ..app import Ariadne

    cover = (cover or 0) + 1
    rider = await Ariadne.service.http_interface.request(
        "GET", f"http://p.qlogo.cn/gh/{self.id}/{self.id}_{cover}/"
    )
    return await rider.io().read()

get_config() async 🔗

获取该群组的 Config

Returns:

Name Type Description
Config GroupConfig

该群组的设置对象.

Source code in src/graia/ariadne/model/relationship.py
66
67
68
69
70
71
72
73
74
async def get_config(self) -> "GroupConfig":
    """获取该群组的 Config

    Returns:
        Config: 该群组的设置对象.
    """
    from ..app import Ariadne

    return await Ariadne.current().get_group_config(self)

modify_config(config) async 🔗

修改该群组的 Config

Parameters:

Name Type Description Default
config GroupConfig

经过修改后的群设置对象.

required
Source code in src/graia/ariadne/model/relationship.py
76
77
78
79
80
81
82
83
84
async def modify_config(self, config: "GroupConfig") -> None:
    """修改该群组的 Config

    Args:
        config (GroupConfig): 经过修改后的群设置对象.
    """
    from ..app import Ariadne

    return await Ariadne.current().modify_group_config(self, config)

GroupConfig 🔗

Bases: AriadneBaseModel

描述群组各项功能的设置.

Source code in src/graia/ariadne/model/relationship.py
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
class GroupConfig(AriadneBaseModel):
    """描述群组各项功能的设置."""

    name: str = ""
    """群名"""

    announcement: str = ""
    """群公告"""

    confess_talk: bool = False
    """开启坦白说"""

    allow_member_invite: bool = False
    """允许群成员直接邀请入群"""

    auto_approve: bool = False
    """自动通过加群申请"""

    anonymous_chat: bool = False
    """允许匿名聊天"""

    mute_all: bool = Field(False, exclude=True)
    """是否在全员禁言"""

allow_member_invite: bool = False class-attribute instance-attribute 🔗

允许群成员直接邀请入群

announcement: str = '' class-attribute instance-attribute 🔗

群公告

anonymous_chat: bool = False class-attribute instance-attribute 🔗

允许匿名聊天

auto_approve: bool = False class-attribute instance-attribute 🔗

自动通过加群申请

confess_talk: bool = False class-attribute instance-attribute 🔗

开启坦白说

mute_all: bool = Field(False, exclude=True) class-attribute instance-attribute 🔗

是否在全员禁言

name: str = '' class-attribute instance-attribute 🔗

群名

Member 🔗

Bases: AriadneBaseModel

描述用户在群组中所具备的有关状态, 包括所在群组, 群中昵称, 所具备的权限, 唯一ID.

Source code in src/graia/ariadne/model/relationship.py
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
class Member(AriadneBaseModel):
    """描述用户在群组中所具备的有关状态, 包括所在群组, 群中昵称, 所具备的权限, 唯一ID."""

    id: int
    """QQ 号"""

    name: str = Field(..., alias="memberName")
    """显示名称"""

    permission: MemberPerm
    """群权限"""

    special_title: Optional[str] = Field(None, alias="specialTitle")
    """特殊头衔"""

    join_timestamp: Optional[int] = Field(None, alias="joinTimestamp")
    """加入的时间"""

    last_speak_timestamp: Optional[int] = Field(None, alias="lastSpeakTimestamp")
    """最后发言时间"""

    mute_time: Optional[int] = Field(None, alias="mutetimeRemaining")
    """禁言剩余时间"""

    group: Group
    """所在群组"""

    def __str__(self) -> str:
        return f"{self.name}({self.id} @ {self.group})"

    def __int__(self):
        return self.id

    def __eq__(self, other: Any) -> bool:
        return isinstance(other, (Friend, Member, Stranger)) and self.id == other.id

    async def get_profile(self) -> "Profile":
        """获取该群成员的 Profile

        Returns:
            Profile: 该群成员的 Profile 对象
        """
        from ..app import Ariadne

        return await Ariadne.current().get_member_profile(self)

    async def get_info(self) -> "MemberInfo":
        """获取该成员的可修改状态

        Returns:
            MemberInfo: 群组成员的可修改状态
        """
        return MemberInfo(name=self.name, specialTitle=self.special_title)

    async def modify_info(self, info: "MemberInfo") -> None:
        """
        修改群组成员的可修改状态; 需要具有相应权限(管理员/群主).

        Args:
            info (MemberInfo): 已修改的指定群组成员的可修改状态

        Returns:
            None: 没有返回.
        """
        from ..app import Ariadne

        return await Ariadne.current().modify_member_info(self, info)

    async def modify_admin(self, assign: bool) -> None:
        """
        修改一位群组成员管理员权限; 需要有相应权限(群主)

        Args:
            assign (bool): 是否设置群成员为管理员.

        Returns:
            None: 没有返回.
        """
        from ..app import Ariadne

        return await Ariadne.current().modify_member_admin(assign, self)

    async def get_avatar(self, size: Literal[640, 140] = 640) -> bytes:
        """获取该群成员的头像

        Args:
            size (Literal[640, 140]): 头像尺寸

        Returns:
            bytes: 群成员头像的二进制内容.
        """
        from ..app import Ariadne

        async with Ariadne.service.client_session.get(
            f"https://q2.qlogo.cn/headimg_dl?dst_uin={self.id}&spec={size}"
        ) as resp:
            return await resp.read()

group: Group instance-attribute 🔗

所在群组

id: int instance-attribute 🔗

QQ 号

join_timestamp: Optional[int] = Field(None, alias='joinTimestamp') class-attribute instance-attribute 🔗

加入的时间

last_speak_timestamp: Optional[int] = Field(None, alias='lastSpeakTimestamp') class-attribute instance-attribute 🔗

最后发言时间

mute_time: Optional[int] = Field(None, alias='mutetimeRemaining') class-attribute instance-attribute 🔗

禁言剩余时间

name: str = Field(..., alias='memberName') class-attribute instance-attribute 🔗

显示名称

permission: MemberPerm instance-attribute 🔗

群权限

special_title: Optional[str] = Field(None, alias='specialTitle') class-attribute instance-attribute 🔗

特殊头衔

get_avatar(size=640) async 🔗

获取该群成员的头像

Parameters:

Name Type Description Default
size Literal[640, 140]

头像尺寸

640

Returns:

Name Type Description
bytes bytes

群成员头像的二进制内容.

Source code in src/graia/ariadne/model/relationship.py
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
async def get_avatar(self, size: Literal[640, 140] = 640) -> bytes:
    """获取该群成员的头像

    Args:
        size (Literal[640, 140]): 头像尺寸

    Returns:
        bytes: 群成员头像的二进制内容.
    """
    from ..app import Ariadne

    async with Ariadne.service.client_session.get(
        f"https://q2.qlogo.cn/headimg_dl?dst_uin={self.id}&spec={size}"
    ) as resp:
        return await resp.read()

get_info() async 🔗

获取该成员的可修改状态

Returns:

Name Type Description
MemberInfo MemberInfo

群组成员的可修改状态

Source code in src/graia/ariadne/model/relationship.py
149
150
151
152
153
154
155
async def get_info(self) -> "MemberInfo":
    """获取该成员的可修改状态

    Returns:
        MemberInfo: 群组成员的可修改状态
    """
    return MemberInfo(name=self.name, specialTitle=self.special_title)

get_profile() async 🔗

获取该群成员的 Profile

Returns:

Name Type Description
Profile Profile

该群成员的 Profile 对象

Source code in src/graia/ariadne/model/relationship.py
139
140
141
142
143
144
145
146
147
async def get_profile(self) -> "Profile":
    """获取该群成员的 Profile

    Returns:
        Profile: 该群成员的 Profile 对象
    """
    from ..app import Ariadne

    return await Ariadne.current().get_member_profile(self)

modify_admin(assign) async 🔗

修改一位群组成员管理员权限; 需要有相应权限(群主)

Parameters:

Name Type Description Default
assign bool

是否设置群成员为管理员.

required

Returns:

Name Type Description
None None

没有返回.

Source code in src/graia/ariadne/model/relationship.py
171
172
173
174
175
176
177
178
179
180
181
182
183
async def modify_admin(self, assign: bool) -> None:
    """
    修改一位群组成员管理员权限; 需要有相应权限(群主)

    Args:
        assign (bool): 是否设置群成员为管理员.

    Returns:
        None: 没有返回.
    """
    from ..app import Ariadne

    return await Ariadne.current().modify_member_admin(assign, self)

modify_info(info) async 🔗

修改群组成员的可修改状态; 需要具有相应权限(管理员/群主).

Parameters:

Name Type Description Default
info MemberInfo

已修改的指定群组成员的可修改状态

required

Returns:

Name Type Description
None None

没有返回.

Source code in src/graia/ariadne/model/relationship.py
157
158
159
160
161
162
163
164
165
166
167
168
169
async def modify_info(self, info: "MemberInfo") -> None:
    """
    修改群组成员的可修改状态; 需要具有相应权限(管理员/群主).

    Args:
        info (MemberInfo): 已修改的指定群组成员的可修改状态

    Returns:
        None: 没有返回.
    """
    from ..app import Ariadne

    return await Ariadne.current().modify_member_info(self, info)

MemberInfo 🔗

Bases: AriadneBaseModel

描述群组成员的可修改状态, 修改需要管理员/群主权限.

Source code in src/graia/ariadne/model/relationship.py
317
318
319
320
321
322
323
324
class MemberInfo(AriadneBaseModel):
    """描述群组成员的可修改状态, 修改需要管理员/群主权限."""

    name: str = ""
    """昵称, 与 nickname不同"""

    special_title: Optional[str] = Field(default="", alias="specialTitle")
    """特殊头衔"""

name: str = '' class-attribute instance-attribute 🔗

昵称, 与 nickname不同

special_title: Optional[str] = Field(default='', alias='specialTitle') class-attribute instance-attribute 🔗

特殊头衔

MemberPerm 🔗

Bases: Enum

描述群成员在群组中所具备的权限

Source code in src/graia/ariadne/model/relationship.py
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
@functools.total_ordering
class MemberPerm(Enum):
    """描述群成员在群组中所具备的权限"""

    Member = "MEMBER"  # 普通成员
    Administrator = "ADMINISTRATOR"  # 管理员
    Owner = "OWNER"  # 群主

    def __str__(self) -> str:
        return self.value

    def __lt__(self, other: "MemberPerm"):
        return _MEMBER_PERM_LV_MAP[self.value] < _MEMBER_PERM_LV_MAP[other.value]

    def __repr__(self) -> str:
        return _MEMBER_PERM_REPR_MAP[self.value]

Stranger 🔗

Bases: AriadneBaseModel

描述 Tencent QQ 中的陌生人.

Source code in src/graia/ariadne/model/relationship.py
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
class Stranger(AriadneBaseModel):
    """描述 Tencent QQ 中的陌生人."""

    id: int
    """QQ 号"""

    nickname: str
    """昵称"""

    remark: str
    """自行设置的代称"""

    __kind: Optional[Literal["Stranger"]] = Field(None, alias="kind")

    def __int__(self):
        return self.id

    def __str__(self) -> str:
        return f"Stranger({self.id}, {self.nickname})"

    def __eq__(self, other: Any) -> bool:
        return isinstance(other, (Friend, Member, Stranger)) and self.id == other.id

    async def get_avatar(self, size: Literal[640, 140] = 640) -> bytes:
        """获取该陌生人的头像

        Args:
            size (Literal[640, 140]): 头像尺寸

        Returns:
            bytes: 陌生人头像的二进制内容.
        """
        from ..app import Ariadne

        async with Ariadne.service.client_session.get(
            f"https://q2.qlogo.cn/headimg_dl?dst_uin={self.id}&spec={size}"
        ) as resp:
            return await resp.read()

id: int instance-attribute 🔗

QQ 号

nickname: str instance-attribute 🔗

昵称

remark: str instance-attribute 🔗

自行设置的代称

get_avatar(size=640) async 🔗

获取该陌生人的头像

Parameters:

Name Type Description Default
size Literal[640, 140]

头像尺寸

640

Returns:

Name Type Description
bytes bytes

陌生人头像的二进制内容.

Source code in src/graia/ariadne/model/relationship.py
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
async def get_avatar(self, size: Literal[640, 140] = 640) -> bytes:
    """获取该陌生人的头像

    Args:
        size (Literal[640, 140]): 头像尺寸

    Returns:
        bytes: 陌生人头像的二进制内容.
    """
    from ..app import Ariadne

    async with Ariadne.service.client_session.get(
        f"https://q2.qlogo.cn/headimg_dl?dst_uin={self.id}&spec={size}"
    ) as resp:
        return await resp.read()