@zhin.js/adapter-slack 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 +14 -0
- package/lib/adapter.d.ts +20 -0
- package/lib/adapter.d.ts.map +1 -0
- package/lib/adapter.js +310 -0
- package/lib/adapter.js.map +1 -0
- package/lib/bot.d.ts +104 -0
- package/lib/bot.d.ts.map +1 -0
- package/lib/bot.js +620 -0
- package/lib/bot.js.map +1 -0
- package/lib/index.d.ts +4 -130
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +9 -925
- package/lib/index.js.map +1 -1
- package/lib/types.d.ts +17 -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 +7 -3
- package/skills/slack/SKILL.md +17 -0
- package/src/adapter.ts +321 -0
- package/src/bot.ts +691 -0
- package/src/index.ts +31 -0
- package/src/types.ts +18 -0
package/lib/bot.js
ADDED
|
@@ -0,0 +1,620 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Slack Bot 实现
|
|
3
|
+
*/
|
|
4
|
+
import { App as SlackApp, LogLevel } from "@slack/bolt";
|
|
5
|
+
import { WebClient } from "@slack/web-api";
|
|
6
|
+
import { Message, segment, } from "zhin.js";
|
|
7
|
+
export class SlackBot {
|
|
8
|
+
adapter;
|
|
9
|
+
$config;
|
|
10
|
+
$connected;
|
|
11
|
+
app;
|
|
12
|
+
client;
|
|
13
|
+
get logger() {
|
|
14
|
+
return this.adapter.plugin.logger;
|
|
15
|
+
}
|
|
16
|
+
get $id() {
|
|
17
|
+
return this.$config.name;
|
|
18
|
+
}
|
|
19
|
+
constructor(adapter, $config) {
|
|
20
|
+
this.adapter = adapter;
|
|
21
|
+
this.$config = $config;
|
|
22
|
+
this.$connected = false;
|
|
23
|
+
// Initialize Slack app
|
|
24
|
+
if ($config.socketMode && $config.appToken) {
|
|
25
|
+
// Socket Mode
|
|
26
|
+
this.app = new SlackApp({
|
|
27
|
+
token: $config.token,
|
|
28
|
+
signingSecret: $config.signingSecret,
|
|
29
|
+
appToken: $config.appToken,
|
|
30
|
+
socketMode: true,
|
|
31
|
+
logLevel: $config.logLevel || LogLevel.INFO,
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
// HTTP Mode
|
|
36
|
+
this.app = new SlackApp({
|
|
37
|
+
token: $config.token,
|
|
38
|
+
signingSecret: $config.signingSecret,
|
|
39
|
+
socketMode: false,
|
|
40
|
+
logLevel: $config.logLevel || LogLevel.INFO,
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
this.client = new WebClient($config.token);
|
|
44
|
+
}
|
|
45
|
+
async $connect() {
|
|
46
|
+
try {
|
|
47
|
+
// Set up message event handler
|
|
48
|
+
this.app.message(async ({ message, say }) => {
|
|
49
|
+
await this.handleSlackMessage(message);
|
|
50
|
+
});
|
|
51
|
+
// Set up app mention handler
|
|
52
|
+
this.app.event("app_mention", async ({ event, say }) => {
|
|
53
|
+
await this.handleSlackMessage(event);
|
|
54
|
+
});
|
|
55
|
+
// Start the app
|
|
56
|
+
const port = this.$config.port || 3000;
|
|
57
|
+
if (this.$config.socketMode) {
|
|
58
|
+
await this.app.start();
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
await this.app.start(port);
|
|
62
|
+
}
|
|
63
|
+
this.$connected = true;
|
|
64
|
+
// Get bot info
|
|
65
|
+
const authTest = await this.client.auth.test();
|
|
66
|
+
this.logger.info(`Slack bot ${this.$config.name} connected successfully as @${authTest.user}`);
|
|
67
|
+
if (!this.$config.socketMode) {
|
|
68
|
+
this.logger.info(`Slack bot listening on port ${port}`);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
catch (error) {
|
|
72
|
+
this.logger.error("Failed to connect Slack bot:", error);
|
|
73
|
+
this.$connected = false;
|
|
74
|
+
throw error;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
async $disconnect() {
|
|
78
|
+
try {
|
|
79
|
+
await this.app.stop();
|
|
80
|
+
this.$connected = false;
|
|
81
|
+
this.logger.info(`Slack bot ${this.$config.name} disconnected`);
|
|
82
|
+
}
|
|
83
|
+
catch (error) {
|
|
84
|
+
this.logger.error("Error disconnecting Slack bot:", error);
|
|
85
|
+
throw error;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
async handleSlackMessage(msg) {
|
|
89
|
+
// Ignore bot messages and message changes
|
|
90
|
+
if ("subtype" in msg && (msg.subtype === "bot_message" || msg.subtype === "message_changed")) {
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
const message = this.$formatMessage(msg);
|
|
94
|
+
this.adapter.emit("message.receive", message);
|
|
95
|
+
this.logger.debug(`${this.$config.name} recv ${message.$channel.type}(${message.$channel.id}): ${segment.raw(message.$content)}`);
|
|
96
|
+
}
|
|
97
|
+
$formatMessage(msg) {
|
|
98
|
+
// Determine channel type based on channel ID
|
|
99
|
+
const channelType = "channel_type" in msg && msg.channel_type === "im" ? "private" : "group";
|
|
100
|
+
const channelId = msg.channel;
|
|
101
|
+
// Parse message content
|
|
102
|
+
const content = this.parseMessageContent(msg);
|
|
103
|
+
// Extract user info safely
|
|
104
|
+
const userId = ("user" in msg ? msg.user : "") || "";
|
|
105
|
+
const userName = ("username" in msg ? msg.username : null) || userId || "Unknown";
|
|
106
|
+
const messageText = ("text" in msg ? msg.text : "") || "";
|
|
107
|
+
const result = Message.from(msg, {
|
|
108
|
+
$id: msg.ts,
|
|
109
|
+
$adapter: "slack",
|
|
110
|
+
$bot: this.$config.name,
|
|
111
|
+
$sender: {
|
|
112
|
+
id: userId,
|
|
113
|
+
name: userName,
|
|
114
|
+
},
|
|
115
|
+
$channel: {
|
|
116
|
+
id: channelId,
|
|
117
|
+
type: channelType,
|
|
118
|
+
},
|
|
119
|
+
$content: content,
|
|
120
|
+
$raw: messageText,
|
|
121
|
+
$timestamp: parseFloat(msg.ts) * 1000,
|
|
122
|
+
$recall: async () => {
|
|
123
|
+
try {
|
|
124
|
+
await this.client.chat.delete({
|
|
125
|
+
channel: channelId,
|
|
126
|
+
ts: result.$id,
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
catch (error) {
|
|
130
|
+
this.logger.error("Error recalling Slack message:", error);
|
|
131
|
+
throw error;
|
|
132
|
+
}
|
|
133
|
+
},
|
|
134
|
+
$reply: async (content, quote) => {
|
|
135
|
+
if (!Array.isArray(content))
|
|
136
|
+
content = [content];
|
|
137
|
+
const sendOptions = {
|
|
138
|
+
channel: channelId,
|
|
139
|
+
};
|
|
140
|
+
// Handle thread reply
|
|
141
|
+
if (quote) {
|
|
142
|
+
const threadTs = typeof quote === "boolean" ? result.$id : quote;
|
|
143
|
+
sendOptions.thread_ts = threadTs;
|
|
144
|
+
}
|
|
145
|
+
return await this.adapter.sendMessage({
|
|
146
|
+
context: "slack",
|
|
147
|
+
bot: this.$config.name,
|
|
148
|
+
id: channelId,
|
|
149
|
+
type: "channel",
|
|
150
|
+
content: content,
|
|
151
|
+
});
|
|
152
|
+
},
|
|
153
|
+
});
|
|
154
|
+
return result;
|
|
155
|
+
}
|
|
156
|
+
parseMessageContent(msg) {
|
|
157
|
+
const segments = [];
|
|
158
|
+
// Handle text
|
|
159
|
+
if ("text" in msg && msg.text) {
|
|
160
|
+
// Parse Slack formatting
|
|
161
|
+
segments.push(...this.parseSlackText(msg.text));
|
|
162
|
+
}
|
|
163
|
+
// Handle files
|
|
164
|
+
if ("files" in msg && msg.files) {
|
|
165
|
+
for (const file of msg.files) {
|
|
166
|
+
if (file.mimetype?.startsWith("image/")) {
|
|
167
|
+
segments.push({
|
|
168
|
+
type: "image",
|
|
169
|
+
data: {
|
|
170
|
+
id: file.id,
|
|
171
|
+
name: file.name,
|
|
172
|
+
url: file.url_private || file.permalink,
|
|
173
|
+
size: file.size,
|
|
174
|
+
mimetype: file.mimetype,
|
|
175
|
+
},
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
else if (file.mimetype?.startsWith("video/")) {
|
|
179
|
+
segments.push({
|
|
180
|
+
type: "video",
|
|
181
|
+
data: {
|
|
182
|
+
id: file.id,
|
|
183
|
+
name: file.name,
|
|
184
|
+
url: file.url_private || file.permalink,
|
|
185
|
+
size: file.size,
|
|
186
|
+
mimetype: file.mimetype,
|
|
187
|
+
},
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
else if (file.mimetype?.startsWith("audio/")) {
|
|
191
|
+
segments.push({
|
|
192
|
+
type: "audio",
|
|
193
|
+
data: {
|
|
194
|
+
id: file.id,
|
|
195
|
+
name: file.name,
|
|
196
|
+
url: file.url_private || file.permalink,
|
|
197
|
+
size: file.size,
|
|
198
|
+
mimetype: file.mimetype,
|
|
199
|
+
},
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
else {
|
|
203
|
+
segments.push({
|
|
204
|
+
type: "file",
|
|
205
|
+
data: {
|
|
206
|
+
id: file.id,
|
|
207
|
+
name: file.name,
|
|
208
|
+
url: file.url_private || file.permalink,
|
|
209
|
+
size: file.size,
|
|
210
|
+
mimetype: file.mimetype,
|
|
211
|
+
},
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
// Handle attachments
|
|
217
|
+
if ("attachments" in msg && msg.attachments) {
|
|
218
|
+
for (const attachment of msg.attachments) {
|
|
219
|
+
if (attachment.image_url) {
|
|
220
|
+
segments.push({
|
|
221
|
+
type: "image",
|
|
222
|
+
data: {
|
|
223
|
+
url: attachment.image_url,
|
|
224
|
+
title: attachment.title,
|
|
225
|
+
text: attachment.text,
|
|
226
|
+
},
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
return segments.length > 0
|
|
232
|
+
? segments
|
|
233
|
+
: [{ type: "text", data: { text: "" } }];
|
|
234
|
+
}
|
|
235
|
+
parseSlackText(text) {
|
|
236
|
+
const segments = [];
|
|
237
|
+
let lastIndex = 0;
|
|
238
|
+
// Match user mentions <@U12345678>
|
|
239
|
+
const userMentionRegex = /<@([UW][A-Z0-9]+)(?:\|([^>]+))?>/g;
|
|
240
|
+
// Match channel mentions <#C12345678|general>
|
|
241
|
+
const channelMentionRegex = /<#([C][A-Z0-9]+)(?:\|([^>]+))?>/g;
|
|
242
|
+
// Match links <http://example.com|Example>
|
|
243
|
+
const linkRegex = /<(https?:\/\/[^|>]+)(?:\|([^>]+))?>/g;
|
|
244
|
+
const allMatches = [];
|
|
245
|
+
// Collect all matches
|
|
246
|
+
let match;
|
|
247
|
+
while ((match = userMentionRegex.exec(text)) !== null) {
|
|
248
|
+
allMatches.push({ match, type: "user" });
|
|
249
|
+
}
|
|
250
|
+
while ((match = channelMentionRegex.exec(text)) !== null) {
|
|
251
|
+
allMatches.push({ match, type: "channel" });
|
|
252
|
+
}
|
|
253
|
+
while ((match = linkRegex.exec(text)) !== null) {
|
|
254
|
+
allMatches.push({ match, type: "link" });
|
|
255
|
+
}
|
|
256
|
+
// Sort by position
|
|
257
|
+
allMatches.sort((a, b) => a.match.index - b.match.index);
|
|
258
|
+
// Process matches
|
|
259
|
+
for (const { match, type } of allMatches) {
|
|
260
|
+
const matchStart = match.index;
|
|
261
|
+
const matchEnd = matchStart + match[0].length;
|
|
262
|
+
// Add text before match
|
|
263
|
+
if (matchStart > lastIndex) {
|
|
264
|
+
const beforeText = text.slice(lastIndex, matchStart);
|
|
265
|
+
if (beforeText.trim()) {
|
|
266
|
+
segments.push({ type: "text", data: { text: beforeText } });
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
// Add special segment
|
|
270
|
+
switch (type) {
|
|
271
|
+
case "user":
|
|
272
|
+
segments.push({
|
|
273
|
+
type: "at",
|
|
274
|
+
data: {
|
|
275
|
+
id: match[1],
|
|
276
|
+
name: match[2] || match[1],
|
|
277
|
+
text: match[0],
|
|
278
|
+
},
|
|
279
|
+
});
|
|
280
|
+
break;
|
|
281
|
+
case "channel":
|
|
282
|
+
segments.push({
|
|
283
|
+
type: "channel_mention",
|
|
284
|
+
data: {
|
|
285
|
+
id: match[1],
|
|
286
|
+
name: match[2] || match[1],
|
|
287
|
+
text: match[0],
|
|
288
|
+
},
|
|
289
|
+
});
|
|
290
|
+
break;
|
|
291
|
+
case "link":
|
|
292
|
+
segments.push({
|
|
293
|
+
type: "link",
|
|
294
|
+
data: {
|
|
295
|
+
url: match[1],
|
|
296
|
+
text: match[2] || match[1],
|
|
297
|
+
},
|
|
298
|
+
});
|
|
299
|
+
break;
|
|
300
|
+
}
|
|
301
|
+
lastIndex = matchEnd;
|
|
302
|
+
}
|
|
303
|
+
// Add remaining text
|
|
304
|
+
if (lastIndex < text.length) {
|
|
305
|
+
const remainingText = text.slice(lastIndex);
|
|
306
|
+
if (remainingText.trim()) {
|
|
307
|
+
segments.push({ type: "text", data: { text: remainingText } });
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
return segments.length > 0
|
|
311
|
+
? segments
|
|
312
|
+
: [{ type: "text", data: { text } }];
|
|
313
|
+
}
|
|
314
|
+
async $sendMessage(options) {
|
|
315
|
+
try {
|
|
316
|
+
const result = await this.sendContentToChannel(options.id, options.content);
|
|
317
|
+
this.logger.debug(`${this.$config.name} send ${options.type}(${options.id}): ${segment.raw(options.content)}`);
|
|
318
|
+
return result.ts || "";
|
|
319
|
+
}
|
|
320
|
+
catch (error) {
|
|
321
|
+
this.logger.error("Failed to send Slack message:", error);
|
|
322
|
+
throw error;
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
async sendContentToChannel(channel, content, extraOptions = {}) {
|
|
326
|
+
if (!Array.isArray(content))
|
|
327
|
+
content = [content];
|
|
328
|
+
let textContent = "";
|
|
329
|
+
const attachments = [];
|
|
330
|
+
for (const segment of content) {
|
|
331
|
+
if (typeof segment === "string") {
|
|
332
|
+
textContent += segment;
|
|
333
|
+
continue;
|
|
334
|
+
}
|
|
335
|
+
const { type, data } = segment;
|
|
336
|
+
switch (type) {
|
|
337
|
+
case "text":
|
|
338
|
+
textContent += data.text || "";
|
|
339
|
+
break;
|
|
340
|
+
case "at":
|
|
341
|
+
textContent += `<@${data.id}>`;
|
|
342
|
+
break;
|
|
343
|
+
case "channel_mention":
|
|
344
|
+
textContent += `<#${data.id}>`;
|
|
345
|
+
break;
|
|
346
|
+
case "link":
|
|
347
|
+
if (data.text && data.text !== data.url) {
|
|
348
|
+
textContent += `<${data.url}|${data.text}>`;
|
|
349
|
+
}
|
|
350
|
+
else {
|
|
351
|
+
textContent += `<${data.url}>`;
|
|
352
|
+
}
|
|
353
|
+
break;
|
|
354
|
+
case "image":
|
|
355
|
+
if (data.url) {
|
|
356
|
+
attachments.push({
|
|
357
|
+
image_url: data.url,
|
|
358
|
+
title: data.name || data.title,
|
|
359
|
+
});
|
|
360
|
+
}
|
|
361
|
+
break;
|
|
362
|
+
case "file":
|
|
363
|
+
// Files need to be uploaded separately
|
|
364
|
+
if (data.file) {
|
|
365
|
+
try {
|
|
366
|
+
await this.client.files.upload({
|
|
367
|
+
channels: channel,
|
|
368
|
+
file: data.file,
|
|
369
|
+
filename: data.name,
|
|
370
|
+
});
|
|
371
|
+
}
|
|
372
|
+
catch (error) {
|
|
373
|
+
this.logger.error("Failed to upload file:", error);
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
break;
|
|
377
|
+
default:
|
|
378
|
+
textContent += data.text || `[${type}]`;
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
// Send message
|
|
382
|
+
const messageOptions = {
|
|
383
|
+
channel,
|
|
384
|
+
text: textContent.trim() || "Message",
|
|
385
|
+
...extraOptions,
|
|
386
|
+
};
|
|
387
|
+
if (attachments.length > 0) {
|
|
388
|
+
messageOptions.attachments = attachments;
|
|
389
|
+
}
|
|
390
|
+
const result = await this.client.chat.postMessage(messageOptions);
|
|
391
|
+
return result.message || {};
|
|
392
|
+
}
|
|
393
|
+
async $recallMessage(id) {
|
|
394
|
+
// Slack requires both channel and ts (timestamp) to delete a message
|
|
395
|
+
// The Bot interface only provides message ID (ts), making recall impossible
|
|
396
|
+
// Users should use message.$recall() instead, which has the full context
|
|
397
|
+
throw new Error("SlackBot.$recallMessage: Message recall not supported without channel information. " +
|
|
398
|
+
"Use message.$recall() method instead, which contains the required context.");
|
|
399
|
+
}
|
|
400
|
+
// ==================== 工作区管理 API ====================
|
|
401
|
+
/**
|
|
402
|
+
* 邀请用户到频道
|
|
403
|
+
* @param channel 频道 ID
|
|
404
|
+
* @param users 用户 ID 列表
|
|
405
|
+
*/
|
|
406
|
+
async inviteToChannel(channel, users) {
|
|
407
|
+
try {
|
|
408
|
+
await this.client.conversations.invite({ channel, users: users.join(',') });
|
|
409
|
+
this.logger.info(`Slack Bot ${this.$id} 邀请用户 ${users.join(',')} 到频道 ${channel}`);
|
|
410
|
+
return true;
|
|
411
|
+
}
|
|
412
|
+
catch (error) {
|
|
413
|
+
this.logger.error(`Slack Bot ${this.$id} 邀请用户失败:`, error);
|
|
414
|
+
throw error;
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
/**
|
|
418
|
+
* 从频道踢出用户
|
|
419
|
+
* @param channel 频道 ID
|
|
420
|
+
* @param user 用户 ID
|
|
421
|
+
*/
|
|
422
|
+
async kickFromChannel(channel, user) {
|
|
423
|
+
try {
|
|
424
|
+
await this.client.conversations.kick({ channel, user });
|
|
425
|
+
this.logger.info(`Slack Bot ${this.$id} 将用户 ${user} 从频道 ${channel} 踢出`);
|
|
426
|
+
return true;
|
|
427
|
+
}
|
|
428
|
+
catch (error) {
|
|
429
|
+
this.logger.error(`Slack Bot ${this.$id} 踢出用户失败:`, error);
|
|
430
|
+
throw error;
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
/**
|
|
434
|
+
* 设置频道话题
|
|
435
|
+
* @param channel 频道 ID
|
|
436
|
+
* @param topic 话题
|
|
437
|
+
*/
|
|
438
|
+
async setChannelTopic(channel, topic) {
|
|
439
|
+
try {
|
|
440
|
+
await this.client.conversations.setTopic({ channel, topic });
|
|
441
|
+
this.logger.info(`Slack Bot ${this.$id} 设置频道 ${channel} 话题为 "${topic}"`);
|
|
442
|
+
return true;
|
|
443
|
+
}
|
|
444
|
+
catch (error) {
|
|
445
|
+
this.logger.error(`Slack Bot ${this.$id} 设置话题失败:`, error);
|
|
446
|
+
throw error;
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
/**
|
|
450
|
+
* 设置频道目的
|
|
451
|
+
* @param channel 频道 ID
|
|
452
|
+
* @param purpose 目的
|
|
453
|
+
*/
|
|
454
|
+
async setChannelPurpose(channel, purpose) {
|
|
455
|
+
try {
|
|
456
|
+
await this.client.conversations.setPurpose({ channel, purpose });
|
|
457
|
+
this.logger.info(`Slack Bot ${this.$id} 设置频道 ${channel} 目的`);
|
|
458
|
+
return true;
|
|
459
|
+
}
|
|
460
|
+
catch (error) {
|
|
461
|
+
this.logger.error(`Slack Bot ${this.$id} 设置目的失败:`, error);
|
|
462
|
+
throw error;
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
/**
|
|
466
|
+
* 归档频道
|
|
467
|
+
* @param channel 频道 ID
|
|
468
|
+
*/
|
|
469
|
+
async archiveChannel(channel) {
|
|
470
|
+
try {
|
|
471
|
+
await this.client.conversations.archive({ channel });
|
|
472
|
+
this.logger.info(`Slack Bot ${this.$id} 归档频道 ${channel}`);
|
|
473
|
+
return true;
|
|
474
|
+
}
|
|
475
|
+
catch (error) {
|
|
476
|
+
this.logger.error(`Slack Bot ${this.$id} 归档频道失败:`, error);
|
|
477
|
+
throw error;
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
/**
|
|
481
|
+
* 取消归档频道
|
|
482
|
+
* @param channel 频道 ID
|
|
483
|
+
*/
|
|
484
|
+
async unarchiveChannel(channel) {
|
|
485
|
+
try {
|
|
486
|
+
await this.client.conversations.unarchive({ channel });
|
|
487
|
+
this.logger.info(`Slack Bot ${this.$id} 取消归档频道 ${channel}`);
|
|
488
|
+
return true;
|
|
489
|
+
}
|
|
490
|
+
catch (error) {
|
|
491
|
+
this.logger.error(`Slack Bot ${this.$id} 取消归档失败:`, error);
|
|
492
|
+
throw error;
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
/**
|
|
496
|
+
* 重命名频道
|
|
497
|
+
* @param channel 频道 ID
|
|
498
|
+
* @param name 新名称
|
|
499
|
+
*/
|
|
500
|
+
async renameChannel(channel, name) {
|
|
501
|
+
try {
|
|
502
|
+
await this.client.conversations.rename({ channel, name });
|
|
503
|
+
this.logger.info(`Slack Bot ${this.$id} 重命名频道 ${channel} 为 "${name}"`);
|
|
504
|
+
return true;
|
|
505
|
+
}
|
|
506
|
+
catch (error) {
|
|
507
|
+
this.logger.error(`Slack Bot ${this.$id} 重命名频道失败:`, error);
|
|
508
|
+
throw error;
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
/**
|
|
512
|
+
* 获取频道成员列表
|
|
513
|
+
* @param channel 频道 ID
|
|
514
|
+
*/
|
|
515
|
+
async getChannelMembers(channel) {
|
|
516
|
+
try {
|
|
517
|
+
const result = await this.client.conversations.members({ channel });
|
|
518
|
+
return result.members || [];
|
|
519
|
+
}
|
|
520
|
+
catch (error) {
|
|
521
|
+
this.logger.error(`Slack Bot ${this.$id} 获取成员列表失败:`, error);
|
|
522
|
+
throw error;
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
/**
|
|
526
|
+
* 获取频道信息
|
|
527
|
+
* @param channel 频道 ID
|
|
528
|
+
*/
|
|
529
|
+
async getChannelInfo(channel) {
|
|
530
|
+
try {
|
|
531
|
+
const result = await this.client.conversations.info({ channel });
|
|
532
|
+
return result.channel;
|
|
533
|
+
}
|
|
534
|
+
catch (error) {
|
|
535
|
+
this.logger.error(`Slack Bot ${this.$id} 获取频道信息失败:`, error);
|
|
536
|
+
throw error;
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
/**
|
|
540
|
+
* 获取用户信息
|
|
541
|
+
* @param user 用户 ID
|
|
542
|
+
*/
|
|
543
|
+
async getUserInfo(user) {
|
|
544
|
+
try {
|
|
545
|
+
const result = await this.client.users.info({ user });
|
|
546
|
+
return result.user;
|
|
547
|
+
}
|
|
548
|
+
catch (error) {
|
|
549
|
+
this.logger.error(`Slack Bot ${this.$id} 获取用户信息失败:`, error);
|
|
550
|
+
throw error;
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
/**
|
|
554
|
+
* 添加消息反应
|
|
555
|
+
* @param channel 频道 ID
|
|
556
|
+
* @param timestamp 消息时间戳
|
|
557
|
+
* @param name 表情名称
|
|
558
|
+
*/
|
|
559
|
+
async addReaction(channel, timestamp, name) {
|
|
560
|
+
try {
|
|
561
|
+
await this.client.reactions.add({ channel, timestamp, name });
|
|
562
|
+
this.logger.info(`Slack Bot ${this.$id} 添加反应 :${name}: 到消息`);
|
|
563
|
+
return true;
|
|
564
|
+
}
|
|
565
|
+
catch (error) {
|
|
566
|
+
this.logger.error(`Slack Bot ${this.$id} 添加反应失败:`, error);
|
|
567
|
+
throw error;
|
|
568
|
+
}
|
|
569
|
+
}
|
|
570
|
+
/**
|
|
571
|
+
* 移除消息反应
|
|
572
|
+
* @param channel 频道 ID
|
|
573
|
+
* @param timestamp 消息时间戳
|
|
574
|
+
* @param name 表情名称
|
|
575
|
+
*/
|
|
576
|
+
async removeReaction(channel, timestamp, name) {
|
|
577
|
+
try {
|
|
578
|
+
await this.client.reactions.remove({ channel, timestamp, name });
|
|
579
|
+
this.logger.info(`Slack Bot ${this.$id} 移除反应 :${name}:`);
|
|
580
|
+
return true;
|
|
581
|
+
}
|
|
582
|
+
catch (error) {
|
|
583
|
+
this.logger.error(`Slack Bot ${this.$id} 移除反应失败:`, error);
|
|
584
|
+
throw error;
|
|
585
|
+
}
|
|
586
|
+
}
|
|
587
|
+
/**
|
|
588
|
+
* 置顶消息
|
|
589
|
+
* @param channel 频道 ID
|
|
590
|
+
* @param timestamp 消息时间戳
|
|
591
|
+
*/
|
|
592
|
+
async pinMessage(channel, timestamp) {
|
|
593
|
+
try {
|
|
594
|
+
await this.client.pins.add({ channel, timestamp });
|
|
595
|
+
this.logger.info(`Slack Bot ${this.$id} 置顶消息(频道 ${channel})`);
|
|
596
|
+
return true;
|
|
597
|
+
}
|
|
598
|
+
catch (error) {
|
|
599
|
+
this.logger.error(`Slack Bot ${this.$id} 置顶消息失败:`, error);
|
|
600
|
+
throw error;
|
|
601
|
+
}
|
|
602
|
+
}
|
|
603
|
+
/**
|
|
604
|
+
* 取消置顶消息
|
|
605
|
+
* @param channel 频道 ID
|
|
606
|
+
* @param timestamp 消息时间戳
|
|
607
|
+
*/
|
|
608
|
+
async unpinMessage(channel, timestamp) {
|
|
609
|
+
try {
|
|
610
|
+
await this.client.pins.remove({ channel, timestamp });
|
|
611
|
+
this.logger.info(`Slack Bot ${this.$id} 取消置顶消息`);
|
|
612
|
+
return true;
|
|
613
|
+
}
|
|
614
|
+
catch (error) {
|
|
615
|
+
this.logger.error(`Slack Bot ${this.$id} 取消置顶失败:`, error);
|
|
616
|
+
throw error;
|
|
617
|
+
}
|
|
618
|
+
}
|
|
619
|
+
}
|
|
620
|
+
//# sourceMappingURL=bot.js.map
|
package/lib/bot.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bot.js","sourceRoot":"","sources":["../src/bot.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,GAAG,IAAI,QAAQ,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACxD,OAAO,EAAE,SAAS,EAAiC,MAAM,gBAAgB,CAAC;AAC1E,OAAO,EAEL,OAAO,EAIP,OAAO,GACR,MAAM,SAAS,CAAC;AAKjB,MAAM,OAAO,QAAQ;IAaA;IAA8B;IAZjD,UAAU,CAAU;IACZ,GAAG,CAAW;IACd,MAAM,CAAY;IAE1B,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,MA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