@zhin.js/adapter-telegram 6.0.5 → 6.0.6
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 +19 -0
- package/lib/endpoint.d.ts +1 -0
- package/lib/endpoint.js +13 -1
- package/package.json +4 -4
- package/src/endpoint.ts +11 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 6.0.6
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- d52f3c5: fix: QQ 适配器群聊误识别为私聊、game-kit 启动崩溃、全面补齐 recallMessage
|
|
8
|
+
|
|
9
|
+
- fix(cli): `resolveChannelType` 增加 `metadata.channelKind` 检查,修复 QQ/Discord/KOOK 群聊消息被误分类为私聊
|
|
10
|
+
- fix(game-kit): `createHostGameDb` 改用延迟代理模型,避免数据库启动前解析模型导致崩溃
|
|
11
|
+
- feat(qq): 实现 `recallMessage`,解析复合 messageId 路由到对应 SDK 撤回方法;`normalizeQqMessage` 增加 `message_type` 缺失时的回退检测
|
|
12
|
+
- feat(slack): 实现 `recallMessage`,利用已有 compound ref 和 `chat.delete` API
|
|
13
|
+
- feat(onebot11): 两个 endpoint 类实现 `recallMessage`(`delete_msg`)
|
|
14
|
+
- feat(onebot12): 两个 endpoint 类实现 `recallMessage`(`delete_message`)
|
|
15
|
+
- feat(napcat): 三个 endpoint 类实现 `recallMessage`(`delete_msg`)
|
|
16
|
+
- feat(discord): 两个 endpoint 类实现 `recallMessage`;`send()` 改为返回 `channelId:snowflake` 复合 ID
|
|
17
|
+
- feat(telegram): 实现 `recallMessage`(`deleteMessage`);`send()` 改为返回 `chatId:messageId` 复合 ID
|
|
18
|
+
- feat(kook): 两个 endpoint 类实现 `recallMessage`,利用 kook-client `recallMsg` API
|
|
19
|
+
- feat(lark): 实现 `recallMessage`(`DELETE /im/v1/messages/{id}`)
|
|
20
|
+
- feat(wecom): 实现 `recallMessage`(`POST /cgi-bin/message/recall`)
|
|
21
|
+
|
|
3
22
|
## 6.0.5
|
|
4
23
|
|
|
5
24
|
### Patch Changes
|
package/lib/endpoint.d.ts
CHANGED
|
@@ -43,6 +43,7 @@ export declare class TelegramEndpoint implements EndpointInstance {
|
|
|
43
43
|
readonly target: string;
|
|
44
44
|
readonly payload: unknown;
|
|
45
45
|
}): Promise<string>;
|
|
46
|
+
recallMessage(messageId: string): Promise<void>;
|
|
46
47
|
/** Test / internal: admit a message when open. */
|
|
47
48
|
admit(msg: TelegramMessage): void;
|
|
48
49
|
/** Test / internal: admit a callback query when open. */
|
package/lib/endpoint.js
CHANGED
|
@@ -138,7 +138,19 @@ export class TelegramEndpoint {
|
|
|
138
138
|
if (result.message_id != null)
|
|
139
139
|
lastId = String(result.message_id);
|
|
140
140
|
}
|
|
141
|
-
|
|
141
|
+
if (!lastId)
|
|
142
|
+
return `telegram-${Date.now()}`;
|
|
143
|
+
return `${target}:${lastId}`;
|
|
144
|
+
}
|
|
145
|
+
async recallMessage(messageId) {
|
|
146
|
+
if (!messageId || messageId.startsWith('telegram-'))
|
|
147
|
+
return;
|
|
148
|
+
const colon = messageId.indexOf(':');
|
|
149
|
+
if (colon <= 0)
|
|
150
|
+
return;
|
|
151
|
+
const chatId = messageId.slice(0, colon);
|
|
152
|
+
const msgId = messageId.slice(colon + 1);
|
|
153
|
+
await this.callApi('deleteMessage', { chat_id: chatId, message_id: Number(msgId) });
|
|
142
154
|
}
|
|
143
155
|
/**
|
|
144
156
|
* 含 `attach://` 占位的媒体参数 → multipart/form-data:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zhin.js/adapter-telegram",
|
|
3
|
-
"version": "6.0.
|
|
3
|
+
"version": "6.0.6",
|
|
4
4
|
"description": "Zhin.js Telegram Bot API adapter for Plugin Runtime (long-poll getUpdates)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./lib/index.js",
|
|
@@ -33,8 +33,8 @@
|
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@zhin.js/adapter": "1.1.2",
|
|
36
|
-
"@zhin.js/command": "1.0.4",
|
|
37
36
|
"@zhin.js/core": "1.4.3",
|
|
37
|
+
"@zhin.js/command": "1.0.4",
|
|
38
38
|
"@zhin.js/host-http": "1.0.4",
|
|
39
39
|
"@zhin.js/logger": "1.0.75",
|
|
40
40
|
"@zhin.js/plugin-runtime": "1.1.1"
|
|
@@ -63,9 +63,9 @@
|
|
|
63
63
|
"typescript": "^6.0.3",
|
|
64
64
|
"vitest": "^4.1.10",
|
|
65
65
|
"zod": "^4.4.3",
|
|
66
|
-
"@zhin.js/agent": "1.0.10",
|
|
67
66
|
"@zhin.js/host-http": "1.0.4",
|
|
68
|
-
"zhin.js": "5.0.3"
|
|
67
|
+
"zhin.js": "5.0.3",
|
|
68
|
+
"@zhin.js/agent": "1.0.10"
|
|
69
69
|
},
|
|
70
70
|
"files": [
|
|
71
71
|
"adapters",
|
package/src/endpoint.ts
CHANGED
|
@@ -209,7 +209,17 @@ export class TelegramEndpoint implements EndpointInstance {
|
|
|
209
209
|
: await this.callApi<{ message_id?: number }>(action.method, action.params);
|
|
210
210
|
if (result.message_id != null) lastId = String(result.message_id);
|
|
211
211
|
}
|
|
212
|
-
|
|
212
|
+
if (!lastId) return `telegram-${Date.now()}`;
|
|
213
|
+
return `${target}:${lastId}`;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
async recallMessage(messageId: string): Promise<void> {
|
|
217
|
+
if (!messageId || messageId.startsWith('telegram-')) return;
|
|
218
|
+
const colon = messageId.indexOf(':');
|
|
219
|
+
if (colon <= 0) return;
|
|
220
|
+
const chatId = messageId.slice(0, colon);
|
|
221
|
+
const msgId = messageId.slice(colon + 1);
|
|
222
|
+
await this.callApi('deleteMessage', { chat_id: chatId, message_id: Number(msgId) });
|
|
213
223
|
}
|
|
214
224
|
|
|
215
225
|
/**
|