@zhin.js/adapter-wecom 1.1.14 → 1.1.16
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.
- package/CHANGELOG.md +54 -0
- package/agents/wecom/messages.js +12 -0
- package/agents/wecom/messages.ts +12 -0
- package/agents/wecom/skills/wecom/tools/send_text/index.js +2 -1
- package/agents/wecom/skills/wecom/tools/send_text/index.ts +2 -1
- package/commands/wecom/endpoint/definition.js +4 -4
- package/commands/wecom/endpoint/definition.ts +4 -4
- package/lib/endpoint.d.ts +1 -1
- package/lib/endpoint.js +2 -2
- package/lib/protocol.d.ts +2 -8
- package/lib/protocol.js +4 -2
- package/package.json +16 -16
- package/schema.json +35 -5
- package/src/endpoint.ts +2 -2
- package/src/protocol.ts +5 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,59 @@
|
|
|
1
1
|
# @zhin.js/adapter-wecom
|
|
2
2
|
|
|
3
|
+
## 1.1.16
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 53bc6a0: 适配器配置标签、端点命令和工具反馈支持中英文;复用当前操作语言,保持协议值、用户内容、身份、权限与发送链路不变。Sandbox 展示使用项目语言,QQ 绑定与交互状态保留完整会话身份。
|
|
8
|
+
- 9cade30: 修复国际化调用链遗漏:Agent 审批、管理命令和错误反馈采用可信语言及实际命令前缀;游戏快捷帮助、工具反馈、平台默认卡片和后台通知贯通语言。协议即时回复复用受运行代约束的个人语言查询,业务验证支持不改变审批身份的双语展示元数据。
|
|
9
|
+
|
|
10
|
+
AI 正文、进度与耗尽摘要统一优先遵从用户明确语言要求,再跟随实际输入;个人/项目语言仅作兜底,固定界面文案继续使用配置语言,不增加翻译调用。
|
|
11
|
+
|
|
12
|
+
GitHub 工作区为 Git clone/pull/fetch/ls-remote 显式分隔选项与位置参数,保留仓库和分支校验;顺序写入 Bot 名称和邮箱,避免竞争同一配置文件锁。
|
|
13
|
+
|
|
14
|
+
- Updated dependencies [334e92d]
|
|
15
|
+
- Updated dependencies [f3b7c9f]
|
|
16
|
+
- Updated dependencies [658a5fb]
|
|
17
|
+
- Updated dependencies [144a17b]
|
|
18
|
+
- Updated dependencies [18296cf]
|
|
19
|
+
- Updated dependencies [08e64de]
|
|
20
|
+
- Updated dependencies [9cade30]
|
|
21
|
+
- Updated dependencies [53bc6a0]
|
|
22
|
+
- Updated dependencies [7595136]
|
|
23
|
+
- Updated dependencies [66b6404]
|
|
24
|
+
- Updated dependencies [adb4af2]
|
|
25
|
+
- Updated dependencies [69f9ef6]
|
|
26
|
+
- Updated dependencies [17d1301]
|
|
27
|
+
- @zhin.js/adapter@1.1.23
|
|
28
|
+
- @zhin.js/host-http@1.1.10
|
|
29
|
+
- @zhin.js/core@1.1.51
|
|
30
|
+
- @zhin.js/tool@1.1.10
|
|
31
|
+
- @zhin.js/skill@1.1.10
|
|
32
|
+
- @zhin.js/im-contract@1.1.7
|
|
33
|
+
- @zhin.js/agent-feature@1.1.10
|
|
34
|
+
- @zhin.js/feature-kit@1.1.9
|
|
35
|
+
|
|
36
|
+
## 1.1.15
|
|
37
|
+
|
|
38
|
+
### Patch Changes
|
|
39
|
+
|
|
40
|
+
- Updated dependencies [f98025b]
|
|
41
|
+
- Updated dependencies [66ec1a5]
|
|
42
|
+
- Updated dependencies [7d68df6]
|
|
43
|
+
- Updated dependencies [bf0fa9f]
|
|
44
|
+
- Updated dependencies [3326db3]
|
|
45
|
+
- Updated dependencies [e91235e]
|
|
46
|
+
- Updated dependencies [6da2bad]
|
|
47
|
+
- Updated dependencies [3781f1c]
|
|
48
|
+
- @zhin.js/core@1.1.50
|
|
49
|
+
- @zhin.js/adapter@1.1.22
|
|
50
|
+
- @zhin.js/im-contract@1.1.6
|
|
51
|
+
- @zhin.js/tool@1.1.9
|
|
52
|
+
- @zhin.js/host-http@1.1.9
|
|
53
|
+
- @zhin.js/agent-feature@1.1.9
|
|
54
|
+
- @zhin.js/feature-kit@1.1.8
|
|
55
|
+
- @zhin.js/skill@1.1.9
|
|
56
|
+
|
|
3
57
|
## 1.1.14
|
|
4
58
|
|
|
5
59
|
### Patch Changes
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// Generated by build-plugin-runtime-entries.mjs. Do not edit.
|
|
2
|
+
import { createMessages } from 'zhin.js/i18n';
|
|
3
|
+
export const messages = createMessages({
|
|
4
|
+
"sendFailed": {
|
|
5
|
+
"zh-CN": "发送失败",
|
|
6
|
+
"en": "Delivery failed"
|
|
7
|
+
},
|
|
8
|
+
"messageSent": {
|
|
9
|
+
"zh-CN": "消息已发送",
|
|
10
|
+
"en": "Message sent"
|
|
11
|
+
}
|
|
12
|
+
});
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
// Generated by build-plugin-runtime-entries.mjs. Do not edit.
|
|
2
|
+
import { messages as t } from "../../../../messages.js";
|
|
2
3
|
import { defineAgentTool } from '@zhin.js/tool';
|
|
3
4
|
import { z } from 'zod';
|
|
4
5
|
export default defineAgentTool({
|
|
@@ -12,6 +13,6 @@ export default defineAgentTool({
|
|
|
12
13
|
async execute({ user_id, content }, context) {
|
|
13
14
|
const endpoint = context.$client;
|
|
14
15
|
const success = await endpoint.sendTextMessage(user_id, content);
|
|
15
|
-
return { success, message: success ? '
|
|
16
|
+
return { success, message: success ? t(context.locale, 'messageSent') : t(context.locale, 'sendFailed') };
|
|
16
17
|
},
|
|
17
18
|
});
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { messages as t } from "../../../../messages.js";
|
|
1
2
|
import { defineAgentTool } from '@zhin.js/tool';
|
|
2
3
|
import { z } from 'zod';
|
|
3
4
|
export default defineAgentTool<{ user_id: string; content: string }>({
|
|
@@ -11,7 +12,7 @@ export default defineAgentTool<{ user_id: string; content: string }>({
|
|
|
11
12
|
async execute({ user_id, content }: { user_id: string; content: string }, context) {
|
|
12
13
|
const endpoint = context.$client;
|
|
13
14
|
const success = await endpoint.sendTextMessage(user_id, content);
|
|
14
|
-
return { success, message: success ? '
|
|
15
|
+
return { success, message: success ? t(context.locale, 'messageSent') : t(context.locale, 'sendFailed') };
|
|
15
16
|
},
|
|
16
17
|
});
|
|
17
18
|
|
|
@@ -10,10 +10,10 @@ export const wecomEndpointCommands = createEndpointCommands({
|
|
|
10
10
|
adapterKey: 'wecom',
|
|
11
11
|
adapterDisplayName: 'WeCom',
|
|
12
12
|
fields: [
|
|
13
|
-
{ key: 'corpId', required: true, env: true, description: '企业 corpId' },
|
|
14
|
-
{ key: 'agentSecret', required: true, env: true, description: '应用 secret' },
|
|
15
|
-
{ key: 'token', required: true, env: true, description: '回调 token' },
|
|
16
|
-
{ key: 'encodingAESKey', required: true, env: true, description: '回调加解密 key' },
|
|
13
|
+
{ key: 'corpId', required: true, env: true, description: '企业 corpId', descriptionI18n: { en: "WeCom corporation ID" } },
|
|
14
|
+
{ key: 'agentSecret', required: true, env: true, description: '应用 secret', descriptionI18n: { en: "Application secret" } },
|
|
15
|
+
{ key: 'token', required: true, env: true, description: '回调 token', descriptionI18n: { en: "Callback token" } },
|
|
16
|
+
{ key: 'encodingAESKey', required: true, env: true, description: '回调加解密 key', descriptionI18n: { en: "Callback encryption key" } },
|
|
17
17
|
],
|
|
18
18
|
running: (use) => use(wecomRuntimeStateToken).endpoints.values(),
|
|
19
19
|
describeEntry: (entry) => `corpId: ${String(entry.corpId)}`,
|
|
@@ -10,10 +10,10 @@ export const wecomEndpointCommands = createEndpointCommands({
|
|
|
10
10
|
adapterKey: 'wecom',
|
|
11
11
|
adapterDisplayName: 'WeCom',
|
|
12
12
|
fields: [
|
|
13
|
-
{ key: 'corpId', required: true, env: true, description: '企业 corpId' },
|
|
14
|
-
{ key: 'agentSecret', required: true, env: true, description: '应用 secret' },
|
|
15
|
-
{ key: 'token', required: true, env: true, description: '回调 token' },
|
|
16
|
-
{ key: 'encodingAESKey', required: true, env: true, description: '回调加解密 key' },
|
|
13
|
+
{ key: 'corpId', required: true, env: true, description: '企业 corpId', descriptionI18n: { en: "WeCom corporation ID" } },
|
|
14
|
+
{ key: 'agentSecret', required: true, env: true, description: '应用 secret', descriptionI18n: { en: "Application secret" } },
|
|
15
|
+
{ key: 'token', required: true, env: true, description: '回调 token', descriptionI18n: { en: "Callback token" } },
|
|
16
|
+
{ key: 'encodingAESKey', required: true, env: true, description: '回调加解密 key', descriptionI18n: { en: "Callback encryption key" } },
|
|
17
17
|
],
|
|
18
18
|
running: (use) => use(wecomRuntimeStateToken).endpoints.values(),
|
|
19
19
|
describeEntry: (entry) => `corpId: ${String(entry.corpId)}`,
|
package/lib/endpoint.d.ts
CHANGED
|
@@ -54,7 +54,7 @@ export declare class WecomEndpoint extends Endpoint<WecomClient> {
|
|
|
54
54
|
open(): void;
|
|
55
55
|
close(): void;
|
|
56
56
|
stop(): Promise<void>;
|
|
57
|
-
send({ conversation, payload }: EndpointSendRequest): Promise<string>;
|
|
57
|
+
send({ conversation, payload, locale }: EndpointSendRequest): Promise<string>;
|
|
58
58
|
recallMessage(messageId: string): Promise<void>;
|
|
59
59
|
/** Test / internal: admit a parsed message when open (non-webhook path). */
|
|
60
60
|
admit(msg: WecomMessage): void;
|
package/lib/endpoint.js
CHANGED
|
@@ -85,9 +85,9 @@ export class WecomEndpoint extends Endpoint {
|
|
|
85
85
|
this.#started = false;
|
|
86
86
|
this.#logger.debug(formatCompact({ op: 'disconnect' }));
|
|
87
87
|
}
|
|
88
|
-
async send({ conversation, payload }) {
|
|
88
|
+
async send({ conversation, payload, locale }) {
|
|
89
89
|
const materialized = await this.#materializeOutboundMedia(payload);
|
|
90
|
-
const content = formatOutboundBody(materialized);
|
|
90
|
+
const content = formatOutboundBody(materialized, locale);
|
|
91
91
|
const body = buildSendRequestBody(conversation.id, content,
|
|
92
92
|
// Legacy field: historically written into agentid (preserved for cutover).
|
|
93
93
|
this.#options.config.agentSecret);
|
package/lib/protocol.d.ts
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
* WeCom (企业微信) protocol helpers — no legacy Adapter/Endpoint / segment-mapper.
|
|
3
|
-
* Canonicalization is owned by gateway/core before endpoint.send.
|
|
4
|
-
*/
|
|
1
|
+
import { type Locale } from 'zhin.js/i18n';
|
|
5
2
|
import type { IncomingMessage } from 'node:http';
|
|
6
3
|
import type { ConversationRef } from '@zhin.js/im-contract';
|
|
7
4
|
/** One endpoint config after AdapterIndex expands `plugins.<instanceKey>.endpoints`. */
|
|
@@ -88,10 +85,7 @@ export declare function resolveChatType(fromUserName: string): 'group' | 'privat
|
|
|
88
85
|
* `@chatroom` 群会话 → kind 'group',其余(应用消息/单聊)→ kind 'private'。
|
|
89
86
|
*/
|
|
90
87
|
export declare function wecomInboundConversation(endpointKey: string, msg: WecomMessage): ConversationRef;
|
|
91
|
-
|
|
92
|
-
* Wire-encode an already-rendered outbound payload into WeCom message/send body parts.
|
|
93
|
-
*/
|
|
94
|
-
export declare function formatOutboundBody(payload: unknown): WecomSendBody;
|
|
88
|
+
export declare function formatOutboundBody(payload: unknown, locale?: Locale): WecomSendBody;
|
|
95
89
|
export declare function buildSendRequestBody(targetId: string, content: WecomSendBody, agentId: string | number): Record<string, unknown>;
|
|
96
90
|
export declare function readTextBody(request: IncomingMessage, options?: {
|
|
97
91
|
readonly limit?: number;
|
package/lib/protocol.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { createMessages } from 'zhin.js/i18n';
|
|
1
2
|
/**
|
|
2
3
|
* WeCom (企业微信) protocol helpers — no legacy Adapter/Endpoint / segment-mapper.
|
|
3
4
|
* Canonicalization is owned by gateway/core before endpoint.send.
|
|
@@ -168,7 +169,8 @@ export function wecomInboundConversation(endpointKey, msg) {
|
|
|
168
169
|
/**
|
|
169
170
|
* Wire-encode an already-rendered outbound payload into WeCom message/send body parts.
|
|
170
171
|
*/
|
|
171
|
-
|
|
172
|
+
const outboundMessages = createMessages({ link: { 'zh-CN': '链接', en: 'Link' } });
|
|
173
|
+
export function formatOutboundBody(payload, locale) {
|
|
172
174
|
if (typeof payload === 'string') {
|
|
173
175
|
return { msgtype: 'text', data: { content: payload } };
|
|
174
176
|
}
|
|
@@ -219,7 +221,7 @@ export function formatOutboundBody(payload) {
|
|
|
219
221
|
mediaType = 'news';
|
|
220
222
|
mediaData = {
|
|
221
223
|
articles: [{
|
|
222
|
-
title: data.title || '
|
|
224
|
+
title: data.title || outboundMessages(locale, 'link'),
|
|
223
225
|
description: data.text || data.content || '',
|
|
224
226
|
url: data.url,
|
|
225
227
|
picurl: data.picUrl,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zhin.js/adapter-wecom",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.16",
|
|
4
4
|
"description": "Zhin.js WeCom (企业微信) adapter for Plugin Runtime (HTTP webhook)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./lib/index.js",
|
|
@@ -33,24 +33,24 @@
|
|
|
33
33
|
"directory": "plugins/adapters/wecom"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@zhin.js/adapter": "1.1.
|
|
37
|
-
"@zhin.js/agent-feature": "1.1.
|
|
38
|
-
"@zhin.js/core": "1.1.
|
|
39
|
-
"@zhin.js/feature-kit": "1.1.
|
|
40
|
-
"@zhin.js/host-http": "1.1.
|
|
41
|
-
"@zhin.js/im-contract": "1.1.
|
|
36
|
+
"@zhin.js/adapter": "1.1.23",
|
|
37
|
+
"@zhin.js/agent-feature": "1.1.10",
|
|
38
|
+
"@zhin.js/core": "1.1.51",
|
|
39
|
+
"@zhin.js/feature-kit": "1.1.9",
|
|
40
|
+
"@zhin.js/host-http": "1.1.10",
|
|
41
|
+
"@zhin.js/im-contract": "1.1.7",
|
|
42
42
|
"@zhin.js/logger": "1.1.2",
|
|
43
|
-
"@zhin.js/skill": "1.1.
|
|
44
|
-
"@zhin.js/tool": "1.1.
|
|
43
|
+
"@zhin.js/skill": "1.1.10",
|
|
44
|
+
"@zhin.js/tool": "1.1.10"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
47
47
|
"zod": "^4.0.0",
|
|
48
|
-
"@zhin.js/adapter": "^1.1.
|
|
49
|
-
"@zhin.js/command": "^1.1.
|
|
50
|
-
"@zhin.js/core": "^1.1.
|
|
51
|
-
"@zhin.js/host-http": "^1.1.
|
|
52
|
-
"@zhin.js/permission": "^1.1.
|
|
53
|
-
"zhin.js": "^1.1.
|
|
48
|
+
"@zhin.js/adapter": "^1.1.23",
|
|
49
|
+
"@zhin.js/command": "^1.1.11",
|
|
50
|
+
"@zhin.js/core": "^1.1.51",
|
|
51
|
+
"@zhin.js/host-http": "^1.1.10",
|
|
52
|
+
"@zhin.js/permission": "^1.1.9",
|
|
53
|
+
"zhin.js": "^1.1.16"
|
|
54
54
|
},
|
|
55
55
|
"peerDependenciesMeta": {
|
|
56
56
|
"@zhin.js/command": {
|
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
"typescript": "^6.0.3",
|
|
69
69
|
"vitest": "^4.1.10",
|
|
70
70
|
"zod": "^4.4.3",
|
|
71
|
-
"zhin.js": "1.1.
|
|
71
|
+
"zhin.js": "1.1.16"
|
|
72
72
|
},
|
|
73
73
|
"files": [
|
|
74
74
|
"adapters",
|
package/schema.json
CHANGED
|
@@ -16,7 +16,12 @@
|
|
|
16
16
|
"string",
|
|
17
17
|
"number"
|
|
18
18
|
],
|
|
19
|
-
"description": "框架 master(WeCom userid;AI/工具权限、endpoint 管理)。endpoints[i].master 可逐项覆盖"
|
|
19
|
+
"description": "框架 master(WeCom userid;AI/工具权限、endpoint 管理)。endpoints[i].master 可逐项覆盖",
|
|
20
|
+
"x-i18n": {
|
|
21
|
+
"en": {
|
|
22
|
+
"description": "Framework masters (WeCom userid; AI/tool permissions and endpoint management). endpoints[i].master can override this value."
|
|
23
|
+
}
|
|
24
|
+
}
|
|
20
25
|
},
|
|
21
26
|
"trusted": {
|
|
22
27
|
"type": "array",
|
|
@@ -27,7 +32,12 @@
|
|
|
27
32
|
],
|
|
28
33
|
"description": "Trusted WeCom userid"
|
|
29
34
|
},
|
|
30
|
-
"description": "框架 trusted 用户列表(弱于 master)。endpoints[i].trusted 可逐项追加"
|
|
35
|
+
"description": "框架 trusted 用户列表(弱于 master)。endpoints[i].trusted 可逐项追加",
|
|
36
|
+
"x-i18n": {
|
|
37
|
+
"en": {
|
|
38
|
+
"description": "Framework trusted users, below master authority. endpoints[i].trusted can add users."
|
|
39
|
+
}
|
|
40
|
+
}
|
|
31
41
|
},
|
|
32
42
|
"endpoints": {
|
|
33
43
|
"type": "array",
|
|
@@ -42,7 +52,12 @@
|
|
|
42
52
|
"string",
|
|
43
53
|
"number"
|
|
44
54
|
],
|
|
45
|
-
"description": "本 endpoint 的框架 master(WeCom userid);覆盖顶层 master"
|
|
55
|
+
"description": "本 endpoint 的框架 master(WeCom userid);覆盖顶层 master",
|
|
56
|
+
"x-i18n": {
|
|
57
|
+
"en": {
|
|
58
|
+
"description": "Framework masters for this endpoint (WeCom userid), overriding the top-level master list."
|
|
59
|
+
}
|
|
60
|
+
}
|
|
46
61
|
},
|
|
47
62
|
"trusted": {
|
|
48
63
|
"type": "array",
|
|
@@ -53,7 +68,12 @@
|
|
|
53
68
|
],
|
|
54
69
|
"description": "Trusted WeCom userid"
|
|
55
70
|
},
|
|
56
|
-
"description": "本 endpoint 的 trusted 列表"
|
|
71
|
+
"description": "本 endpoint 的 trusted 列表",
|
|
72
|
+
"x-i18n": {
|
|
73
|
+
"en": {
|
|
74
|
+
"description": "Trusted users for this endpoint."
|
|
75
|
+
}
|
|
76
|
+
}
|
|
57
77
|
},
|
|
58
78
|
"corpId": {
|
|
59
79
|
"type": "string",
|
|
@@ -92,12 +112,22 @@
|
|
|
92
112
|
"token",
|
|
93
113
|
"encodingAESKey"
|
|
94
114
|
]
|
|
115
|
+
},
|
|
116
|
+
"x-i18n": {
|
|
117
|
+
"en": {
|
|
118
|
+
"description": "Multiple accounts: mount multiple endpoints in one plugin instance. Each entry uses the top-level fields; id is required and other fields override defaults."
|
|
119
|
+
}
|
|
95
120
|
}
|
|
96
121
|
},
|
|
97
122
|
"commandPrefix": {
|
|
98
123
|
"type": "string",
|
|
99
124
|
"default": "",
|
|
100
|
-
"description": "命令前缀(默认 '' 无前缀,任意文本按命令匹配;如 '/' 要求 / 开头)。endpoints[i] 可逐项覆盖"
|
|
125
|
+
"description": "命令前缀(默认 '' 无前缀,任意文本按命令匹配;如 '/' 要求 / 开头)。endpoints[i] 可逐项覆盖",
|
|
126
|
+
"x-i18n": {
|
|
127
|
+
"en": {
|
|
128
|
+
"description": "Command prefix. The default empty string allows unprefixed commands; '/' requires a leading slash. Each endpoints[i] can override it."
|
|
129
|
+
}
|
|
130
|
+
}
|
|
101
131
|
}
|
|
102
132
|
},
|
|
103
133
|
"required": [
|
package/src/endpoint.ts
CHANGED
|
@@ -139,9 +139,9 @@ export class WecomEndpoint extends Endpoint<WecomClient> {
|
|
|
139
139
|
this.#logger.debug(formatCompact({ op: 'disconnect' }));
|
|
140
140
|
}
|
|
141
141
|
|
|
142
|
-
async send({ conversation, payload }: EndpointSendRequest): Promise<string> {
|
|
142
|
+
async send({ conversation, payload, locale }: EndpointSendRequest): Promise<string> {
|
|
143
143
|
const materialized = await this.#materializeOutboundMedia(payload);
|
|
144
|
-
const content = formatOutboundBody(materialized);
|
|
144
|
+
const content = formatOutboundBody(materialized, locale);
|
|
145
145
|
const body = buildSendRequestBody(
|
|
146
146
|
conversation.id,
|
|
147
147
|
content,
|
package/src/protocol.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { createMessages, type Locale } from 'zhin.js/i18n';
|
|
1
2
|
/**
|
|
2
3
|
* WeCom (企业微信) protocol helpers — no legacy Adapter/Endpoint / segment-mapper.
|
|
3
4
|
* Canonicalization is owned by gateway/core before endpoint.send.
|
|
@@ -269,7 +270,9 @@ export function wecomInboundConversation(endpointKey: string, msg: WecomMessage)
|
|
|
269
270
|
/**
|
|
270
271
|
* Wire-encode an already-rendered outbound payload into WeCom message/send body parts.
|
|
271
272
|
*/
|
|
272
|
-
|
|
273
|
+
const outboundMessages = createMessages({ link: { 'zh-CN': '链接', en: 'Link' } });
|
|
274
|
+
|
|
275
|
+
export function formatOutboundBody(payload: unknown, locale?: Locale): WecomSendBody {
|
|
273
276
|
if (typeof payload === 'string') {
|
|
274
277
|
return { msgtype: 'text', data: { content: payload } };
|
|
275
278
|
}
|
|
@@ -320,7 +323,7 @@ export function formatOutboundBody(payload: unknown): WecomSendBody {
|
|
|
320
323
|
mediaType = 'news';
|
|
321
324
|
mediaData = {
|
|
322
325
|
articles: [{
|
|
323
|
-
title: data.title || '
|
|
326
|
+
title: data.title || outboundMessages(locale, 'link'),
|
|
324
327
|
description: data.text || data.content || '',
|
|
325
328
|
url: data.url,
|
|
326
329
|
picurl: data.picUrl,
|