ErisPulse-WebhookAdapter 4.2.0__tar.gz → 4.3.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.
- {erispulse_webhookadapter-4.2.0 → erispulse_webhookadapter-4.3.0}/ErisPulse_WebhookAdapter.egg-info/PKG-INFO +1 -1
- {erispulse_webhookadapter-4.2.0 → erispulse_webhookadapter-4.3.0}/PKG-INFO +1 -1
- {erispulse_webhookadapter-4.2.0 → erispulse_webhookadapter-4.3.0}/WebhookAdapter/Core.py +38 -1
- {erispulse_webhookadapter-4.2.0 → erispulse_webhookadapter-4.3.0}/pyproject.toml +1 -1
- {erispulse_webhookadapter-4.2.0 → erispulse_webhookadapter-4.3.0}/ErisPulse_WebhookAdapter.egg-info/SOURCES.txt +0 -0
- {erispulse_webhookadapter-4.2.0 → erispulse_webhookadapter-4.3.0}/ErisPulse_WebhookAdapter.egg-info/dependency_links.txt +0 -0
- {erispulse_webhookadapter-4.2.0 → erispulse_webhookadapter-4.3.0}/ErisPulse_WebhookAdapter.egg-info/entry_points.txt +0 -0
- {erispulse_webhookadapter-4.2.0 → erispulse_webhookadapter-4.3.0}/ErisPulse_WebhookAdapter.egg-info/top_level.txt +0 -0
- {erispulse_webhookadapter-4.2.0 → erispulse_webhookadapter-4.3.0}/LICENSE +0 -0
- {erispulse_webhookadapter-4.2.0 → erispulse_webhookadapter-4.3.0}/README.md +0 -0
- {erispulse_webhookadapter-4.2.0 → erispulse_webhookadapter-4.3.0}/WebhookAdapter/Converter.py +0 -0
- {erispulse_webhookadapter-4.2.0 → erispulse_webhookadapter-4.3.0}/WebhookAdapter/__init__.py +0 -0
- {erispulse_webhookadapter-4.2.0 → erispulse_webhookadapter-4.3.0}/setup.cfg +0 -0
|
@@ -11,7 +11,7 @@ from ErisPulse.Core.Bases.config_schema import dict_to_dataclass
|
|
|
11
11
|
from ErisPulse.Core.Event import register_event_mixin, unregister_platform_event_methods
|
|
12
12
|
from ErisPulse.Core.i18n import i18n
|
|
13
13
|
|
|
14
|
-
__version__ = "4.
|
|
14
|
+
__version__ = "4.3.0"
|
|
15
15
|
|
|
16
16
|
# 软依赖的框架最低版本(运行时检测,仅提示不强制)
|
|
17
17
|
MIN_FRAMEWORK_VERSION = (2, 7, 1)
|
|
@@ -19,6 +19,32 @@ MIN_FRAMEWORK_VERSION = (2, 7, 1)
|
|
|
19
19
|
from .Converter import WebhookConverter
|
|
20
20
|
|
|
21
21
|
|
|
22
|
+
def _forward_node_text(node: Dict) -> str:
|
|
23
|
+
"""提取合并转发节点 content 中全部 text 段文本(段间直接连接)"""
|
|
24
|
+
data = node.get("data") or {}
|
|
25
|
+
return "".join(
|
|
26
|
+
str(seg.get("data", {}).get("text") or "")
|
|
27
|
+
for seg in (data.get("content") or [])
|
|
28
|
+
if isinstance(seg, dict) and seg.get("type") == "text"
|
|
29
|
+
)
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def _forward_nodes_plain(nodes, separator: str = "\n") -> str:
|
|
33
|
+
"""合并转发节点降级纯文本:每条「昵称: 正文」(Webhook 桥接无富文本能力)"""
|
|
34
|
+
lines = []
|
|
35
|
+
for node in nodes if isinstance(nodes, list) else [nodes]:
|
|
36
|
+
if not isinstance(node, dict):
|
|
37
|
+
continue
|
|
38
|
+
data = node.get("data") or {}
|
|
39
|
+
nickname = str(data.get("nickname") or "").strip()
|
|
40
|
+
text = _forward_node_text(node).strip()
|
|
41
|
+
if nickname and text:
|
|
42
|
+
lines.append(f"{nickname}: {text}")
|
|
43
|
+
elif text:
|
|
44
|
+
lines.append(text)
|
|
45
|
+
return separator.join(lines)
|
|
46
|
+
|
|
47
|
+
|
|
22
48
|
@dataclass
|
|
23
49
|
class WebhookAccountConfig(BotAccountConfig):
|
|
24
50
|
"""Webhook 桥接账户配置:一个账户 = 一个入站路径 + 一个出站 URL + 鉴权密钥"""
|
|
@@ -113,6 +139,17 @@ class WebhookAdapter(BaseAdapter):
|
|
|
113
139
|
return self.Raw_ob12([{"type": "image", "data": {"file": file}}])
|
|
114
140
|
|
|
115
141
|
def Raw_ob12(self, message: list, **kwargs):
|
|
142
|
+
if isinstance(message, dict):
|
|
143
|
+
message = [message]
|
|
144
|
+
|
|
145
|
+
# node 段降级为纯文本原文输出(内容不丢失)
|
|
146
|
+
message = [
|
|
147
|
+
{"type": "text", "data": {"text": _forward_nodes_plain(seg)}}
|
|
148
|
+
if isinstance(seg, dict) and seg.get("type") == "node"
|
|
149
|
+
else seg
|
|
150
|
+
for seg in message
|
|
151
|
+
]
|
|
152
|
+
|
|
116
153
|
async def _do_send():
|
|
117
154
|
segments = self._apply_modifiers(message)
|
|
118
155
|
ctx = self.send_context
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{erispulse_webhookadapter-4.2.0 → erispulse_webhookadapter-4.3.0}/WebhookAdapter/Converter.py
RENAMED
|
File without changes
|
{erispulse_webhookadapter-4.2.0 → erispulse_webhookadapter-4.3.0}/WebhookAdapter/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|