entari-plugin-server 0.8.0__tar.gz → 0.8.2__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.
- {entari_plugin_server-0.8.0 → entari_plugin_server-0.8.2}/PKG-INFO +5 -3
- {entari_plugin_server-0.8.0 → entari_plugin_server-0.8.2}/pyproject.toml +7 -5
- {entari_plugin_server-0.8.0 → entari_plugin_server-0.8.2}/src/entari_plugin_server/__init__.py +1 -1
- {entari_plugin_server-0.8.0 → entari_plugin_server-0.8.2}/src/entari_plugin_server/_adapter.py +2 -3
- {entari_plugin_server-0.8.0 → entari_plugin_server-0.8.2}/src/entari_plugin_server/patch.py +66 -14
- {entari_plugin_server-0.8.0 → entari_plugin_server-0.8.2}/LICENSE +0 -0
- {entari_plugin_server-0.8.0 → entari_plugin_server-0.8.2}/README.md +0 -0
- {entari_plugin_server-0.8.0 → entari_plugin_server-0.8.2}/src/entari_plugin_server/README.md +0 -0
- {entari_plugin_server-0.8.0 → entari_plugin_server-0.8.2}/src/entari_plugin_server/config.py +0 -0
- {entari_plugin_server-0.8.0 → entari_plugin_server-0.8.2}/tests/__init__.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: entari-plugin-server
|
|
3
|
-
Version: 0.8.
|
|
3
|
+
Version: 0.8.2
|
|
4
4
|
Summary: Entari plugin for running Satori Server
|
|
5
5
|
Keywords: server,adapters,satori,entari,plugin
|
|
6
6
|
Author-Email: RF-Tar-Railt <rf_tar_railt@qq.com>
|
|
@@ -8,8 +8,10 @@ License: MIT
|
|
|
8
8
|
Project-URL: homepage, https://github.com/ArcletProject/entari-plugin-server
|
|
9
9
|
Project-URL: repository, https://github.com/ArcletProject/entari-plugin-server
|
|
10
10
|
Requires-Python: >=3.11
|
|
11
|
-
Requires-Dist: arclet-entari>=0.19.
|
|
12
|
-
Requires-Dist: satori-python-server<1.4.0,>=1.3.
|
|
11
|
+
Requires-Dist: arclet-entari>=0.19.0.post2
|
|
12
|
+
Requires-Dist: satori-python-server<1.4.0,>=1.3.11
|
|
13
|
+
Requires-Dist: satori-python-core<1.4.0,>=1.3.11
|
|
14
|
+
Requires-Dist: satori-python-client<1.4.0,>=1.3.11
|
|
13
15
|
Provides-Extra: fastapi
|
|
14
16
|
Requires-Dist: fastapi>=0.116.1; extra == "fastapi"
|
|
15
17
|
Description-Content-Type: text/markdown
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "entari-plugin-server"
|
|
3
|
-
version = "0.8.
|
|
3
|
+
version = "0.8.2"
|
|
4
4
|
description = "Entari plugin for running Satori Server"
|
|
5
5
|
authors = [
|
|
6
6
|
{ name = "RF-Tar-Railt", email = "rf_tar_railt@qq.com" },
|
|
7
7
|
]
|
|
8
8
|
dependencies = [
|
|
9
|
-
"arclet-entari>=0.19.
|
|
10
|
-
"satori-python-server<1.4.0,>=1.3.
|
|
9
|
+
"arclet-entari>=0.19.0.post2",
|
|
10
|
+
"satori-python-server<1.4.0,>=1.3.11",
|
|
11
|
+
"satori-python-core<1.4.0,>=1.3.11",
|
|
12
|
+
"satori-python-client<1.4.0,>=1.3.11",
|
|
11
13
|
]
|
|
12
14
|
requires-python = ">=3.11"
|
|
13
15
|
readme = "README.md"
|
|
@@ -45,8 +47,8 @@ typeCheckingMode = "basic"
|
|
|
45
47
|
|
|
46
48
|
[dependency-groups]
|
|
47
49
|
dev = [
|
|
48
|
-
"arclet-entari[dotenv,reload,yaml]>=0.
|
|
49
|
-
"satori-python-adapter-onebot11>=0.
|
|
50
|
+
"arclet-entari[dotenv,reload,yaml]>=0.19.2.post2",
|
|
51
|
+
"satori-python-adapter-onebot11>=0.5.2",
|
|
50
52
|
"satori-python-adapter-console>=0.5.3",
|
|
51
53
|
"fastapi>=0.116.1",
|
|
52
54
|
"graia-amnesia>=0.11.5",
|
{entari_plugin_server-0.8.0 → entari_plugin_server-0.8.2}/src/entari_plugin_server/__init__.py
RENAMED
|
@@ -33,7 +33,7 @@ plugin.metadata(
|
|
|
33
33
|
"server",
|
|
34
34
|
PluginRole.LIBRARY,
|
|
35
35
|
[{"name": "RF-Tar-Railt", "email": "rf_tar_railt@qq.com"}],
|
|
36
|
-
"0.8.
|
|
36
|
+
"0.8.2",
|
|
37
37
|
description="为 Entari 提供 Satori 服务器支持,基于此为 Entari 提供 ASGI 服务、适配器连接等功能",
|
|
38
38
|
urls={
|
|
39
39
|
"homepage": "https://github.com/ArcletProject/entari-plugin-server",
|
{entari_plugin_server-0.8.0 → entari_plugin_server-0.8.2}/src/entari_plugin_server/_adapter.py
RENAMED
|
@@ -6,11 +6,10 @@ from launart.status import Phase
|
|
|
6
6
|
from starlette.datastructures import FormData
|
|
7
7
|
from starlette.responses import JSONResponse, Response
|
|
8
8
|
|
|
9
|
-
from satori import Api
|
|
9
|
+
from satori import Api, Login
|
|
10
10
|
from satori.exception import ActionFailed
|
|
11
11
|
from satori.server import Adapter as BaseAdapter
|
|
12
12
|
from satori.server import Request
|
|
13
|
-
from satori.server.adapter import LoginType
|
|
14
13
|
|
|
15
14
|
|
|
16
15
|
class EntariAdapter(BaseAdapter):
|
|
@@ -67,7 +66,7 @@ class EntariAdapter(BaseAdapter):
|
|
|
67
66
|
async with self.server.session.get(path) as resp:
|
|
68
67
|
return Response(await resp.read())
|
|
69
68
|
|
|
70
|
-
async def get_logins(self) -> list[
|
|
69
|
+
async def get_logins(self) -> list[Login]:
|
|
71
70
|
return [acc.self_info for acc in self.app.accounts.values()]
|
|
72
71
|
|
|
73
72
|
@property
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
from io import BytesIO
|
|
2
|
+
from typing import TYPE_CHECKING
|
|
2
3
|
|
|
3
4
|
from arclet.entari import Entari
|
|
4
5
|
from arclet.entari.logger import log
|
|
5
6
|
from arclet.entari.session import EntariProtocol
|
|
6
7
|
from arclet.letoderea.utils import add_task
|
|
7
|
-
from satori import Api, Event
|
|
8
|
+
from satori import Api, Event, EventType, LoginStatus
|
|
9
|
+
from satori import event as events
|
|
8
10
|
from satori.client import Account, ApiInfo
|
|
9
11
|
from satori.exception import (
|
|
10
12
|
ActionFailed,
|
|
@@ -96,18 +98,68 @@ class DirectAdapterServer(Server):
|
|
|
96
98
|
for provider in self.providers:
|
|
97
99
|
proxy_urls.extend(provider.proxy_urls())
|
|
98
100
|
await super().post(event)
|
|
99
|
-
|
|
100
|
-
if
|
|
101
|
-
|
|
102
|
-
event.
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
101
|
+
config = ApiInfo(self.host, self.port, self.path, self.token)
|
|
102
|
+
if event.type in (EventType.LOGIN_ADDED, EventType.LOGIN_UPDATED):
|
|
103
|
+
if TYPE_CHECKING:
|
|
104
|
+
assert isinstance(event, events.LoginEvent)
|
|
105
|
+
login = event.login
|
|
106
|
+
if not login.user:
|
|
107
|
+
logger.warning(f"Received login-updated event without user info: {login}")
|
|
108
|
+
return
|
|
109
|
+
login_sn = login.identifier
|
|
110
|
+
if login_sn not in app.accounts:
|
|
111
|
+
account = Account(
|
|
112
|
+
login,
|
|
113
|
+
config,
|
|
114
|
+
proxy_urls,
|
|
115
|
+
DirectAdapterProtocol,
|
|
116
|
+
)
|
|
117
|
+
logger.info(f"account added: {account}")
|
|
118
|
+
else:
|
|
119
|
+
account = app.accounts[login_sn].custom(protocol_cls=DirectAdapterProtocol)
|
|
120
|
+
account.self_info = login
|
|
121
|
+
account.config = config
|
|
122
|
+
logger.info(f"account updated: {account} to {login.status.name}")
|
|
123
|
+
app.accounts[login_sn] = account
|
|
124
|
+
account.protocol.server = self
|
|
125
|
+
(
|
|
126
|
+
account.connected.set()
|
|
127
|
+
if login.status in (LoginStatus.ONLINE, LoginStatus.CONNECT)
|
|
128
|
+
else account.connected.clear()
|
|
106
129
|
)
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
130
|
+
await app.account_update(account, login.status)
|
|
131
|
+
elif event.type == EventType.LOGIN_REMOVED:
|
|
132
|
+
if TYPE_CHECKING:
|
|
133
|
+
assert isinstance(event, events.LoginEvent)
|
|
134
|
+
login = event.login
|
|
135
|
+
if not login.user:
|
|
136
|
+
logger.warning(f"Received login-removed event without user info: {login}")
|
|
137
|
+
return
|
|
138
|
+
login_sn = login.identifier
|
|
139
|
+
if login_sn not in app.accounts:
|
|
140
|
+
logger.warning(f"Received event for unknown account: {event}")
|
|
141
|
+
return
|
|
142
|
+
account = app.accounts[login_sn].custom(protocol_cls=DirectAdapterProtocol)
|
|
143
|
+
app.accounts[login_sn] = account
|
|
144
|
+
account.protocol.server = self
|
|
145
|
+
account.config = config
|
|
146
|
+
account.self_info = login
|
|
110
147
|
else:
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
148
|
+
login_sn = event.login.identifier
|
|
149
|
+
if login_sn not in app.accounts:
|
|
150
|
+
logger.warning(f"Received event for unknown account: {event}")
|
|
151
|
+
return
|
|
152
|
+
account = app.accounts[login_sn].custom(protocol_cls=DirectAdapterProtocol)
|
|
153
|
+
app.accounts[login_sn] = account
|
|
154
|
+
account.protocol.server = self
|
|
155
|
+
account.config = config
|
|
156
|
+
|
|
157
|
+
if app.event_callbacks:
|
|
158
|
+
for callback in app.event_callbacks:
|
|
159
|
+
add_task(callback(account, event)) # type: ignore
|
|
160
|
+
|
|
161
|
+
if event.type == EventType.LOGIN_REMOVED:
|
|
162
|
+
logger.info(f"account removed: {account}")
|
|
163
|
+
account.connected.clear()
|
|
164
|
+
await app.account_update(account, event.login.status)
|
|
165
|
+
del app.accounts[login_sn]
|
|
File without changes
|
|
File without changes
|
{entari_plugin_server-0.8.0 → entari_plugin_server-0.8.2}/src/entari_plugin_server/README.md
RENAMED
|
File without changes
|
{entari_plugin_server-0.8.0 → entari_plugin_server-0.8.2}/src/entari_plugin_server/config.py
RENAMED
|
File without changes
|
|
File without changes
|