@zhin.js/adapter-telegram 1.0.36 → 1.0.38
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 +16 -0
- package/lib/adapter.d.ts +22 -0
- package/lib/adapter.d.ts.map +1 -0
- package/lib/adapter.js +339 -0
- package/lib/adapter.js.map +1 -0
- package/lib/bot.d.ts +140 -0
- package/lib/bot.d.ts.map +1 -0
- package/lib/bot.js +865 -0
- package/lib/bot.js.map +1 -0
- package/lib/index.d.ts +4 -176
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +9 -1198
- package/lib/index.js.map +1 -1
- package/lib/types.d.ts +29 -0
- package/lib/types.d.ts.map +1 -0
- package/lib/types.js +2 -0
- package/lib/types.js.map +1 -0
- package/package.json +8 -4
- package/skills/telegram/SKILL.md +18 -0
- package/src/adapter.ts +349 -0
- package/src/bot.ts +982 -0
- package/src/index.ts +31 -0
- package/src/types.ts +32 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.0.38
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [bb6bfa8]
|
|
8
|
+
- Updated dependencies [bb6bfa8]
|
|
9
|
+
- zhin.js@1.0.52
|
|
10
|
+
- @zhin.js/logger@0.1.36
|
|
11
|
+
|
|
12
|
+
## 1.0.37
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- zhin.js@1.0.51
|
|
17
|
+
- @zhin.js/logger@0.1.35
|
|
18
|
+
|
|
3
19
|
## 1.0.36
|
|
4
20
|
|
|
5
21
|
### Patch Changes
|
package/lib/adapter.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Telegram 适配器
|
|
3
|
+
*/
|
|
4
|
+
import { Adapter, Plugin } from "zhin.js";
|
|
5
|
+
import { TelegramBot } from "./bot.js";
|
|
6
|
+
import type { TelegramBotConfig } from "./types.js";
|
|
7
|
+
export declare class TelegramAdapter extends Adapter<TelegramBot> {
|
|
8
|
+
constructor(plugin: Plugin);
|
|
9
|
+
createBot(config: TelegramBotConfig): TelegramBot;
|
|
10
|
+
kickMember(botId: string, sceneId: string, userId: string): Promise<boolean>;
|
|
11
|
+
unbanMember(botId: string, sceneId: string, userId: string): Promise<boolean>;
|
|
12
|
+
muteMember(botId: string, sceneId: string, userId: string, duration?: number): Promise<boolean>;
|
|
13
|
+
setAdmin(botId: string, sceneId: string, userId: string, enable?: boolean): Promise<boolean>;
|
|
14
|
+
setGroupName(botId: string, sceneId: string, name: string): Promise<boolean>;
|
|
15
|
+
getGroupInfo(botId: string, sceneId: string): Promise<any>;
|
|
16
|
+
start(): Promise<void>;
|
|
17
|
+
/**
|
|
18
|
+
* 注册 Telegram 平台特有工具(置顶消息等)
|
|
19
|
+
*/
|
|
20
|
+
private registerTelegramPlatformTools;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=adapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../src/adapter.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EACL,OAAO,EACP,MAAM,EAGP,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAEpD,qBAAa,eAAgB,SAAQ,OAAO,CAAC,WAAW,CAAC;gBAC3C,MAAM,EAAE,MAAM;IAI1B,SAAS,CAAC,MAAM,EAAE,iBAAiB,GAAG,WAAW;IAM3C,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;IAMzD,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;IAM1D,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,SAAM;IAMzE,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,UAAO;IAMtE,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM;IAMzD,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM;IAQ3C,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAO5B;;OAEG;IACH,OAAO,CAAC,6BAA6B;CAoRtC"}
|
package/lib/adapter.js
ADDED
|
@@ -0,0 +1,339 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Telegram 适配器
|
|
3
|
+
*/
|
|
4
|
+
import { Adapter, createGroupManagementTools, } from "zhin.js";
|
|
5
|
+
import { TelegramBot } from "./bot.js";
|
|
6
|
+
export class TelegramAdapter extends Adapter {
|
|
7
|
+
constructor(plugin) {
|
|
8
|
+
super(plugin, "telegram", []);
|
|
9
|
+
}
|
|
10
|
+
createBot(config) {
|
|
11
|
+
return new TelegramBot(this, config);
|
|
12
|
+
}
|
|
13
|
+
// ── IGroupManagement 标准群管方法 ──────────────────────────────────
|
|
14
|
+
async kickMember(botId, sceneId, userId) {
|
|
15
|
+
const bot = this.bots.get(botId);
|
|
16
|
+
if (!bot)
|
|
17
|
+
throw new Error(`Bot ${botId} 不存在`);
|
|
18
|
+
return bot.kickMember(Number(sceneId), Number(userId));
|
|
19
|
+
}
|
|
20
|
+
async unbanMember(botId, sceneId, userId) {
|
|
21
|
+
const bot = this.bots.get(botId);
|
|
22
|
+
if (!bot)
|
|
23
|
+
throw new Error(`Bot ${botId} 不存在`);
|
|
24
|
+
return bot.unbanMember(Number(sceneId), Number(userId));
|
|
25
|
+
}
|
|
26
|
+
async muteMember(botId, sceneId, userId, duration = 600) {
|
|
27
|
+
const bot = this.bots.get(botId);
|
|
28
|
+
if (!bot)
|
|
29
|
+
throw new Error(`Bot ${botId} 不存在`);
|
|
30
|
+
return bot.muteMember(Number(sceneId), Number(userId), duration);
|
|
31
|
+
}
|
|
32
|
+
async setAdmin(botId, sceneId, userId, enable = true) {
|
|
33
|
+
const bot = this.bots.get(botId);
|
|
34
|
+
if (!bot)
|
|
35
|
+
throw new Error(`Bot ${botId} 不存在`);
|
|
36
|
+
return bot.setAdmin(Number(sceneId), Number(userId), enable);
|
|
37
|
+
}
|
|
38
|
+
async setGroupName(botId, sceneId, name) {
|
|
39
|
+
const bot = this.bots.get(botId);
|
|
40
|
+
if (!bot)
|
|
41
|
+
throw new Error(`Bot ${botId} 不存在`);
|
|
42
|
+
return bot.setChatTitle(Number(sceneId), name);
|
|
43
|
+
}
|
|
44
|
+
async getGroupInfo(botId, sceneId) {
|
|
45
|
+
const bot = this.bots.get(botId);
|
|
46
|
+
if (!bot)
|
|
47
|
+
throw new Error(`Bot ${botId} 不存在`);
|
|
48
|
+
return bot.getChatInfo(Number(sceneId));
|
|
49
|
+
}
|
|
50
|
+
// ── 生命周期 ───────────────────────────────────────────────────────
|
|
51
|
+
async start() {
|
|
52
|
+
this.registerTelegramPlatformTools();
|
|
53
|
+
const groupTools = createGroupManagementTools(this, this.name);
|
|
54
|
+
groupTools.forEach((t) => this.addTool(t));
|
|
55
|
+
await super.start();
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* 注册 Telegram 平台特有工具(置顶消息等)
|
|
59
|
+
*/
|
|
60
|
+
registerTelegramPlatformTools() {
|
|
61
|
+
// 置顶消息工具
|
|
62
|
+
this.addTool({
|
|
63
|
+
name: 'telegram_pin_message',
|
|
64
|
+
description: '置顶 Telegram 群组消息',
|
|
65
|
+
parameters: {
|
|
66
|
+
type: 'object',
|
|
67
|
+
properties: {
|
|
68
|
+
bot: { type: 'string', description: 'Bot 名称' },
|
|
69
|
+
chat_id: { type: 'number', description: '聊天 ID' },
|
|
70
|
+
message_id: { type: 'number', description: '消息 ID' },
|
|
71
|
+
},
|
|
72
|
+
required: ['bot', 'chat_id', 'message_id'],
|
|
73
|
+
},
|
|
74
|
+
platforms: ['telegram'],
|
|
75
|
+
scopes: ['group'],
|
|
76
|
+
permissionLevel: 'group_admin',
|
|
77
|
+
execute: async (args) => {
|
|
78
|
+
const { bot: botId, chat_id, message_id } = args;
|
|
79
|
+
const bot = this.bots.get(botId);
|
|
80
|
+
if (!bot)
|
|
81
|
+
throw new Error(`Bot ${botId} 不存在`);
|
|
82
|
+
const success = await bot.pinMessage(chat_id, message_id);
|
|
83
|
+
return { success, message: success ? '消息已置顶' : '操作失败' };
|
|
84
|
+
},
|
|
85
|
+
});
|
|
86
|
+
// 取消置顶工具
|
|
87
|
+
this.addTool({
|
|
88
|
+
name: 'telegram_unpin_message',
|
|
89
|
+
description: '取消置顶 Telegram 群组消息',
|
|
90
|
+
parameters: {
|
|
91
|
+
type: 'object',
|
|
92
|
+
properties: {
|
|
93
|
+
bot: { type: 'string', description: 'Bot 名称' },
|
|
94
|
+
chat_id: { type: 'number', description: '聊天 ID' },
|
|
95
|
+
message_id: { type: 'number', description: '消息 ID(可选,不提供则取消所有置顶)' },
|
|
96
|
+
},
|
|
97
|
+
required: ['bot', 'chat_id'],
|
|
98
|
+
},
|
|
99
|
+
platforms: ['telegram'],
|
|
100
|
+
scopes: ['group'],
|
|
101
|
+
permissionLevel: 'group_admin',
|
|
102
|
+
execute: async (args) => {
|
|
103
|
+
const { bot: botId, chat_id, message_id } = args;
|
|
104
|
+
const bot = this.bots.get(botId);
|
|
105
|
+
if (!bot)
|
|
106
|
+
throw new Error(`Bot ${botId} 不存在`);
|
|
107
|
+
const success = await bot.unpinMessage(chat_id, message_id);
|
|
108
|
+
return { success, message: success ? '已取消置顶' : '操作失败' };
|
|
109
|
+
},
|
|
110
|
+
});
|
|
111
|
+
// 获取管理员列表工具
|
|
112
|
+
this.addTool({
|
|
113
|
+
name: 'telegram_list_admins',
|
|
114
|
+
description: '获取 Telegram 群组管理员列表',
|
|
115
|
+
parameters: {
|
|
116
|
+
type: 'object',
|
|
117
|
+
properties: {
|
|
118
|
+
bot: { type: 'string', description: 'Bot 名称' },
|
|
119
|
+
chat_id: { type: 'number', description: '聊天 ID' },
|
|
120
|
+
},
|
|
121
|
+
required: ['bot', 'chat_id'],
|
|
122
|
+
},
|
|
123
|
+
platforms: ['telegram'],
|
|
124
|
+
scopes: ['group'],
|
|
125
|
+
permissionLevel: 'user',
|
|
126
|
+
execute: async (args) => {
|
|
127
|
+
const { bot: botId, chat_id } = args;
|
|
128
|
+
const bot = this.bots.get(botId);
|
|
129
|
+
if (!bot)
|
|
130
|
+
throw new Error(`Bot ${botId} 不存在`);
|
|
131
|
+
const admins = await bot.getChatAdmins(chat_id);
|
|
132
|
+
return {
|
|
133
|
+
admins: admins.map(a => ({
|
|
134
|
+
user_id: a.user.id,
|
|
135
|
+
username: a.user.username,
|
|
136
|
+
first_name: a.user.first_name,
|
|
137
|
+
status: a.status,
|
|
138
|
+
})),
|
|
139
|
+
count: admins.length,
|
|
140
|
+
};
|
|
141
|
+
},
|
|
142
|
+
});
|
|
143
|
+
// 获取成员数量工具
|
|
144
|
+
this.addTool({
|
|
145
|
+
name: 'telegram_member_count',
|
|
146
|
+
description: '获取 Telegram 群组成员数量',
|
|
147
|
+
parameters: {
|
|
148
|
+
type: 'object',
|
|
149
|
+
properties: {
|
|
150
|
+
bot: { type: 'string', description: 'Bot 名称' },
|
|
151
|
+
chat_id: { type: 'number', description: '聊天 ID' },
|
|
152
|
+
},
|
|
153
|
+
required: ['bot', 'chat_id'],
|
|
154
|
+
},
|
|
155
|
+
platforms: ['telegram'],
|
|
156
|
+
scopes: ['group'],
|
|
157
|
+
permissionLevel: 'user',
|
|
158
|
+
execute: async (args) => {
|
|
159
|
+
const { bot: botId, chat_id } = args;
|
|
160
|
+
const bot = this.bots.get(botId);
|
|
161
|
+
if (!bot)
|
|
162
|
+
throw new Error(`Bot ${botId} 不存在`);
|
|
163
|
+
const count = await bot.getChatMemberCount(chat_id);
|
|
164
|
+
return { count, message: `群组共有 ${count} 名成员` };
|
|
165
|
+
},
|
|
166
|
+
});
|
|
167
|
+
// 创建邀请链接工具
|
|
168
|
+
this.addTool({
|
|
169
|
+
name: 'telegram_create_invite',
|
|
170
|
+
description: '创建 Telegram 群组邀请链接',
|
|
171
|
+
parameters: {
|
|
172
|
+
type: 'object',
|
|
173
|
+
properties: {
|
|
174
|
+
bot: { type: 'string', description: 'Bot 名称' },
|
|
175
|
+
chat_id: { type: 'number', description: '聊天 ID' },
|
|
176
|
+
},
|
|
177
|
+
required: ['bot', 'chat_id'],
|
|
178
|
+
},
|
|
179
|
+
platforms: ['telegram'],
|
|
180
|
+
scopes: ['group'],
|
|
181
|
+
permissionLevel: 'group_admin',
|
|
182
|
+
execute: async (args) => {
|
|
183
|
+
const { bot: botId, chat_id } = args;
|
|
184
|
+
const bot = this.bots.get(botId);
|
|
185
|
+
if (!bot)
|
|
186
|
+
throw new Error(`Bot ${botId} 不存在`);
|
|
187
|
+
const link = await bot.createInviteLink(chat_id);
|
|
188
|
+
return { invite_link: link, message: `邀请链接: ${link}` };
|
|
189
|
+
},
|
|
190
|
+
});
|
|
191
|
+
// 发起投票
|
|
192
|
+
this.addTool({
|
|
193
|
+
name: 'telegram_send_poll',
|
|
194
|
+
description: '在 Telegram 群组中发起投票',
|
|
195
|
+
parameters: {
|
|
196
|
+
type: 'object',
|
|
197
|
+
properties: {
|
|
198
|
+
bot: { type: 'string', description: 'Bot 名称' },
|
|
199
|
+
chat_id: { type: 'number', description: '聊天 ID' },
|
|
200
|
+
question: { type: 'string', description: '投票问题' },
|
|
201
|
+
options: { type: 'string', description: '选项,用逗号分隔' },
|
|
202
|
+
is_anonymous: { type: 'boolean', description: '是否匿名投票,默认 true' },
|
|
203
|
+
allows_multiple: { type: 'boolean', description: '是否允许多选,默认 false' },
|
|
204
|
+
},
|
|
205
|
+
required: ['bot', 'chat_id', 'question', 'options'],
|
|
206
|
+
},
|
|
207
|
+
platforms: ['telegram'],
|
|
208
|
+
scopes: ['group'],
|
|
209
|
+
permissionLevel: 'user',
|
|
210
|
+
execute: async (args) => {
|
|
211
|
+
const { bot: botId, chat_id, question, options, is_anonymous = true, allows_multiple = false } = args;
|
|
212
|
+
const bot = this.bots.get(botId);
|
|
213
|
+
if (!bot)
|
|
214
|
+
throw new Error(`Bot ${botId} 不存在`);
|
|
215
|
+
const optList = options.split(',').map((o) => o.trim()).filter(Boolean);
|
|
216
|
+
if (optList.length < 2)
|
|
217
|
+
return { success: false, message: '至少需要 2 个选项' };
|
|
218
|
+
const result = await bot.sendPoll(chat_id, question, optList, is_anonymous, allows_multiple);
|
|
219
|
+
return { success: true, message_id: result.message_id, message: '投票已发送' };
|
|
220
|
+
},
|
|
221
|
+
});
|
|
222
|
+
// 消息表情反应
|
|
223
|
+
this.addTool({
|
|
224
|
+
name: 'telegram_react',
|
|
225
|
+
description: '对 Telegram 消息添加表情反应',
|
|
226
|
+
parameters: {
|
|
227
|
+
type: 'object',
|
|
228
|
+
properties: {
|
|
229
|
+
bot: { type: 'string', description: 'Bot 名称' },
|
|
230
|
+
chat_id: { type: 'number', description: '聊天 ID' },
|
|
231
|
+
message_id: { type: 'number', description: '消息 ID' },
|
|
232
|
+
reaction: { type: 'string', description: '反应表情(如 👍、❤️、🔥)' },
|
|
233
|
+
},
|
|
234
|
+
required: ['bot', 'chat_id', 'message_id', 'reaction'],
|
|
235
|
+
},
|
|
236
|
+
platforms: ['telegram'],
|
|
237
|
+
scopes: ['group', 'private'],
|
|
238
|
+
permissionLevel: 'user',
|
|
239
|
+
execute: async (args) => {
|
|
240
|
+
const { bot: botId, chat_id, message_id, reaction } = args;
|
|
241
|
+
const bot = this.bots.get(botId);
|
|
242
|
+
if (!bot)
|
|
243
|
+
throw new Error(`Bot ${botId} 不存在`);
|
|
244
|
+
const success = await bot.setMessageReaction(chat_id, message_id, reaction);
|
|
245
|
+
return { success, message: success ? `已添加反应 ${reaction}` : '操作失败' };
|
|
246
|
+
},
|
|
247
|
+
});
|
|
248
|
+
// 发送贴纸
|
|
249
|
+
this.addTool({
|
|
250
|
+
name: 'telegram_send_sticker',
|
|
251
|
+
description: '发送 Telegram 贴纸',
|
|
252
|
+
parameters: {
|
|
253
|
+
type: 'object',
|
|
254
|
+
properties: {
|
|
255
|
+
bot: { type: 'string', description: 'Bot 名称' },
|
|
256
|
+
chat_id: { type: 'number', description: '聊天 ID' },
|
|
257
|
+
sticker: { type: 'string', description: '贴纸 file_id 或 URL' },
|
|
258
|
+
},
|
|
259
|
+
required: ['bot', 'chat_id', 'sticker'],
|
|
260
|
+
},
|
|
261
|
+
platforms: ['telegram'],
|
|
262
|
+
scopes: ['group', 'private'],
|
|
263
|
+
permissionLevel: 'user',
|
|
264
|
+
execute: async (args) => {
|
|
265
|
+
const { bot: botId, chat_id, sticker } = args;
|
|
266
|
+
const bot = this.bots.get(botId);
|
|
267
|
+
if (!bot)
|
|
268
|
+
throw new Error(`Bot ${botId} 不存在`);
|
|
269
|
+
const result = await bot.sendStickerMessage(chat_id, sticker);
|
|
270
|
+
return { success: true, message_id: result.message_id, message: '贴纸已发送' };
|
|
271
|
+
},
|
|
272
|
+
});
|
|
273
|
+
// 设置群权限
|
|
274
|
+
this.addTool({
|
|
275
|
+
name: 'telegram_set_permissions',
|
|
276
|
+
description: '设置 Telegram 群组的默认成员权限',
|
|
277
|
+
parameters: {
|
|
278
|
+
type: 'object',
|
|
279
|
+
properties: {
|
|
280
|
+
bot: { type: 'string', description: 'Bot 名称' },
|
|
281
|
+
chat_id: { type: 'number', description: '聊天 ID' },
|
|
282
|
+
can_send_messages: { type: 'boolean', description: '是否可以发消息' },
|
|
283
|
+
can_send_photos: { type: 'boolean', description: '是否可以发图片' },
|
|
284
|
+
can_send_videos: { type: 'boolean', description: '是否可以发视频' },
|
|
285
|
+
can_send_polls: { type: 'boolean', description: '是否可以发投票' },
|
|
286
|
+
can_send_other_messages: { type: 'boolean', description: '是否可以发贴纸/GIF等' },
|
|
287
|
+
can_add_web_page_previews: { type: 'boolean', description: '是否可以添加网页预览' },
|
|
288
|
+
can_change_info: { type: 'boolean', description: '是否可以改群信息' },
|
|
289
|
+
can_invite_users: { type: 'boolean', description: '是否可以邀请用户' },
|
|
290
|
+
can_pin_messages: { type: 'boolean', description: '是否可以置顶消息' },
|
|
291
|
+
},
|
|
292
|
+
required: ['bot', 'chat_id'],
|
|
293
|
+
},
|
|
294
|
+
platforms: ['telegram'],
|
|
295
|
+
scopes: ['group'],
|
|
296
|
+
permissionLevel: 'group_admin',
|
|
297
|
+
execute: async (args) => {
|
|
298
|
+
const { bot: botId, chat_id, ...perms } = args;
|
|
299
|
+
const bot = this.bots.get(botId);
|
|
300
|
+
if (!bot)
|
|
301
|
+
throw new Error(`Bot ${botId} 不存在`);
|
|
302
|
+
const permissions = {};
|
|
303
|
+
for (const [k, v] of Object.entries(perms)) {
|
|
304
|
+
if (typeof v === 'boolean')
|
|
305
|
+
permissions[k] = v;
|
|
306
|
+
}
|
|
307
|
+
const success = await bot.setChatPermissionsAll(chat_id, permissions);
|
|
308
|
+
return { success, message: success ? '群权限已更新' : '操作失败' };
|
|
309
|
+
},
|
|
310
|
+
});
|
|
311
|
+
// 设置群描述
|
|
312
|
+
this.addTool({
|
|
313
|
+
name: 'telegram_set_description',
|
|
314
|
+
description: '设置 Telegram 群组描述',
|
|
315
|
+
parameters: {
|
|
316
|
+
type: 'object',
|
|
317
|
+
properties: {
|
|
318
|
+
bot: { type: 'string', description: 'Bot 名称' },
|
|
319
|
+
chat_id: { type: 'number', description: '聊天 ID' },
|
|
320
|
+
description: { type: 'string', description: '群描述文字' },
|
|
321
|
+
},
|
|
322
|
+
required: ['bot', 'chat_id', 'description'],
|
|
323
|
+
},
|
|
324
|
+
platforms: ['telegram'],
|
|
325
|
+
scopes: ['group'],
|
|
326
|
+
permissionLevel: 'group_admin',
|
|
327
|
+
execute: async (args) => {
|
|
328
|
+
const { bot: botId, chat_id, description } = args;
|
|
329
|
+
const bot = this.bots.get(botId);
|
|
330
|
+
if (!bot)
|
|
331
|
+
throw new Error(`Bot ${botId} 不存在`);
|
|
332
|
+
const success = await bot.setChatDescription(chat_id, description);
|
|
333
|
+
return { success, message: success ? '群描述已更新' : '操作失败' };
|
|
334
|
+
},
|
|
335
|
+
});
|
|
336
|
+
this.plugin.logger.debug('已注册 Telegram 平台群组管理工具');
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
//# sourceMappingURL=adapter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adapter.js","sourceRoot":"","sources":["../src/adapter.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EACL,OAAO,EAEP,0BAA0B,GAE3B,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAGvC,MAAM,OAAO,eAAgB,SAAQ,OAAoB;IACvD,YAAY,MAAc;QACxB,KAAK,CAAC,MAAM,EAAE,UAAU,EAAE,EAAE,CAAC,CAAC;IAChC,CAAC;IAED,SAAS,CAAC,MAAyB;QACjC,OAAO,IAAI,WAAW,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IACvC,CAAC;IAED,gEAAgE;IAEhE,KAAK,CAAC,UAAU,CAAC,KAAa,EAAE,OAAe,EAAE,MAAc;QAC7D,MAAM,GAAG,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QACjC,IAAI,CAAC,GAAG;YAAE,MAAM,IAAI,KAAK,CAAC,OAAO,KAAK,MAAM,CAAC,CAAC;QAC9C,OAAO,GAAG,CAAC,UAAU,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC;IACzD,CAAC;IAED,KAAK,CAAC,WAAW,CAAC,KAAa,EAAE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AAE,WAAW,EAAE,OAAO,EAAE;iBACtD;gBACD,QAAQ,EAAE,CAAC,KAAK,EAAE,SAAS,EAAE,aAAa,CAAC;aAC5C;YACD,SAAS,EAAE,CAAC,UAAU,CAAC;YACvB,MAAM,EAAE,CAAC,OAAO,CAAC;YACjB,eAAe,EAAE,aAAa;YAC9B,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE;gBACtB,MAAM,EAAE,GAAG,EAAE,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,GAAG,IAAI,CAAC;gBAClD,MAAM,GAAG,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;gBACjC,IAAI,CAAC,GAAG;oBAAE,MAAM,IAAI,KAAK,CAAC,OAAO,KAAK,MAAM,CAAC,CAAC;gBAC9C,MAAM,OAAO,GAAG,MAAM,GAAG,CAAC,kBAAkB,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC;gBACnE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;YAC3D,CAAC;SACF,CAAC,CAAC;QAEH,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,uBAAuB,CAAC,CAAC;IACpD,CAAC;CACF"}
|
package/lib/bot.d.ts
ADDED
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Telegram Bot 实现
|
|
3
|
+
*/
|
|
4
|
+
import { Telegraf } from "telegraf";
|
|
5
|
+
import type { Message as TelegramMessage, ChatMember } from "telegraf/types";
|
|
6
|
+
import { Bot, Message, SendOptions } from "zhin.js";
|
|
7
|
+
import type { TelegramBotConfig } from "./types.js";
|
|
8
|
+
import type { TelegramAdapter } from "./adapter.js";
|
|
9
|
+
export declare class TelegramBot extends Telegraf implements Bot<TelegramBotConfig, TelegramMessage> {
|
|
10
|
+
adapter: TelegramAdapter;
|
|
11
|
+
$config: TelegramBotConfig;
|
|
12
|
+
$connected: boolean;
|
|
13
|
+
get pluginLogger(): import("zhin.js").Logger;
|
|
14
|
+
get $id(): string;
|
|
15
|
+
constructor(adapter: TelegramAdapter, $config: TelegramBotConfig);
|
|
16
|
+
$connect(): Promise<void>;
|
|
17
|
+
$disconnect(): Promise<void>;
|
|
18
|
+
private handleTelegramMessage;
|
|
19
|
+
$formatMessage(msg: TelegramMessage): Message<TelegramMessage>;
|
|
20
|
+
private $formatCallbackQuery;
|
|
21
|
+
private parseMessageContent;
|
|
22
|
+
private parseTextWithEntities;
|
|
23
|
+
$sendMessage(options: SendOptions): Promise<string>;
|
|
24
|
+
private sendContentToChat;
|
|
25
|
+
$recallMessage(id: string): Promise<void>;
|
|
26
|
+
/**
|
|
27
|
+
* 踢出用户
|
|
28
|
+
* @param chatId 聊天 ID
|
|
29
|
+
* @param userId 用户 ID
|
|
30
|
+
* @param untilDate 封禁截止时间(Unix 时间戳),0 表示永久
|
|
31
|
+
*/
|
|
32
|
+
kickMember(chatId: number, userId: number, untilDate?: number): Promise<boolean>;
|
|
33
|
+
/**
|
|
34
|
+
* 解除封禁
|
|
35
|
+
* @param chatId 聊天 ID
|
|
36
|
+
* @param userId 用户 ID
|
|
37
|
+
*/
|
|
38
|
+
unbanMember(chatId: number, userId: number): Promise<boolean>;
|
|
39
|
+
/**
|
|
40
|
+
* 限制用户权限(禁言等)
|
|
41
|
+
* @param chatId 聊天 ID
|
|
42
|
+
* @param userId 用户 ID
|
|
43
|
+
* @param permissions 权限设置
|
|
44
|
+
* @param untilDate 限制截止时间
|
|
45
|
+
*/
|
|
46
|
+
restrictMember(chatId: number, userId: number, permissions: {
|
|
47
|
+
can_send_messages?: boolean;
|
|
48
|
+
can_send_media_messages?: boolean;
|
|
49
|
+
can_send_polls?: boolean;
|
|
50
|
+
can_send_other_messages?: boolean;
|
|
51
|
+
can_add_web_page_previews?: boolean;
|
|
52
|
+
can_change_info?: boolean;
|
|
53
|
+
can_invite_users?: boolean;
|
|
54
|
+
can_pin_messages?: boolean;
|
|
55
|
+
}, untilDate?: number): Promise<boolean>;
|
|
56
|
+
/**
|
|
57
|
+
* 禁言用户
|
|
58
|
+
* @param chatId 聊天 ID
|
|
59
|
+
* @param userId 用户 ID
|
|
60
|
+
* @param duration 禁言时长(秒),0 表示解除禁言
|
|
61
|
+
*/
|
|
62
|
+
muteMember(chatId: number, userId: number, duration?: number): Promise<boolean>;
|
|
63
|
+
/**
|
|
64
|
+
* 提升/降级管理员
|
|
65
|
+
* @param chatId 聊天 ID
|
|
66
|
+
* @param userId 用户 ID
|
|
67
|
+
* @param promote 是否提升为管理员
|
|
68
|
+
*/
|
|
69
|
+
setAdmin(chatId: number, userId: number, promote?: boolean): Promise<boolean>;
|
|
70
|
+
/**
|
|
71
|
+
* 设置聊天标题
|
|
72
|
+
* @param chatId 聊天 ID
|
|
73
|
+
* @param title 新标题
|
|
74
|
+
*/
|
|
75
|
+
setChatTitle(chatId: number, title: string): Promise<boolean>;
|
|
76
|
+
/**
|
|
77
|
+
* 设置聊天描述
|
|
78
|
+
* @param chatId 聊天 ID
|
|
79
|
+
* @param description 新描述
|
|
80
|
+
*/
|
|
81
|
+
setChatDescription(chatId: number, description: string): Promise<boolean>;
|
|
82
|
+
/**
|
|
83
|
+
* 置顶消息
|
|
84
|
+
* @param chatId 聊天 ID
|
|
85
|
+
* @param messageId 消息 ID
|
|
86
|
+
*/
|
|
87
|
+
pinMessage(chatId: number, messageId: number): Promise<boolean>;
|
|
88
|
+
/**
|
|
89
|
+
* 取消置顶消息
|
|
90
|
+
* @param chatId 聊天 ID
|
|
91
|
+
* @param messageId 消息 ID(可选,不提供则取消所有置顶)
|
|
92
|
+
*/
|
|
93
|
+
unpinMessage(chatId: number, messageId?: number): Promise<boolean>;
|
|
94
|
+
/**
|
|
95
|
+
* 获取聊天信息
|
|
96
|
+
* @param chatId 聊天 ID
|
|
97
|
+
*/
|
|
98
|
+
getChatInfo(chatId: number): Promise<any>;
|
|
99
|
+
/**
|
|
100
|
+
* 获取聊天成员
|
|
101
|
+
* @param chatId 聊天 ID
|
|
102
|
+
* @param userId 用户 ID
|
|
103
|
+
*/
|
|
104
|
+
getChatMember(chatId: number, userId: number): Promise<ChatMember>;
|
|
105
|
+
/**
|
|
106
|
+
* 获取管理员列表
|
|
107
|
+
* @param chatId 聊天 ID
|
|
108
|
+
*/
|
|
109
|
+
getChatAdmins(chatId: number): Promise<ChatMember[]>;
|
|
110
|
+
/**
|
|
111
|
+
* 获取聊天成员数量
|
|
112
|
+
* @param chatId 聊天 ID
|
|
113
|
+
*/
|
|
114
|
+
getChatMemberCount(chatId: number): Promise<number>;
|
|
115
|
+
/**
|
|
116
|
+
* 创建邀请链接
|
|
117
|
+
* @param chatId 聊天 ID
|
|
118
|
+
*/
|
|
119
|
+
createInviteLink(chatId: number): Promise<string>;
|
|
120
|
+
sendPoll(chatId: number, question: string, options: string[], isAnonymous?: boolean, allowsMultipleAnswers?: boolean): Promise<TelegramMessage>;
|
|
121
|
+
setMessageReaction(chatId: number, messageId: number, reaction: string): Promise<boolean>;
|
|
122
|
+
sendStickerMessage(chatId: number, sticker: string): Promise<TelegramMessage>;
|
|
123
|
+
setChatPermissionsAll(chatId: number, permissions: {
|
|
124
|
+
can_send_messages?: boolean;
|
|
125
|
+
can_send_audios?: boolean;
|
|
126
|
+
can_send_documents?: boolean;
|
|
127
|
+
can_send_photos?: boolean;
|
|
128
|
+
can_send_videos?: boolean;
|
|
129
|
+
can_send_video_notes?: boolean;
|
|
130
|
+
can_send_voice_notes?: boolean;
|
|
131
|
+
can_send_polls?: boolean;
|
|
132
|
+
can_send_other_messages?: boolean;
|
|
133
|
+
can_add_web_page_previews?: boolean;
|
|
134
|
+
can_change_info?: boolean;
|
|
135
|
+
can_invite_users?: boolean;
|
|
136
|
+
can_pin_messages?: boolean;
|
|
137
|
+
can_manage_topics?: boolean;
|
|
138
|
+
}): Promise<boolean>;
|
|
139
|
+
}
|
|
140
|
+
//# sourceMapp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