satori-python-adapter-onebot11 0.2.2__tar.gz → 0.2.4__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_onebot11-0.2.2 → satori_python_adapter_onebot11-0.2.4}/.mina/adapter_onebot11.toml +1 -1
- {satori_python_adapter_onebot11-0.2.2 → satori_python_adapter_onebot11-0.2.4}/PKG-INFO +1 -1
- {satori_python_adapter_onebot11-0.2.2 → satori_python_adapter_onebot11-0.2.4}/pyproject.toml +2 -1
- {satori_python_adapter_onebot11-0.2.2 → satori_python_adapter_onebot11-0.2.4}/src/satori/adapters/onebot11/api.py +4 -31
- satori_python_adapter_onebot11-0.2.4/src/satori/adapters/onebot11/events/__init__.py +3 -0
- {satori_python_adapter_onebot11-0.2.2 → satori_python_adapter_onebot11-0.2.4}/src/satori/adapters/onebot11/forward.py +2 -2
- {satori_python_adapter_onebot11-0.2.2 → satori_python_adapter_onebot11-0.2.4}/src/satori/adapters/onebot11/message.py +15 -4
- {satori_python_adapter_onebot11-0.2.2 → satori_python_adapter_onebot11-0.2.4}/src/satori/adapters/onebot11/reverse.py +2 -2
- {satori_python_adapter_onebot11-0.2.2 → satori_python_adapter_onebot11-0.2.4}/src/satori/adapters/onebot11/utils.py +1 -1
- satori_python_adapter_onebot11-0.2.2/src/satori/adapters/onebot11/events/__init__.py +0 -4
- {satori_python_adapter_onebot11-0.2.2 → satori_python_adapter_onebot11-0.2.4}/LICENSE +0 -0
- {satori_python_adapter_onebot11-0.2.2 → satori_python_adapter_onebot11-0.2.4}/README.md +0 -0
- {satori_python_adapter_onebot11-0.2.2 → satori_python_adapter_onebot11-0.2.4}/src/satori/adapters/onebot11/__init__.py +0 -0
- {satori_python_adapter_onebot11-0.2.2 → satori_python_adapter_onebot11-0.2.4}/src/satori/adapters/onebot11/events/base.py +0 -0
- {satori_python_adapter_onebot11-0.2.2 → satori_python_adapter_onebot11-0.2.4}/src/satori/adapters/onebot11/events/message.py +0 -0
- {satori_python_adapter_onebot11-0.2.2 → satori_python_adapter_onebot11-0.2.4}/src/satori/adapters/onebot11/events/notice.py +0 -0
- {satori_python_adapter_onebot11-0.2.2 → satori_python_adapter_onebot11-0.2.4}/src/satori/adapters/onebot11/events/request.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: satori-python-adapter-onebot11
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.4
|
|
4
4
|
Summary: Satori Protocol SDK for python, adapter for OneBot 11
|
|
5
5
|
Home-page: https://github.com/RF-Tar-Railt/satori-python
|
|
6
6
|
Author-Email: RF-Tar-Railt <rf_tar_railt@qq.com>
|
{satori_python_adapter_onebot11-0.2.2 → satori_python_adapter_onebot11-0.2.4}/pyproject.toml
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "satori-python-adapter-onebot11"
|
|
3
|
-
version = "0.2.
|
|
3
|
+
version = "0.2.4"
|
|
4
4
|
authors = [
|
|
5
5
|
{ name = "RF-Tar-Railt", email = "rf_tar_railt@qq.com" },
|
|
6
6
|
]
|
|
@@ -89,6 +89,7 @@ exclude = [
|
|
|
89
89
|
"exam_qps.py",
|
|
90
90
|
"exam1.py",
|
|
91
91
|
"exam2.py",
|
|
92
|
+
"src/satori/_vendor/*",
|
|
92
93
|
]
|
|
93
94
|
|
|
94
95
|
[tool.ruff.lint]
|
|
@@ -27,31 +27,6 @@ from satori.server.route import (
|
|
|
27
27
|
from .message import OneBot11MessageEncoder, decode
|
|
28
28
|
from .utils import GROUP_AVATAR_URL, USER_AVATAR_URL, OneBotNetwork
|
|
29
29
|
|
|
30
|
-
INTERNAL_API = [
|
|
31
|
-
"get_forward_msg",
|
|
32
|
-
"send_like",
|
|
33
|
-
"set_group_card",
|
|
34
|
-
"set_group_leave",
|
|
35
|
-
"set_group_special_title",
|
|
36
|
-
"get_login_info",
|
|
37
|
-
"get_group_honor_info",
|
|
38
|
-
"get_cookies",
|
|
39
|
-
"get_csrf_token",
|
|
40
|
-
"get_credentials",
|
|
41
|
-
"get_record",
|
|
42
|
-
"get_image",
|
|
43
|
-
"can_send_image",
|
|
44
|
-
"can_send_record",
|
|
45
|
-
"get_status",
|
|
46
|
-
"get_version_info",
|
|
47
|
-
"set_restart",
|
|
48
|
-
"clean_cache",
|
|
49
|
-
# additional
|
|
50
|
-
"group_poke",
|
|
51
|
-
"friend_poke",
|
|
52
|
-
"set_group_reaction",
|
|
53
|
-
]
|
|
54
|
-
|
|
55
30
|
|
|
56
31
|
def apply(adapter: Adapter, net_getter: Callable[[str], OneBotNetwork], login_getter: Callable[[str], Login]):
|
|
57
32
|
@adapter.route(Api.LOGIN_GET)
|
|
@@ -335,9 +310,7 @@ def apply(adapter: Adapter, net_getter: Callable[[str], OneBotNetwork], login_ge
|
|
|
335
310
|
)
|
|
336
311
|
return
|
|
337
312
|
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
net = net_getter(request.self_id)
|
|
343
|
-
return await net.call_api(api, request.params)
|
|
313
|
+
@adapter.route("*")
|
|
314
|
+
async def internal_api(request: Request[dict]):
|
|
315
|
+
net = net_getter(request.self_id)
|
|
316
|
+
return await net.call_api(request.action.removeprefix("internal/"), request.params)
|
|
@@ -217,7 +217,7 @@ class OneBot11ForwardAdapter(BaseAdapter):
|
|
|
217
217
|
async with self.session.get(path) as resp:
|
|
218
218
|
return Response(await resp.read())
|
|
219
219
|
|
|
220
|
-
async def call_api(self, action: str, params: dict | None = None) -> dict
|
|
220
|
+
async def call_api(self, action: str, params: dict | None = None) -> dict:
|
|
221
221
|
if not self.connection:
|
|
222
222
|
raise RuntimeError("connection is not established")
|
|
223
223
|
|
|
@@ -234,7 +234,7 @@ class OneBot11ForwardAdapter(BaseAdapter):
|
|
|
234
234
|
if result["status"] != "ok":
|
|
235
235
|
raise ActionFailed(f"{result['retcode']}: {result}", result)
|
|
236
236
|
|
|
237
|
-
return result.get("data")
|
|
237
|
+
return result.get("data", {})
|
|
238
238
|
|
|
239
239
|
def __str__(self):
|
|
240
240
|
return self.id
|
|
@@ -279,7 +279,7 @@ class OneBot11MessageEncoder:
|
|
|
279
279
|
await self.flush()
|
|
280
280
|
self.children.append({"type": "xml", "data": attrs})
|
|
281
281
|
elif type_ == "author":
|
|
282
|
-
self.stack[0].author
|
|
282
|
+
self.stack[0].author.update(attrs)
|
|
283
283
|
elif type_ == "quote":
|
|
284
284
|
await self.flush()
|
|
285
285
|
self.children.append({"type": "reply", "data": attrs})
|
|
@@ -294,9 +294,20 @@ class OneBot11MessageEncoder:
|
|
|
294
294
|
elif "id" in attrs:
|
|
295
295
|
self.stack[0].author["message_id"] = str(attrs["id"])
|
|
296
296
|
else:
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
297
|
+
payload = {}
|
|
298
|
+
if "name" in attrs:
|
|
299
|
+
payload["name"] = attrs["name"]
|
|
300
|
+
if "nickname" in attrs:
|
|
301
|
+
payload["name"] = attrs["nickname"]
|
|
302
|
+
if "username" in attrs:
|
|
303
|
+
payload["name"] = attrs["username"]
|
|
304
|
+
if "id" in attrs:
|
|
305
|
+
payload["id"] = int(attrs["id"])
|
|
306
|
+
if "user_id" in attrs:
|
|
307
|
+
payload["id"] = int(attrs["user_id"])
|
|
308
|
+
if "time" in attrs:
|
|
309
|
+
payload["time"] = int(attrs["time"])
|
|
310
|
+
self.stack[0].author.update(payload)
|
|
300
311
|
await self.render(_children)
|
|
301
312
|
await self.flush()
|
|
302
313
|
else:
|
|
@@ -104,7 +104,7 @@ class _Connection:
|
|
|
104
104
|
|
|
105
105
|
asyncio.create_task(event_parse_task(data))
|
|
106
106
|
|
|
107
|
-
async def call_api(self, action: str, params: dict | None = None) -> dict
|
|
107
|
+
async def call_api(self, action: str, params: dict | None = None) -> dict:
|
|
108
108
|
if not self.ws:
|
|
109
109
|
raise RuntimeError("connection is not established")
|
|
110
110
|
|
|
@@ -121,7 +121,7 @@ class _Connection:
|
|
|
121
121
|
if result["status"] != "ok":
|
|
122
122
|
raise ActionFailed(f"{result['retcode']}: {result}", result)
|
|
123
123
|
|
|
124
|
-
return result.get("data")
|
|
124
|
+
return result.get("data", {})
|
|
125
125
|
|
|
126
126
|
|
|
127
127
|
class OneBot11ReverseAdapter(BaseAdapter):
|
|
@@ -2,7 +2,7 @@ from typing import Protocol
|
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
class OneBotNetwork(Protocol):
|
|
5
|
-
async def call_api(self, action: str, params: dict | None = None) -> dict
|
|
5
|
+
async def call_api(self, action: str, params: dict | None = None) -> dict: ...
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
SPECIAL_POST_TYPE = {"message_sent": "message"}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|