satori-python-adapter-qq 0.3.2__tar.gz → 0.3.3__tar.gz
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.
- {satori_python_adapter_qq-0.3.2 → satori_python_adapter_qq-0.3.3}/.mina/adapter_qq.toml +1 -1
- {satori_python_adapter_qq-0.3.2 → satori_python_adapter_qq-0.3.3}/PKG-INFO +1 -1
- {satori_python_adapter_qq-0.3.2 → satori_python_adapter_qq-0.3.3}/pyproject.toml +1 -1
- {satori_python_adapter_qq-0.3.2 → satori_python_adapter_qq-0.3.3}/src/satori/adapters/qq/api.py +26 -5
- {satori_python_adapter_qq-0.3.2 → satori_python_adapter_qq-0.3.3}/src/satori/adapters/qq/events/group.py +7 -3
- {satori_python_adapter_qq-0.3.2 → satori_python_adapter_qq-0.3.3}/src/satori/adapters/qq/message.py +12 -1
- {satori_python_adapter_qq-0.3.2 → satori_python_adapter_qq-0.3.3}/src/satori/adapters/qq/utils.py +3 -0
- {satori_python_adapter_qq-0.3.2 → satori_python_adapter_qq-0.3.3}/LICENSE +0 -0
- {satori_python_adapter_qq-0.3.2 → satori_python_adapter_qq-0.3.3}/README.md +0 -0
- {satori_python_adapter_qq-0.3.2 → satori_python_adapter_qq-0.3.3}/src/satori/adapters/qq/__init__.py +0 -0
- {satori_python_adapter_qq-0.3.2 → satori_python_adapter_qq-0.3.3}/src/satori/adapters/qq/audit_store.py +0 -0
- {satori_python_adapter_qq-0.3.2 → satori_python_adapter_qq-0.3.3}/src/satori/adapters/qq/events/__init__.py +0 -0
- {satori_python_adapter_qq-0.3.2 → satori_python_adapter_qq-0.3.3}/src/satori/adapters/qq/events/base.py +0 -0
- {satori_python_adapter_qq-0.3.2 → satori_python_adapter_qq-0.3.3}/src/satori/adapters/qq/events/guild.py +0 -0
- {satori_python_adapter_qq-0.3.2 → satori_python_adapter_qq-0.3.3}/src/satori/adapters/qq/events/interaction.py +0 -0
- {satori_python_adapter_qq-0.3.2 → satori_python_adapter_qq-0.3.3}/src/satori/adapters/qq/events/message.py +0 -0
- {satori_python_adapter_qq-0.3.2 → satori_python_adapter_qq-0.3.3}/src/satori/adapters/qq/exception.py +0 -0
- {satori_python_adapter_qq-0.3.2 → satori_python_adapter_qq-0.3.3}/src/satori/adapters/qq/main.py +0 -0
- {satori_python_adapter_qq-0.3.2 → satori_python_adapter_qq-0.3.3}/src/satori/adapters/qq/websocket.py +0 -0
{satori_python_adapter_qq-0.3.2 → satori_python_adapter_qq-0.3.3}/src/satori/adapters/qq/api.py
RENAMED
|
@@ -29,7 +29,7 @@ from satori.server.route import (
|
|
|
29
29
|
)
|
|
30
30
|
|
|
31
31
|
from .message import QQGroupMessageEncoder, QQGuildMessageEncoder, decode_segments
|
|
32
|
-
from .utils import ROLE_MAPPING, QQBotNetwork, decode_channel, decode_guild, decode_member, decode_user
|
|
32
|
+
from .utils import ROLE_MAPPING, USER_AVATAR_URL, QQBotNetwork, decode_channel, decode_guild, decode_member, decode_user
|
|
33
33
|
|
|
34
34
|
|
|
35
35
|
def apply(
|
|
@@ -141,7 +141,14 @@ def apply(
|
|
|
141
141
|
)
|
|
142
142
|
return decode_user(res)
|
|
143
143
|
raise NotFoundException("qqguild platform does not support user.get without guild_id")
|
|
144
|
-
raise NotFoundException("qq platform does not support user.get")
|
|
144
|
+
# raise NotFoundException("qq platform does not support user.get")
|
|
145
|
+
app_id = net.bot_id_mapping[login_getter(request.self_id, request.platform == "qqguild").id]
|
|
146
|
+
return decode_user(
|
|
147
|
+
{
|
|
148
|
+
"id": request.params["user_id"],
|
|
149
|
+
"avatar": USER_AVATAR_URL.format(app_id=app_id, user_id=request.params["user_id"]),
|
|
150
|
+
}
|
|
151
|
+
)
|
|
145
152
|
|
|
146
153
|
@adapter.route(Api.GUILD_GET)
|
|
147
154
|
async def guild_get(request: Request[GuildGetParam]):
|
|
@@ -152,7 +159,8 @@ def apply(
|
|
|
152
159
|
f"guilds/{request.params['guild_id']}",
|
|
153
160
|
)
|
|
154
161
|
return decode_guild(res)
|
|
155
|
-
raise NotFoundException("qq platform does not support guild.get")
|
|
162
|
+
# raise NotFoundException("qq platform does not support guild.get")
|
|
163
|
+
return Guild(request.params["guild_id"]) # type: ignore
|
|
156
164
|
|
|
157
165
|
@adapter.route(Api.GUILD_LIST)
|
|
158
166
|
async def guild_list(request: Request[GuildListParam]):
|
|
@@ -177,7 +185,9 @@ def apply(
|
|
|
177
185
|
f"channels/{channel_id}",
|
|
178
186
|
)
|
|
179
187
|
return decode_channel(res)
|
|
180
|
-
raise NotFoundException("qq platform does not support channel.get")
|
|
188
|
+
# raise NotFoundException("qq platform does not support channel.get")
|
|
189
|
+
is_private = request.params["channel_id"].startswith("private:")
|
|
190
|
+
return Channel(request.params["channel_id"], ChannelType.DIRECT if is_private else ChannelType.TEXT) # type: ignore
|
|
181
191
|
|
|
182
192
|
@adapter.route(Api.CHANNEL_LIST)
|
|
183
193
|
async def channel_list(request: Request[ChannelListParam]):
|
|
@@ -253,7 +263,18 @@ def apply(
|
|
|
253
263
|
f"guilds/{guild_id}/members/{request.params['user_id']}",
|
|
254
264
|
)
|
|
255
265
|
return decode_member(res)
|
|
256
|
-
raise NotFoundException("qq platform does not support guild.member.get")
|
|
266
|
+
# raise NotFoundException("qq platform does not support guild.member.get")
|
|
267
|
+
app_id = net.bot_id_mapping[login_getter(request.self_id, request.platform == "qqguild").id]
|
|
268
|
+
return Member(
|
|
269
|
+
decode_user(
|
|
270
|
+
{
|
|
271
|
+
"id": request.params["user_id"],
|
|
272
|
+
"avatar": USER_AVATAR_URL.format(app_id=app_id, user_id=request.params["user_id"]),
|
|
273
|
+
}
|
|
274
|
+
),
|
|
275
|
+
joined_at=None,
|
|
276
|
+
roles=[ROLE_MAPPING["1"]],
|
|
277
|
+
)
|
|
257
278
|
|
|
258
279
|
@adapter.route(Api.GUILD_MEMBER_LIST)
|
|
259
280
|
async def guild_list_member(request: Request[GuildXXXListParam]):
|
|
@@ -5,7 +5,7 @@ from datetime import datetime
|
|
|
5
5
|
from satori import EventType
|
|
6
6
|
from satori.model import Channel, ChannelType, Event, Guild, User
|
|
7
7
|
|
|
8
|
-
from ..utils import Payload
|
|
8
|
+
from ..utils import USER_AVATAR_URL, Payload
|
|
9
9
|
from .base import register_event
|
|
10
10
|
|
|
11
11
|
|
|
@@ -17,7 +17,8 @@ async def friend_event(login, guild_login, net, payload: Payload):
|
|
|
17
17
|
"FRIEND_ADD": EventType.FRIEND_ADDED,
|
|
18
18
|
"FRIEND_DEL": EventType.FRIEND_REMOVED,
|
|
19
19
|
}[payload.type or ""]
|
|
20
|
-
|
|
20
|
+
app_id = net.bot_id_mapping[login.id]
|
|
21
|
+
user = User(raw["openid"], avatar=USER_AVATAR_URL.format(app_id=app_id, user_id=raw["openid"]))
|
|
21
22
|
return Event(
|
|
22
23
|
t,
|
|
23
24
|
(
|
|
@@ -40,7 +41,10 @@ async def group_event(login, guild_login, net, payload: Payload):
|
|
|
40
41
|
guild = Guild(raw["group_openid"])
|
|
41
42
|
else:
|
|
42
43
|
guild = Guild(raw["guild_id"])
|
|
43
|
-
|
|
44
|
+
app_id = net.bot_id_mapping[login.id]
|
|
45
|
+
operator = User(
|
|
46
|
+
raw["op_member_openid"], avatar=USER_AVATAR_URL.format(app_id=app_id, user_id=raw["op_member_openid"])
|
|
47
|
+
)
|
|
44
48
|
t = {
|
|
45
49
|
"GROUP_ADD_ROBOT": EventType.GUILD_ADDED,
|
|
46
50
|
"GROUP_DEL_ROBOT": EventType.GUILD_REMOVED,
|
{satori_python_adapter_qq-0.3.2 → satori_python_adapter_qq-0.3.3}/src/satori/adapters/qq/message.py
RENAMED
|
@@ -21,6 +21,17 @@ from .utils import QQBotNetwork, parse_file_uri
|
|
|
21
21
|
|
|
22
22
|
_BASE64_RE = re.compile(r"^data:([\w/.+-]+);base64,")
|
|
23
23
|
MAX_FILESIZE_ONCE = 10 * 1024 * 1024 # 10MB
|
|
24
|
+
BUTTON_STYLES = {
|
|
25
|
+
"grey": 0,
|
|
26
|
+
"secondary": 0,
|
|
27
|
+
"blue": 1,
|
|
28
|
+
"primary": 1,
|
|
29
|
+
"success": 1,
|
|
30
|
+
"info": 2,
|
|
31
|
+
"warning": 3,
|
|
32
|
+
"danger": 3,
|
|
33
|
+
"link": 4,
|
|
34
|
+
}
|
|
24
35
|
|
|
25
36
|
|
|
26
37
|
def escape(s: str) -> str:
|
|
@@ -530,7 +541,7 @@ class QQGroupMessageEncoder(QQBotMessageEncoder):
|
|
|
530
541
|
"render_data": {
|
|
531
542
|
"label": label,
|
|
532
543
|
"visited_label": label,
|
|
533
|
-
"style":
|
|
544
|
+
"style": BUTTON_STYLES.get(attrs.get("class", "grey"), 1),
|
|
534
545
|
},
|
|
535
546
|
"action": {
|
|
536
547
|
"type": {"input": 2, "link": 0}.get(attrs.get("type", "action"), 1),
|
{satori_python_adapter_qq-0.3.2 → satori_python_adapter_qq-0.3.3}/src/satori/adapters/qq/utils.py
RENAMED
|
@@ -18,6 +18,9 @@ CallMethod = Literal["get", "post", "fetch", "update", "multipart", "put", "dele
|
|
|
18
18
|
class QQBotNetwork(Protocol):
|
|
19
19
|
session: ClientSession
|
|
20
20
|
|
|
21
|
+
@property
|
|
22
|
+
def bot_id_mapping(self) -> dict[str, str]: ...
|
|
23
|
+
|
|
21
24
|
async def call_api(self, method: CallMethod, action: str, params: dict | None = None) -> dict: ...
|
|
22
25
|
|
|
23
26
|
|
|
File without changes
|
|
File without changes
|
{satori_python_adapter_qq-0.3.2 → satori_python_adapter_qq-0.3.3}/src/satori/adapters/qq/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{satori_python_adapter_qq-0.3.2 → satori_python_adapter_qq-0.3.3}/src/satori/adapters/qq/main.py
RENAMED
|
File without changes
|
|
File without changes
|