satori-python-adapter-milky 0.3.1__tar.gz → 0.4.0__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.
Files changed (18) hide show
  1. {satori_python_adapter_milky-0.3.1 → satori_python_adapter_milky-0.4.0}/.mina/adapter_milky.toml +4 -4
  2. {satori_python_adapter_milky-0.3.1 → satori_python_adapter_milky-0.4.0}/PKG-INFO +6 -6
  3. {satori_python_adapter_milky-0.3.1 → satori_python_adapter_milky-0.4.0}/README.md +2 -2
  4. {satori_python_adapter_milky-0.3.1 → satori_python_adapter_milky-0.4.0}/pyproject.toml +15 -17
  5. {satori_python_adapter_milky-0.3.1 → satori_python_adapter_milky-0.4.0}/src/satori/adapters/milky/base.py +3 -1
  6. {satori_python_adapter_milky-0.3.1 → satori_python_adapter_milky-0.4.0}/src/satori/adapters/milky/message.py +51 -3
  7. {satori_python_adapter_milky-0.3.1 → satori_python_adapter_milky-0.4.0}/LICENSE +0 -0
  8. {satori_python_adapter_milky-0.3.1 → satori_python_adapter_milky-0.4.0}/src/satori/adapters/milky/__init__.py +0 -0
  9. {satori_python_adapter_milky-0.3.1 → satori_python_adapter_milky-0.4.0}/src/satori/adapters/milky/api.py +0 -0
  10. {satori_python_adapter_milky-0.3.1 → satori_python_adapter_milky-0.4.0}/src/satori/adapters/milky/events/__init__.py +0 -0
  11. {satori_python_adapter_milky-0.3.1 → satori_python_adapter_milky-0.4.0}/src/satori/adapters/milky/events/base.py +0 -0
  12. {satori_python_adapter_milky-0.3.1 → satori_python_adapter_milky-0.4.0}/src/satori/adapters/milky/events/group.py +0 -0
  13. {satori_python_adapter_milky-0.3.1 → satori_python_adapter_milky-0.4.0}/src/satori/adapters/milky/events/message.py +0 -0
  14. {satori_python_adapter_milky-0.3.1 → satori_python_adapter_milky-0.4.0}/src/satori/adapters/milky/events/request.py +0 -0
  15. {satori_python_adapter_milky-0.3.1 → satori_python_adapter_milky-0.4.0}/src/satori/adapters/milky/main.py +0 -0
  16. {satori_python_adapter_milky-0.3.1 → satori_python_adapter_milky-0.4.0}/src/satori/adapters/milky/sse.py +0 -0
  17. {satori_python_adapter_milky-0.3.1 → satori_python_adapter_milky-0.4.0}/src/satori/adapters/milky/utils.py +0 -0
  18. {satori_python_adapter_milky-0.3.1 → satori_python_adapter_milky-0.4.0}/src/satori/adapters/milky/webhook.py +0 -0
@@ -1,9 +1,9 @@
1
1
  includes = ["src/satori/adapters/milky"]
2
- raw-dependencies = ["satori-python-server<1.4.0,>= 1.3.0"]
2
+ raw-dependencies = ["satori-python-server<1.4.0,>= 1.3.3"]
3
3
 
4
4
  [project]
5
5
  name = "satori-python-adapter-milky"
6
- version = "0.3.1"
6
+ version = "0.4.0"
7
7
  authors = [
8
8
  {name = "RF-Tar-Railt", email = "rf_tar_railt@qq.com"}
9
9
  ]
@@ -16,11 +16,11 @@ classifiers = [
16
16
  "Typing :: Typed",
17
17
  "Development Status :: 4 - Beta",
18
18
  "License :: OSI Approved :: MIT License",
19
- "Programming Language :: Python :: 3.8",
20
- "Programming Language :: Python :: 3.9",
21
19
  "Programming Language :: Python :: 3.10",
22
20
  "Programming Language :: Python :: 3.11",
23
21
  "Programming Language :: Python :: 3.12",
22
+ "Programming Language :: Python :: 3.13",
23
+ "Programming Language :: Python :: 3.14",
24
24
  "Operating System :: OS Independent",
25
25
  ]
26
26
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: satori-python-adapter-milky
3
- Version: 0.3.1
3
+ Version: 0.4.0
4
4
  Summary: Satori Protocol SDK for python, adapter for Milky
5
5
  Home-page: https://github.com/RF-Tar-Railt/satori-python
6
6
  Author-Email: RF-Tar-Railt <rf_tar_railt@qq.com>
@@ -8,16 +8,16 @@ License: MIT
8
8
  Classifier: Typing :: Typed
9
9
  Classifier: Development Status :: 4 - Beta
10
10
  Classifier: License :: OSI Approved :: MIT License
11
- Classifier: Programming Language :: Python :: 3.8
12
- Classifier: Programming Language :: Python :: 3.9
13
11
  Classifier: Programming Language :: Python :: 3.10
14
12
  Classifier: Programming Language :: Python :: 3.11
15
13
  Classifier: Programming Language :: Python :: 3.12
14
+ Classifier: Programming Language :: Python :: 3.13
15
+ Classifier: Programming Language :: Python :: 3.14
16
16
  Classifier: Operating System :: OS Independent
17
17
  Project-URL: Homepage, https://github.com/RF-Tar-Railt/satori-python
18
18
  Project-URL: Repository, https://github.com/RF-Tar-Railt/satori-python
19
19
  Requires-Python: <4.0,>=3.10
20
- Requires-Dist: satori-python-server<1.4.0,>=1.3.0
20
+ Requires-Dist: satori-python-server<1.4.0,>=1.3.3
21
21
  Description-Content-Type: text/markdown
22
22
 
23
23
  # satori-python
@@ -27,11 +27,11 @@ Description-Content-Type: text/markdown
27
27
  [![PyPI](https://img.shields.io/pypi/v/satori-python)](https://pypi.org/project/satori-python)
28
28
  [![PyPI - Python Version](https://img.shields.io/pypi/pyversions/satori-python)](https://www.python.org/)
29
29
 
30
- 基于 [Satori](https://satori.chat/zh-CN/) 协议的 Python 开发工具包
30
+ 基于 [Satori](https://satori.chat/zh-CN/protocol) 协议的 Python 开发工具包
31
31
 
32
32
  ## 协议介绍
33
33
 
34
- [Satori Protocol](https://satori.chat/zh-CN/)
34
+ [Satori Protocol](https://satori.chat/zh-CN/protocol)
35
35
 
36
36
  ### 协议端
37
37
 
@@ -5,11 +5,11 @@
5
5
  [![PyPI](https://img.shields.io/pypi/v/satori-python)](https://pypi.org/project/satori-python)
6
6
  [![PyPI - Python Version](https://img.shields.io/pypi/pyversions/satori-python)](https://www.python.org/)
7
7
 
8
- 基于 [Satori](https://satori.chat/zh-CN/) 协议的 Python 开发工具包
8
+ 基于 [Satori](https://satori.chat/zh-CN/protocol) 协议的 Python 开发工具包
9
9
 
10
10
  ## 协议介绍
11
11
 
12
- [Satori Protocol](https://satori.chat/zh-CN/)
12
+ [Satori Protocol](https://satori.chat/zh-CN/protocol)
13
13
 
14
14
  ### 协议端
15
15
 
@@ -1,11 +1,11 @@
1
1
  [project]
2
2
  name = "satori-python-adapter-milky"
3
- version = "0.3.1"
3
+ version = "0.4.0"
4
4
  authors = [
5
5
  { name = "RF-Tar-Railt", email = "rf_tar_railt@qq.com" },
6
6
  ]
7
7
  dependencies = [
8
- "satori-python-server<1.4.0,>= 1.3.0",
8
+ "satori-python-server<1.4.0,>= 1.3.3",
9
9
  ]
10
10
  description = "Satori Protocol SDK for python, adapter for Milky"
11
11
  readme = "README.md"
@@ -14,11 +14,11 @@ classifiers = [
14
14
  "Typing :: Typed",
15
15
  "Development Status :: 4 - Beta",
16
16
  "License :: OSI Approved :: MIT License",
17
- "Programming Language :: Python :: 3.8",
18
- "Programming Language :: Python :: 3.9",
19
17
  "Programming Language :: Python :: 3.10",
20
18
  "Programming Language :: Python :: 3.11",
21
19
  "Programming Language :: Python :: 3.12",
20
+ "Programming Language :: Python :: 3.13",
21
+ "Programming Language :: Python :: 3.14",
22
22
  "Operating System :: OS Independent",
23
23
  ]
24
24
 
@@ -38,15 +38,14 @@ build-backend = "mina.backend"
38
38
 
39
39
  [dependency-groups]
40
40
  dev = [
41
- "isort>=5.13.2",
42
- "black>=24.4.0",
43
- "ruff>=0.4.1",
41
+ "black>=26.3.0",
42
+ "ruff>=0.15.1",
44
43
  "pre-commit>=3.7.0",
45
- "fix-future-annotations>=0.5.0",
46
44
  "mina-build<0.6,>=0.5.1",
47
45
  "pdm-mina>=0.3.2",
48
46
  "nonechat<0.7.0,>=0.6.0",
49
47
  "uvicorn[standard]>=0.37.0",
48
+ "pydantic>=2.13.1",
50
49
  ]
51
50
 
52
51
  [tool.pdm.build]
@@ -60,7 +59,7 @@ excludes = [
60
59
 
61
60
  [tool.pdm.scripts.format]
62
61
  composite = [
63
- "isort ./src/ ./example/",
62
+ "ruff check --select I --fix ./src/ ./example/",
64
63
  "black ./src/ ./example/",
65
64
  "ruff check",
66
65
  ]
@@ -74,14 +73,6 @@ line-length = 120
74
73
  include = "\\.pyi?$"
75
74
  extend-exclude = ""
76
75
 
77
- [tool.isort]
78
- profile = "black"
79
- line_length = 120
80
- skip_gitignore = true
81
- extra_standard_library = [
82
- "typing_extensions",
83
- ]
84
-
85
76
  [tool.ruff]
86
77
  line-length = 120
87
78
  target-version = "py310"
@@ -91,6 +82,7 @@ exclude = [
91
82
  "exam2.py",
92
83
  "src/satori/_vendor/*",
93
84
  ]
85
+ respect-gitignore = true
94
86
 
95
87
  [tool.ruff.lint]
96
88
  select = [
@@ -110,6 +102,12 @@ ignore = [
110
102
  "T201",
111
103
  ]
112
104
 
105
+ [tool.ruff.lint.isort]
106
+ extra-standard-library = [
107
+ "typing_extensions",
108
+ ]
109
+ force-sort-within-sections = false
110
+
113
111
  [tool.pyright]
114
112
  pythonPlatform = "All"
115
113
  pythonVersion = "3.10"
@@ -132,7 +132,9 @@ class MilkyBaseAdapter(BaseAdapter, ABC):
132
132
  if not data:
133
133
  return
134
134
  user = decode_login_user(data)
135
- login = Login(0, LoginStatus.ONLINE, "milky", platform="milky", user=user, features=self.features.copy())
135
+ login = Login(
136
+ sn=0, status=LoginStatus.ONLINE, adapter="milky", platform="milky", user=user, features=self.features.copy()
137
+ )
136
138
  self_id = login.id
137
139
  previous = self.logins.get(self_id)
138
140
  self.logins[self_id] = login
@@ -167,6 +167,9 @@ class MilkyMessageEncoder:
167
167
  case "file":
168
168
  await self.flush()
169
169
  await self._send_file(attrs)
170
+ case "milky:light_app":
171
+ await self.flush()
172
+ self.segments.append({"type": "light_app", "data": {"json_payload": attrs["json_payload"]}})
170
173
  case "author":
171
174
  self.stack[0].author.update(attrs)
172
175
  case "quote":
@@ -364,7 +367,7 @@ async def _decode_segments(net: MilkyNetwork, payload: dict, segments: Sequence[
364
367
  case "text":
365
368
  result.append(E.text(data.get("text", "")))
366
369
  case "mention":
367
- result.append(E.at(str(data.get("user_id"))))
370
+ result.append(E.at(str(data.get("user_id")), name=data.get("name")))
368
371
  case "mention_all":
369
372
  result.append(E.at_all())
370
373
  case "face":
@@ -380,15 +383,60 @@ async def _decode_segments(net: MilkyNetwork, payload: dict, segments: Sequence[
380
383
  case "reply":
381
384
  seq = data.get("message_seq")
382
385
  if seq is not None:
383
- quote = await _decode_reply(net, payload, int(seq))
386
+ quote = await _decode_reply(net, payload, data, int(seq))
384
387
  if quote:
385
388
  result.append(quote)
389
+ case "forward":
390
+ forward_id = data.get("forward_id")
391
+ if forward_id is not None:
392
+ messages = (await net.call_api("get_forwarded_messages", {"forward_id": forward_id}))["messages"]
393
+ forward_elements = []
394
+ for msg in messages:
395
+ sender_name = msg.get("sender_name")
396
+ avatar = msg.get("avatar_url")
397
+ response = {}
398
+ if "message_seq" in msg:
399
+ try:
400
+ response = await net.call_api(
401
+ "get_message",
402
+ {
403
+ "message_scene": payload["message_scene"],
404
+ "peer_id": payload["peer_id"],
405
+ "message_seq": msg["message_seq"],
406
+ },
407
+ )
408
+ except Exception:
409
+ pass
410
+ if response:
411
+ origin = await decode_message(net, response["message"])
412
+ content = []
413
+ if origin.user:
414
+ content.append(
415
+ E.author(
416
+ origin.user.id, origin.user.name or sender_name, origin.user.avatar or avatar
417
+ )
418
+ )
419
+ content.extend(origin.message)
420
+
421
+ else:
422
+ content = await _decode_segments(net, payload, msg.get("segments", []))
423
+ content.insert(0, E.author(str(msg.get("sender_id")), sender_name, avatar))
424
+ forward_elements.append(E.message(str(msg.get("message_seq")), content=content))
425
+ result.append(E.message(forward_id, content=forward_elements, forward=True))
386
426
  case _:
387
427
  result.append(Custom(f"milky:{seg_type}", data))
388
428
  return result
389
429
 
390
430
 
391
- async def _decode_reply(net: MilkyNetwork, payload: dict, message_seq: int) -> Element | None:
431
+ async def _decode_reply(net: MilkyNetwork, payload: dict, data: dict, message_seq: int) -> Element | None:
432
+ if all(k in data for k in ("sender_id", "time", "segments")):
433
+ user = User(str(data["sender_id"]), data.get("sender_name"), avatar=user_avatar(data["sender_id"]))
434
+ elements = await _decode_segments(net, payload, data["segments"])
435
+ content = []
436
+ if user:
437
+ content.append(E.author(user.id, user.name, user.avatar))
438
+ content.extend(elements)
439
+ return E.quote(str(message_seq), content=content)
392
440
  try:
393
441
  response = await net.call_api(
394
442
  "get_message",