qqbot-sdk-python 0.4.1__cp310-abi3-macosx_11_0_arm64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- qqbot_sdk_python/__init__.py +9 -0
- qqbot_sdk_python/_native.abi3.so +0 -0
- qqbot_sdk_python/_native.pyi +57 -0
- qqbot_sdk_python/api.py +627 -0
- qqbot_sdk_python/py.typed +0 -0
- qqbot_sdk_python-0.4.1.dist-info/METADATA +87 -0
- qqbot_sdk_python-0.4.1.dist-info/RECORD +9 -0
- qqbot_sdk_python-0.4.1.dist-info/WHEEL +4 -0
- qqbot_sdk_python-0.4.1.dist-info/sboms/qqbot-sdk-python.cyclonedx.json +6961 -0
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"""异步 QQ 机器人 SDK。"""
|
|
2
|
+
|
|
3
|
+
from ._native import ApiError as ApiError
|
|
4
|
+
from ._native import Bot as Bot
|
|
5
|
+
from ._native import BotError as BotError
|
|
6
|
+
from ._native import Target as Target
|
|
7
|
+
from ._native import User as User
|
|
8
|
+
|
|
9
|
+
__all__ = ["ApiError", "Bot", "BotError", "Target", "User"]
|
|
Binary file
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
from collections.abc import Awaitable, Callable
|
|
2
|
+
from typing import Any, Literal
|
|
3
|
+
|
|
4
|
+
from .api import BotApi
|
|
5
|
+
|
|
6
|
+
class BotError(Exception): ...
|
|
7
|
+
|
|
8
|
+
class ApiError(BotError):
|
|
9
|
+
status: int
|
|
10
|
+
code: int
|
|
11
|
+
message: str
|
|
12
|
+
trace_id: str | None
|
|
13
|
+
data: Any
|
|
14
|
+
|
|
15
|
+
class Bot:
|
|
16
|
+
def __init__(
|
|
17
|
+
self,
|
|
18
|
+
app_id: str,
|
|
19
|
+
app_secret: str,
|
|
20
|
+
*,
|
|
21
|
+
mode: Literal["public", "private", "webhook"] = "public",
|
|
22
|
+
intents: int | None = None,
|
|
23
|
+
api_base_url: str | None = None,
|
|
24
|
+
) -> None: ...
|
|
25
|
+
@property
|
|
26
|
+
def api(self) -> BotApi: ...
|
|
27
|
+
def user(self, user_openid: str) -> User: ...
|
|
28
|
+
def group(self, id: str) -> Target: ...
|
|
29
|
+
def channel(self, id: str) -> Target: ...
|
|
30
|
+
def direct(self, id: str) -> Target: ...
|
|
31
|
+
def _call(self, operation: str, *args: Any) -> Awaitable[Any]: ...
|
|
32
|
+
def _upload_material(
|
|
33
|
+
self, file_name: str, content_type: str, data: bytes
|
|
34
|
+
) -> Awaitable[dict[str, Any]]: ...
|
|
35
|
+
def _upload_media(
|
|
36
|
+
self, kind: Literal["user", "group"], id: str, file_type: int,
|
|
37
|
+
data: bytes, srv_send_msg: bool = False,
|
|
38
|
+
) -> Awaitable[dict[str, Any]]: ...
|
|
39
|
+
def _send_media(
|
|
40
|
+
self, kind: Literal["user", "group"], id: str, file_type: int,
|
|
41
|
+
data: bytes, message: str | dict[str, Any],
|
|
42
|
+
) -> Awaitable[dict[str, Any]]: ...
|
|
43
|
+
def handle_webhook(
|
|
44
|
+
self, timestamp: str, signature: str, body: bytes
|
|
45
|
+
) -> dict[str, Any]: ...
|
|
46
|
+
def run(self, callback: Callable[[dict[str, Any]], None]) -> Awaitable[None]: ...
|
|
47
|
+
def stop(self) -> None: ...
|
|
48
|
+
|
|
49
|
+
class Target:
|
|
50
|
+
@property
|
|
51
|
+
def id(self) -> str: ...
|
|
52
|
+
def send(
|
|
53
|
+
self, content: str | dict[str, Any], *, msg_id: str | None = None
|
|
54
|
+
) -> Awaitable[dict[str, Any]]: ...
|
|
55
|
+
def recall(self, message_id: str, hide_tip: bool = False) -> Awaitable[None]: ...
|
|
56
|
+
|
|
57
|
+
class User(Target): ...
|
qqbot_sdk_python/api.py
ADDED
|
@@ -0,0 +1,627 @@
|
|
|
1
|
+
# Generated by packages/npm/scripts/generate-api.py.
|
|
2
|
+
"""Grouped QQ API methods shared with the Rust and Node.js SDKs."""
|
|
3
|
+
|
|
4
|
+
from __future__ import annotations
|
|
5
|
+
|
|
6
|
+
from typing import Any, Literal, TypedDict
|
|
7
|
+
|
|
8
|
+
from ._native import Bot as _NativeBot
|
|
9
|
+
|
|
10
|
+
Message = str | dict[str, Any]
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class MediaTarget(TypedDict):
|
|
14
|
+
kind: Literal["user", "group"]
|
|
15
|
+
id: str
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class _ApiGroup:
|
|
19
|
+
def __init__(self, client: _NativeBot) -> None:
|
|
20
|
+
self._client = client
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
class BotMethods(_ApiGroup):
|
|
24
|
+
async def me(self) -> dict[str, Any]:
|
|
25
|
+
return await self._client._call("bot.me")
|
|
26
|
+
|
|
27
|
+
async def guilds(
|
|
28
|
+
self,
|
|
29
|
+
before: str | None = None,
|
|
30
|
+
after: str | None = None,
|
|
31
|
+
limit: int | None = None,
|
|
32
|
+
) -> list[dict[str, Any]]:
|
|
33
|
+
return await self._client._call("bot.guilds", before, after, limit)
|
|
34
|
+
|
|
35
|
+
async def create_dm(self, body: dict[str, Any]) -> Any:
|
|
36
|
+
return await self._client._call("bot.createDm", body)
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
class ChannelsMethods(_ApiGroup):
|
|
40
|
+
async def get(self, channel_id: str) -> dict[str, Any]:
|
|
41
|
+
return await self._client._call("channels.get", channel_id)
|
|
42
|
+
|
|
43
|
+
async def list(self, guild_id: str) -> list[dict[str, Any]]:
|
|
44
|
+
return await self._client._call("channels.list", guild_id)
|
|
45
|
+
|
|
46
|
+
async def update(self, channel_id: str, body: dict[str, Any]) -> dict[str, Any]:
|
|
47
|
+
return await self._client._call("channels.update", channel_id, body)
|
|
48
|
+
|
|
49
|
+
async def delete(self, channel_id: str) -> None:
|
|
50
|
+
return await self._client._call("channels.delete", channel_id)
|
|
51
|
+
|
|
52
|
+
async def create_announcement(self, channel_id: str, body: dict[str, Any]) -> Any:
|
|
53
|
+
return await self._client._call("channels.createAnnouncement", channel_id, body)
|
|
54
|
+
|
|
55
|
+
async def delete_announcement(self, channel_id: str, message_id: str) -> None:
|
|
56
|
+
return await self._client._call("channels.deleteAnnouncement", channel_id, message_id)
|
|
57
|
+
|
|
58
|
+
async def audio_control(self, channel_id: str, body: dict[str, Any]) -> Any:
|
|
59
|
+
return await self._client._call("channels.audioControl", channel_id, body)
|
|
60
|
+
|
|
61
|
+
async def enable_mic(self, channel_id: str, body: dict[str, Any]) -> Any:
|
|
62
|
+
return await self._client._call("channels.enableMic", channel_id, body)
|
|
63
|
+
|
|
64
|
+
async def disable_mic(self, channel_id: str) -> None:
|
|
65
|
+
return await self._client._call("channels.disableMic", channel_id)
|
|
66
|
+
|
|
67
|
+
async def list_threads(self, channel_id: str) -> Any:
|
|
68
|
+
return await self._client._call("channels.listThreads", channel_id)
|
|
69
|
+
|
|
70
|
+
async def get_thread(self, channel_id: str, thread_id: str) -> Any:
|
|
71
|
+
return await self._client._call("channels.getThread", channel_id, thread_id)
|
|
72
|
+
|
|
73
|
+
async def create_thread(self, channel_id: str, body: dict[str, Any]) -> Any:
|
|
74
|
+
return await self._client._call("channels.createThread", channel_id, body)
|
|
75
|
+
|
|
76
|
+
async def delete_thread(self, channel_id: str, thread_id: str) -> None:
|
|
77
|
+
return await self._client._call("channels.deleteThread", channel_id, thread_id)
|
|
78
|
+
|
|
79
|
+
async def list_pins(self, channel_id: str) -> Any:
|
|
80
|
+
return await self._client._call("channels.listPins", channel_id)
|
|
81
|
+
|
|
82
|
+
async def pin_message(self, channel_id: str, message_id: str) -> Any:
|
|
83
|
+
return await self._client._call("channels.pinMessage", channel_id, message_id)
|
|
84
|
+
|
|
85
|
+
async def unpin_message(self, channel_id: str, message_id: str) -> None:
|
|
86
|
+
return await self._client._call("channels.unpinMessage", channel_id, message_id)
|
|
87
|
+
|
|
88
|
+
async def create_schedule(self, channel_id: str, body: dict[str, Any]) -> Any:
|
|
89
|
+
return await self._client._call("channels.createSchedule", channel_id, body)
|
|
90
|
+
|
|
91
|
+
async def list_schedules(self, channel_id: str) -> Any:
|
|
92
|
+
return await self._client._call("channels.listSchedules", channel_id)
|
|
93
|
+
|
|
94
|
+
async def list_schedules_since(self, channel_id: str, since: str | None = None) -> Any:
|
|
95
|
+
return await self._client._call("channels.listSchedulesSince", channel_id, since)
|
|
96
|
+
|
|
97
|
+
async def get_schedule(self, channel_id: str, schedule_id: str) -> Any:
|
|
98
|
+
return await self._client._call("channels.getSchedule", channel_id, schedule_id)
|
|
99
|
+
|
|
100
|
+
async def update_schedule(
|
|
101
|
+
self,
|
|
102
|
+
channel_id: str,
|
|
103
|
+
schedule_id: str,
|
|
104
|
+
body: dict[str, Any],
|
|
105
|
+
) -> Any:
|
|
106
|
+
return await self._client._call("channels.updateSchedule", channel_id, schedule_id, body)
|
|
107
|
+
|
|
108
|
+
async def delete_schedule(self, channel_id: str, schedule_id: str) -> None:
|
|
109
|
+
return await self._client._call("channels.deleteSchedule", channel_id, schedule_id)
|
|
110
|
+
|
|
111
|
+
async def add_reaction(
|
|
112
|
+
self,
|
|
113
|
+
channel_id: str,
|
|
114
|
+
message_id: str,
|
|
115
|
+
reaction_type: str,
|
|
116
|
+
reaction_id: str,
|
|
117
|
+
) -> Any:
|
|
118
|
+
return await self._client._call("channels.addReaction", channel_id, message_id, reaction_type, reaction_id)
|
|
119
|
+
|
|
120
|
+
async def remove_reaction(
|
|
121
|
+
self,
|
|
122
|
+
channel_id: str,
|
|
123
|
+
message_id: str,
|
|
124
|
+
reaction_type: str,
|
|
125
|
+
reaction_id: str,
|
|
126
|
+
) -> None:
|
|
127
|
+
return await self._client._call("channels.removeReaction", channel_id, message_id, reaction_type, reaction_id)
|
|
128
|
+
|
|
129
|
+
async def list_reactions(
|
|
130
|
+
self,
|
|
131
|
+
channel_id: str,
|
|
132
|
+
message_id: str,
|
|
133
|
+
reaction_type: str,
|
|
134
|
+
reaction_id: str,
|
|
135
|
+
cookie: str | None = None,
|
|
136
|
+
limit: int | None = None,
|
|
137
|
+
) -> Any:
|
|
138
|
+
return await self._client._call("channels.listReactions", channel_id, message_id, reaction_type, reaction_id, cookie, limit)
|
|
139
|
+
|
|
140
|
+
async def recall_message(self, channel_id: str, message_id: str, hide_tip: bool) -> None:
|
|
141
|
+
return await self._client._call("channels.recallMessage", channel_id, message_id, hide_tip)
|
|
142
|
+
|
|
143
|
+
async def message_setting(self, guild_id: str) -> Any:
|
|
144
|
+
return await self._client._call("channels.messageSetting", guild_id)
|
|
145
|
+
|
|
146
|
+
async def online_numbers(self, channel_id: str) -> Any:
|
|
147
|
+
return await self._client._call("channels.onlineNumbers", channel_id)
|
|
148
|
+
|
|
149
|
+
async def member_permissions(self, channel_id: str, user_id: str) -> Any:
|
|
150
|
+
return await self._client._call("channels.memberPermissions", channel_id, user_id)
|
|
151
|
+
|
|
152
|
+
async def role_permissions(self, channel_id: str, role_id: str) -> Any:
|
|
153
|
+
return await self._client._call("channels.rolePermissions", channel_id, role_id)
|
|
154
|
+
|
|
155
|
+
async def update_member_permissions(
|
|
156
|
+
self,
|
|
157
|
+
channel_id: str,
|
|
158
|
+
user_id: str,
|
|
159
|
+
body: dict[str, Any],
|
|
160
|
+
) -> Any:
|
|
161
|
+
return await self._client._call("channels.updateMemberPermissions", channel_id, user_id, body)
|
|
162
|
+
|
|
163
|
+
async def update_role_permissions(
|
|
164
|
+
self,
|
|
165
|
+
channel_id: str,
|
|
166
|
+
role_id: str,
|
|
167
|
+
body: dict[str, Any],
|
|
168
|
+
) -> Any:
|
|
169
|
+
return await self._client._call("channels.updateRolePermissions", channel_id, role_id, body)
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
class GroupsMethods(_ApiGroup):
|
|
173
|
+
async def get(self, openid: str) -> dict[str, Any]:
|
|
174
|
+
return await self._client._call("groups.get", openid)
|
|
175
|
+
|
|
176
|
+
async def bot_state(self, group_openid: str) -> Any:
|
|
177
|
+
return await self._client._call("groups.botState", group_openid)
|
|
178
|
+
|
|
179
|
+
async def upload_file(self, group_openid: str, body: dict[str, Any]) -> Any:
|
|
180
|
+
return await self._client._call("groups.uploadFile", group_openid, body)
|
|
181
|
+
|
|
182
|
+
async def members(self, group_openid: str) -> Any:
|
|
183
|
+
return await self._client._call("groups.members", group_openid)
|
|
184
|
+
|
|
185
|
+
async def members_page(self, group_openid: str, cursor: str | None = None) -> Any:
|
|
186
|
+
return await self._client._call("groups.membersPage", group_openid, cursor)
|
|
187
|
+
|
|
188
|
+
async def members_request(self, group_openid: str, body: dict[str, Any]) -> Any:
|
|
189
|
+
return await self._client._call("groups.membersRequest", group_openid, body)
|
|
190
|
+
|
|
191
|
+
async def join_request_list_request(self, group_openid: str, body: dict[str, Any]) -> Any:
|
|
192
|
+
return await self._client._call("groups.joinRequestListRequest", group_openid, body)
|
|
193
|
+
|
|
194
|
+
async def member_blacklist_request(self, group_openid: str, body: dict[str, Any]) -> Any:
|
|
195
|
+
return await self._client._call("groups.memberBlacklistRequest", group_openid, body)
|
|
196
|
+
|
|
197
|
+
async def list_join_approval_strategies_request(self, body: dict[str, Any]) -> Any:
|
|
198
|
+
return await self._client._call("groups.listJoinApprovalStrategiesRequest", body)
|
|
199
|
+
|
|
200
|
+
async def member(self, group_openid: str, member_openid: str) -> Any:
|
|
201
|
+
return await self._client._call("groups.member", group_openid, member_openid)
|
|
202
|
+
|
|
203
|
+
async def join_request_list(self, group_openid: str) -> Any:
|
|
204
|
+
return await self._client._call("groups.joinRequestList", group_openid)
|
|
205
|
+
|
|
206
|
+
async def restrict_chat_setting(self, group_openid: str) -> Any:
|
|
207
|
+
return await self._client._call("groups.restrictChatSetting", group_openid)
|
|
208
|
+
|
|
209
|
+
async def update_restrict_chat_setting(self, group_openid: str, body: dict[str, Any]) -> Any:
|
|
210
|
+
return await self._client._call("groups.updateRestrictChatSetting", group_openid, body)
|
|
211
|
+
|
|
212
|
+
async def join_request_list_page(
|
|
213
|
+
self,
|
|
214
|
+
group_openid: str,
|
|
215
|
+
cursor: str | None = None,
|
|
216
|
+
limit: int | None = None,
|
|
217
|
+
) -> Any:
|
|
218
|
+
return await self._client._call("groups.joinRequestListPage", group_openid, cursor, limit)
|
|
219
|
+
|
|
220
|
+
async def batch_remove_members(self, group_openid: str, body: dict[str, Any]) -> Any:
|
|
221
|
+
return await self._client._call("groups.batchRemoveMembers", group_openid, body)
|
|
222
|
+
|
|
223
|
+
async def approve_join_request(
|
|
224
|
+
self,
|
|
225
|
+
group_openid: str,
|
|
226
|
+
member_openid: str,
|
|
227
|
+
body: dict[str, Any],
|
|
228
|
+
) -> Any:
|
|
229
|
+
return await self._client._call("groups.approveJoinRequest", group_openid, member_openid, body)
|
|
230
|
+
|
|
231
|
+
async def member_blacklist(self, group_openid: str) -> Any:
|
|
232
|
+
return await self._client._call("groups.memberBlacklist", group_openid)
|
|
233
|
+
|
|
234
|
+
async def member_blacklist_page(
|
|
235
|
+
self,
|
|
236
|
+
group_openid: str,
|
|
237
|
+
cursor: str | None = None,
|
|
238
|
+
limit: int | None = None,
|
|
239
|
+
) -> Any:
|
|
240
|
+
return await self._client._call("groups.memberBlacklistPage", group_openid, cursor, limit)
|
|
241
|
+
|
|
242
|
+
async def update_member_blacklist(self, group_openid: str, body: dict[str, Any]) -> Any:
|
|
243
|
+
return await self._client._call("groups.updateMemberBlacklist", group_openid, body)
|
|
244
|
+
|
|
245
|
+
async def create_join_approval_strategy(self, body: dict[str, Any]) -> Any:
|
|
246
|
+
return await self._client._call("groups.createJoinApprovalStrategy", body)
|
|
247
|
+
|
|
248
|
+
async def list_join_approval_strategies(self) -> Any:
|
|
249
|
+
return await self._client._call("groups.listJoinApprovalStrategies")
|
|
250
|
+
|
|
251
|
+
async def list_join_approval_strategies_page(
|
|
252
|
+
self,
|
|
253
|
+
cursor: str | None = None,
|
|
254
|
+
limit: int | None = None,
|
|
255
|
+
) -> Any:
|
|
256
|
+
return await self._client._call("groups.listJoinApprovalStrategiesPage", cursor, limit)
|
|
257
|
+
|
|
258
|
+
async def update_join_approval_strategy(self, strategy_id: str, body: dict[str, Any]) -> Any:
|
|
259
|
+
return await self._client._call("groups.updateJoinApprovalStrategy", strategy_id, body)
|
|
260
|
+
|
|
261
|
+
async def delete_join_approval_strategy(self, strategy_id: str) -> None:
|
|
262
|
+
return await self._client._call("groups.deleteJoinApprovalStrategy", strategy_id)
|
|
263
|
+
|
|
264
|
+
async def execute_join_approval_strategy(self, strategy_id: str, body: dict[str, Any]) -> Any:
|
|
265
|
+
return await self._client._call("groups.executeJoinApprovalStrategy", strategy_id, body)
|
|
266
|
+
|
|
267
|
+
async def whitelist_join_approval_strategy(
|
|
268
|
+
self,
|
|
269
|
+
strategy_id: str,
|
|
270
|
+
body: dict[str, Any],
|
|
271
|
+
) -> Any:
|
|
272
|
+
return await self._client._call("groups.whitelistJoinApprovalStrategy", strategy_id, body)
|
|
273
|
+
|
|
274
|
+
async def upload_prepare(self, group_id: str, body: dict[str, Any]) -> Any:
|
|
275
|
+
return await self._client._call("groups.uploadPrepare", group_id, body)
|
|
276
|
+
|
|
277
|
+
async def upload_part_finish(self, group_id: str, body: dict[str, Any]) -> Any:
|
|
278
|
+
return await self._client._call("groups.uploadPartFinish", group_id, body)
|
|
279
|
+
|
|
280
|
+
|
|
281
|
+
class GuildsMethods(_ApiGroup):
|
|
282
|
+
async def get(self, guild_id: str) -> dict[str, Any]:
|
|
283
|
+
return await self._client._call("guilds.get", guild_id)
|
|
284
|
+
|
|
285
|
+
async def channels(self, guild_id: str) -> list[dict[str, Any]]:
|
|
286
|
+
return await self._client._call("guilds.channels", guild_id)
|
|
287
|
+
|
|
288
|
+
async def create_channel(self, guild_id: str, body: dict[str, Any]) -> dict[str, Any]:
|
|
289
|
+
return await self._client._call("guilds.createChannel", guild_id, body)
|
|
290
|
+
|
|
291
|
+
async def create_announcement(self, guild_id: str, body: dict[str, Any]) -> Any:
|
|
292
|
+
return await self._client._call("guilds.createAnnouncement", guild_id, body)
|
|
293
|
+
|
|
294
|
+
async def delete_announcement(self, guild_id: str, message_id: str) -> None:
|
|
295
|
+
return await self._client._call("guilds.deleteAnnouncement", guild_id, message_id)
|
|
296
|
+
|
|
297
|
+
async def api_permissions(self, guild_id: str) -> Any:
|
|
298
|
+
return await self._client._call("guilds.apiPermissions", guild_id)
|
|
299
|
+
|
|
300
|
+
async def request_api_permission(self, guild_id: str, body: dict[str, Any]) -> Any:
|
|
301
|
+
return await self._client._call("guilds.requestApiPermission", guild_id, body)
|
|
302
|
+
|
|
303
|
+
async def roles(self, guild_id: str) -> Any:
|
|
304
|
+
return await self._client._call("guilds.roles", guild_id)
|
|
305
|
+
|
|
306
|
+
async def create_role(self, guild_id: str, body: dict[str, Any]) -> Any:
|
|
307
|
+
return await self._client._call("guilds.createRole", guild_id, body)
|
|
308
|
+
|
|
309
|
+
async def update_role(self, guild_id: str, role_id: str, body: dict[str, Any]) -> Any:
|
|
310
|
+
return await self._client._call("guilds.updateRole", guild_id, role_id, body)
|
|
311
|
+
|
|
312
|
+
async def delete_role(self, guild_id: str, role_id: str) -> None:
|
|
313
|
+
return await self._client._call("guilds.deleteRole", guild_id, role_id)
|
|
314
|
+
|
|
315
|
+
async def add_member_role(
|
|
316
|
+
self,
|
|
317
|
+
guild_id: str,
|
|
318
|
+
user_id: str,
|
|
319
|
+
role_id: str,
|
|
320
|
+
body: dict[str, Any],
|
|
321
|
+
) -> Any:
|
|
322
|
+
return await self._client._call("guilds.addMemberRole", guild_id, user_id, role_id, body)
|
|
323
|
+
|
|
324
|
+
async def remove_member_role(self, guild_id: str, user_id: str, role_id: str) -> None:
|
|
325
|
+
return await self._client._call("guilds.removeMemberRole", guild_id, user_id, role_id)
|
|
326
|
+
|
|
327
|
+
async def remove_member_role_with_body(
|
|
328
|
+
self,
|
|
329
|
+
guild_id: str,
|
|
330
|
+
user_id: str,
|
|
331
|
+
role_id: str,
|
|
332
|
+
body: dict[str, Any],
|
|
333
|
+
) -> None:
|
|
334
|
+
return await self._client._call("guilds.removeMemberRoleWithBody", guild_id, user_id, role_id, body)
|
|
335
|
+
|
|
336
|
+
async def members(self, guild_id: str) -> Any:
|
|
337
|
+
return await self._client._call("guilds.members", guild_id)
|
|
338
|
+
|
|
339
|
+
async def members_page(
|
|
340
|
+
self,
|
|
341
|
+
guild_id: str,
|
|
342
|
+
after: str | None = None,
|
|
343
|
+
limit: int | None = None,
|
|
344
|
+
) -> Any:
|
|
345
|
+
return await self._client._call("guilds.membersPage", guild_id, after, limit)
|
|
346
|
+
|
|
347
|
+
async def member(self, guild_id: str, user_id: str) -> Any:
|
|
348
|
+
return await self._client._call("guilds.member", guild_id, user_id)
|
|
349
|
+
|
|
350
|
+
async def remove_member(self, guild_id: str, user_id: str) -> None:
|
|
351
|
+
return await self._client._call("guilds.removeMember", guild_id, user_id)
|
|
352
|
+
|
|
353
|
+
async def remove_member_with_options(
|
|
354
|
+
self,
|
|
355
|
+
guild_id: str,
|
|
356
|
+
user_id: str,
|
|
357
|
+
body: dict[str, Any],
|
|
358
|
+
) -> None:
|
|
359
|
+
return await self._client._call("guilds.removeMemberWithOptions", guild_id, user_id, body)
|
|
360
|
+
|
|
361
|
+
async def role_members(self, guild_id: str, role_id: str) -> Any:
|
|
362
|
+
return await self._client._call("guilds.roleMembers", guild_id, role_id)
|
|
363
|
+
|
|
364
|
+
async def role_members_page(
|
|
365
|
+
self,
|
|
366
|
+
guild_id: str,
|
|
367
|
+
role_id: str,
|
|
368
|
+
start_index: int | None = None,
|
|
369
|
+
limit: int | None = None,
|
|
370
|
+
) -> Any:
|
|
371
|
+
return await self._client._call("guilds.roleMembersPage", guild_id, role_id, start_index, limit)
|
|
372
|
+
|
|
373
|
+
async def mute_member(self, guild_id: str, user_id: str, body: dict[str, Any]) -> Any:
|
|
374
|
+
return await self._client._call("guilds.muteMember", guild_id, user_id, body)
|
|
375
|
+
|
|
376
|
+
async def mute_guild(self, guild_id: str, body: dict[str, Any]) -> Any:
|
|
377
|
+
return await self._client._call("guilds.muteGuild", guild_id, body)
|
|
378
|
+
|
|
379
|
+
async def mute_members(self, guild_id: str, body: dict[str, Any]) -> Any:
|
|
380
|
+
return await self._client._call("guilds.muteMembers", guild_id, body)
|
|
381
|
+
|
|
382
|
+
|
|
383
|
+
class InteractionsMethods(_ApiGroup):
|
|
384
|
+
async def respond(self, interaction_id: str, body: dict[str, Any]) -> Any:
|
|
385
|
+
return await self._client._call("interactions.respond", interaction_id, body)
|
|
386
|
+
|
|
387
|
+
|
|
388
|
+
class MaterialsMethods(_ApiGroup):
|
|
389
|
+
async def prepare(self, request: dict[str, Any]) -> dict[str, Any]:
|
|
390
|
+
return await self._client._call("materials.prepare", request)
|
|
391
|
+
|
|
392
|
+
async def complete(self, request: dict[str, Any]) -> dict[str, Any]:
|
|
393
|
+
return await self._client._call("materials.complete", request)
|
|
394
|
+
|
|
395
|
+
async def list(self, cursor: str | None = None) -> dict[str, Any]:
|
|
396
|
+
return await self._client._call("materials.list", cursor)
|
|
397
|
+
|
|
398
|
+
async def delete(self, image_id: str) -> None:
|
|
399
|
+
return await self._client._call("materials.delete", image_id)
|
|
400
|
+
|
|
401
|
+
async def upload(self, file_name: str, content_type: str, source: bytes) -> dict[str, Any]:
|
|
402
|
+
return await self._client._upload_material(file_name, content_type, source)
|
|
403
|
+
|
|
404
|
+
|
|
405
|
+
class MenuMethods(_ApiGroup):
|
|
406
|
+
async def get(self) -> Any:
|
|
407
|
+
return await self._client._call("menu.get")
|
|
408
|
+
|
|
409
|
+
async def put(self, body: dict[str, Any]) -> Any:
|
|
410
|
+
return await self._client._call("menu.put", body)
|
|
411
|
+
|
|
412
|
+
|
|
413
|
+
class MessagesMethods(_ApiGroup):
|
|
414
|
+
async def upload_media_with(self, target: MediaTarget, body: dict[str, Any]) -> dict[str, Any]:
|
|
415
|
+
return await self._client._call("messages.uploadMediaWith", target, body)
|
|
416
|
+
|
|
417
|
+
async def upload_media(
|
|
418
|
+
self,
|
|
419
|
+
target: MediaTarget,
|
|
420
|
+
file_type: int,
|
|
421
|
+
source: bytes | str,
|
|
422
|
+
srv_send_msg: bool,
|
|
423
|
+
) -> dict[str, Any]:
|
|
424
|
+
return await self._upload_media(target, file_type, source, srv_send_msg)
|
|
425
|
+
|
|
426
|
+
async def upload_media_url(
|
|
427
|
+
self,
|
|
428
|
+
target: MediaTarget,
|
|
429
|
+
file_type: int,
|
|
430
|
+
url: str,
|
|
431
|
+
srv_send_msg: bool,
|
|
432
|
+
) -> dict[str, Any]:
|
|
433
|
+
return await self._client._call("messages.uploadMediaUrl", target, file_type, url, srv_send_msg)
|
|
434
|
+
|
|
435
|
+
async def upload_media_request(
|
|
436
|
+
self,
|
|
437
|
+
target: MediaTarget,
|
|
438
|
+
body: dict[str, Any],
|
|
439
|
+
) -> dict[str, Any]:
|
|
440
|
+
return await self._client._call("messages.uploadMediaRequest", target, body)
|
|
441
|
+
|
|
442
|
+
async def send_media(
|
|
443
|
+
self,
|
|
444
|
+
target: MediaTarget,
|
|
445
|
+
file_type: int,
|
|
446
|
+
source: bytes | str,
|
|
447
|
+
message: Message,
|
|
448
|
+
) -> dict[str, Any]:
|
|
449
|
+
return await self._send_media(target, file_type, source, message)
|
|
450
|
+
|
|
451
|
+
async def send_media_url(
|
|
452
|
+
self,
|
|
453
|
+
target: MediaTarget,
|
|
454
|
+
file_type: int,
|
|
455
|
+
url: str,
|
|
456
|
+
message: Message,
|
|
457
|
+
) -> dict[str, Any]:
|
|
458
|
+
return await self._client._call("messages.sendMediaUrl", target, file_type, url, message)
|
|
459
|
+
|
|
460
|
+
async def send_c2c(self, user_openid: str, message: Message) -> dict[str, Any]:
|
|
461
|
+
return await self._client._call("messages.sendC2c", user_openid, message)
|
|
462
|
+
|
|
463
|
+
async def reply_c2c(
|
|
464
|
+
self,
|
|
465
|
+
user_openid: str,
|
|
466
|
+
message: Message,
|
|
467
|
+
msg_id: str | None = None,
|
|
468
|
+
event_id: str | None = None,
|
|
469
|
+
) -> dict[str, Any]:
|
|
470
|
+
return await self._client._call("messages.replyC2c", user_openid, message, msg_id, event_id)
|
|
471
|
+
|
|
472
|
+
async def send_group(self, group_openid: str, message: Message) -> dict[str, Any]:
|
|
473
|
+
return await self._client._call("messages.sendGroup", group_openid, message)
|
|
474
|
+
|
|
475
|
+
async def reply_group(
|
|
476
|
+
self,
|
|
477
|
+
group_openid: str,
|
|
478
|
+
message: Message,
|
|
479
|
+
msg_id: str | None = None,
|
|
480
|
+
event_id: str | None = None,
|
|
481
|
+
) -> dict[str, Any]:
|
|
482
|
+
return await self._client._call("messages.replyGroup", group_openid, message, msg_id, event_id)
|
|
483
|
+
|
|
484
|
+
async def send_channel(self, channel_id: str, message: Message) -> dict[str, Any]:
|
|
485
|
+
return await self._client._call("messages.sendChannel", channel_id, message)
|
|
486
|
+
|
|
487
|
+
async def reply_channel(
|
|
488
|
+
self,
|
|
489
|
+
channel_id: str,
|
|
490
|
+
message: Message,
|
|
491
|
+
msg_id: str | None = None,
|
|
492
|
+
event_id: str | None = None,
|
|
493
|
+
) -> dict[str, Any]:
|
|
494
|
+
return await self._client._call("messages.replyChannel", channel_id, message, msg_id, event_id)
|
|
495
|
+
|
|
496
|
+
async def send_dm(self, guild_id: str, message: Message) -> dict[str, Any]:
|
|
497
|
+
return await self._client._call("messages.sendDm", guild_id, message)
|
|
498
|
+
|
|
499
|
+
async def reply_dm(
|
|
500
|
+
self,
|
|
501
|
+
guild_id: str,
|
|
502
|
+
message: Message,
|
|
503
|
+
msg_id: str | None = None,
|
|
504
|
+
event_id: str | None = None,
|
|
505
|
+
) -> dict[str, Any]:
|
|
506
|
+
return await self._client._call("messages.replyDm", guild_id, message, msg_id, event_id)
|
|
507
|
+
|
|
508
|
+
async def delete_channel(self, channel_id: str, message_id: str) -> None:
|
|
509
|
+
return await self._client._call("messages.deleteChannel", channel_id, message_id)
|
|
510
|
+
|
|
511
|
+
async def delete_c2c(self, user_openid: str, message_id: str) -> None:
|
|
512
|
+
return await self._client._call("messages.deleteC2c", user_openid, message_id)
|
|
513
|
+
|
|
514
|
+
async def delete_group(self, group_openid: str, message_id: str) -> None:
|
|
515
|
+
return await self._client._call("messages.deleteGroup", group_openid, message_id)
|
|
516
|
+
|
|
517
|
+
async def delete_dm(self, guild_id: str, message_id: str, hide_tip: bool) -> None:
|
|
518
|
+
return await self._client._call("messages.deleteDm", guild_id, message_id, hide_tip)
|
|
519
|
+
|
|
520
|
+
async def _upload_media(
|
|
521
|
+
self, target: MediaTarget, file_type: int, source: bytes | str, srv_send_msg: bool
|
|
522
|
+
) -> dict[str, Any]:
|
|
523
|
+
if isinstance(source, str):
|
|
524
|
+
return await self.upload_media_url(target, file_type, source, srv_send_msg)
|
|
525
|
+
return await self._client._upload_media(
|
|
526
|
+
target["kind"], target["id"], file_type, source, srv_send_msg
|
|
527
|
+
)
|
|
528
|
+
|
|
529
|
+
async def _send_media(
|
|
530
|
+
self, target: MediaTarget, file_type: int, source: bytes | str, message: Message
|
|
531
|
+
) -> dict[str, Any]:
|
|
532
|
+
if isinstance(source, str):
|
|
533
|
+
return await self.send_media_url(target, file_type, source, message)
|
|
534
|
+
return await self._client._send_media(
|
|
535
|
+
target["kind"], target["id"], file_type, source, message
|
|
536
|
+
)
|
|
537
|
+
|
|
538
|
+
|
|
539
|
+
class PanelsMethods(_ApiGroup):
|
|
540
|
+
async def list_with_options(
|
|
541
|
+
self,
|
|
542
|
+
scope: str,
|
|
543
|
+
cursor: str | None = None,
|
|
544
|
+
limit: int | None = None,
|
|
545
|
+
) -> Any:
|
|
546
|
+
return await self._client._call("panels.listWithOptions", scope, cursor, limit)
|
|
547
|
+
|
|
548
|
+
async def list(self, scope: str) -> Any:
|
|
549
|
+
return await self._client._call("panels.list", scope)
|
|
550
|
+
|
|
551
|
+
async def create(self, body: dict[str, Any]) -> Any:
|
|
552
|
+
return await self._client._call("panels.create", body)
|
|
553
|
+
|
|
554
|
+
async def get(self, panel_id: str) -> Any:
|
|
555
|
+
return await self._client._call("panels.get", panel_id)
|
|
556
|
+
|
|
557
|
+
async def update(self, panel_id: str, body: dict[str, Any]) -> Any:
|
|
558
|
+
return await self._client._call("panels.update", panel_id, body)
|
|
559
|
+
|
|
560
|
+
async def delete(self, panel_id: str) -> None:
|
|
561
|
+
return await self._client._call("panels.delete", panel_id)
|
|
562
|
+
|
|
563
|
+
async def update_target(self, panel_id: str, body: dict[str, Any]) -> Any:
|
|
564
|
+
return await self._client._call("panels.updateTarget", panel_id, body)
|
|
565
|
+
|
|
566
|
+
|
|
567
|
+
class UsersMethods(_ApiGroup):
|
|
568
|
+
async def get(self, user_openid: str) -> dict[str, Any]:
|
|
569
|
+
return await self._client._call("users.get", user_openid)
|
|
570
|
+
|
|
571
|
+
async def send_stream(self, user_openid: str, body: dict[str, Any]) -> dict[str, Any]:
|
|
572
|
+
return await self._client._call("users.sendStream", user_openid, body)
|
|
573
|
+
|
|
574
|
+
async def me(self) -> dict[str, Any]:
|
|
575
|
+
return await self._client._call("users.me")
|
|
576
|
+
|
|
577
|
+
async def guilds(
|
|
578
|
+
self,
|
|
579
|
+
before: str | None = None,
|
|
580
|
+
after: str | None = None,
|
|
581
|
+
limit: int | None = None,
|
|
582
|
+
) -> list[dict[str, Any]]:
|
|
583
|
+
return await self._client._call("users.guilds", before, after, limit)
|
|
584
|
+
|
|
585
|
+
async def upload_file(self, user_openid: str, body: dict[str, Any]) -> Any:
|
|
586
|
+
return await self._client._call("users.uploadFile", user_openid, body)
|
|
587
|
+
|
|
588
|
+
async def upload_prepare(self, user_id: str, body: dict[str, Any]) -> Any:
|
|
589
|
+
return await self._client._call("users.uploadPrepare", user_id, body)
|
|
590
|
+
|
|
591
|
+
async def upload_part_finish(self, user_id: str, body: dict[str, Any]) -> Any:
|
|
592
|
+
return await self._client._call("users.uploadPartFinish", user_id, body)
|
|
593
|
+
|
|
594
|
+
async def send_stream_message(self, user_openid: str, body: dict[str, Any]) -> Any:
|
|
595
|
+
return await self._client._call("users.sendStreamMessage", user_openid, body)
|
|
596
|
+
|
|
597
|
+
|
|
598
|
+
class UtilityMethods(_ApiGroup):
|
|
599
|
+
async def generate_url_link(self, body: dict[str, Any]) -> Any:
|
|
600
|
+
return await self._client._call("utility.generateUrlLink", body)
|
|
601
|
+
|
|
602
|
+
|
|
603
|
+
class BotApi:
|
|
604
|
+
bot: BotMethods
|
|
605
|
+
channels: ChannelsMethods
|
|
606
|
+
groups: GroupsMethods
|
|
607
|
+
guilds: GuildsMethods
|
|
608
|
+
interactions: InteractionsMethods
|
|
609
|
+
materials: MaterialsMethods
|
|
610
|
+
menu: MenuMethods
|
|
611
|
+
messages: MessagesMethods
|
|
612
|
+
panels: PanelsMethods
|
|
613
|
+
users: UsersMethods
|
|
614
|
+
utility: UtilityMethods
|
|
615
|
+
|
|
616
|
+
def __init__(self, client: _NativeBot) -> None:
|
|
617
|
+
self.bot = BotMethods(client)
|
|
618
|
+
self.channels = ChannelsMethods(client)
|
|
619
|
+
self.groups = GroupsMethods(client)
|
|
620
|
+
self.guilds = GuildsMethods(client)
|
|
621
|
+
self.interactions = InteractionsMethods(client)
|
|
622
|
+
self.materials = MaterialsMethods(client)
|
|
623
|
+
self.menu = MenuMethods(client)
|
|
624
|
+
self.messages = MessagesMethods(client)
|
|
625
|
+
self.panels = PanelsMethods(client)
|
|
626
|
+
self.users = UsersMethods(client)
|
|
627
|
+
self.utility = UtilityMethods(client)
|