@zhin.js/adapter-slack 1.0.1

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 ADDED
@@ -0,0 +1,20 @@
1
+ # Changelog
2
+
3
+ ## 1.0.1
4
+
5
+ ### Patch Changes
6
+
7
+ - cda76be: fix: add adapters
8
+
9
+ ## 1.0.0 (2025-01-19)
10
+
11
+ ### Features
12
+
13
+ - Initial release of Slack adapter
14
+ - Support for text messages with Slack mrkdwn formatting
15
+ - Rich media support (images, files)
16
+ - Socket Mode and HTTP mode
17
+ - Thread replies
18
+ - User and channel mentions
19
+ - Link attachments
20
+ - Private messages and channel support
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 凉菜
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,174 @@
1
+ # @zhin.js/adapter-slack
2
+
3
+ Slack adapter for zhin.js framework.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ pnpm add @zhin.js/adapter-slack
9
+ ```
10
+
11
+ ## Configuration
12
+
13
+ ### Socket Mode (Recommended for Development)
14
+
15
+ ```typescript
16
+ import { defineConfig } from 'zhin.js'
17
+
18
+ export default defineConfig({
19
+ bots: [
20
+ {
21
+ name: 'my-slack-bot',
22
+ context: 'slack',
23
+ token: 'xoxb-your-bot-token',
24
+ signingSecret: 'your-signing-secret',
25
+ appToken: 'xapp-your-app-token',
26
+ socketMode: true
27
+ }
28
+ ]
29
+ })
30
+ ```
31
+
32
+ ### HTTP Mode (For Production with Public URL)
33
+
34
+ ```typescript
35
+ import { defineConfig } from 'zhin.js'
36
+
37
+ export default defineConfig({
38
+ bots: [
39
+ {
40
+ name: 'my-slack-bot',
41
+ context: 'slack',
42
+ token: 'xoxb-your-bot-token',
43
+ signingSecret: 'your-signing-secret',
44
+ socketMode: false,
45
+ port: 3000
46
+ }
47
+ ]
48
+ })
49
+ ```
50
+
51
+ ## Features
52
+
53
+ - ✅ Send and receive text messages
54
+ - ✅ Support for rich media (images, files)
55
+ - ✅ Message formatting (Slack mrkdwn)
56
+ - ✅ Reply to messages and threads
57
+ - ✅ Mentions (@user, #channel)
58
+ - ✅ Links and attachments
59
+ - ✅ Socket Mode and HTTP mode
60
+ - ✅ Private messages and channels
61
+
62
+ ## Setting Up Your Slack App
63
+
64
+ 1. Go to [Slack API](https://api.slack.com/apps)
65
+ 2. Create a new app
66
+ 3. Add Bot Token Scopes:
67
+ - `chat:write` - Send messages
68
+ - `chat:write.public` - Send messages to public channels
69
+ - `channels:read` - View basic channel info
70
+ - `channels:history` - View messages in channels
71
+ - `groups:read` - View basic private channel info
72
+ - `groups:history` - View messages in private channels
73
+ - `im:read` - View basic direct message info
74
+ - `im:history` - View messages in direct messages
75
+ - `mpim:read` - View basic group direct message info
76
+ - `mpim:history` - View messages in group direct messages
77
+ - `users:read` - View user info
78
+ - `files:read` - View files
79
+ - `files:write` - Upload files
80
+ 4. Enable Socket Mode (if using Socket Mode):
81
+ - Go to Socket Mode settings
82
+ - Enable Socket Mode
83
+ - Generate an app-level token with `connections:write` scope
84
+ 5. Subscribe to events:
85
+ - `message.channels` - Messages in public channels
86
+ - `message.groups` - Messages in private channels
87
+ - `message.im` - Direct messages
88
+ - `message.mpim` - Group direct messages
89
+ - `app_mention` - When the bot is mentioned
90
+ 6. Install the app to your workspace
91
+ 7. Copy the Bot User OAuth Token (`xoxb-...`)
92
+ 8. Copy the Signing Secret
93
+ 9. Copy the App-Level Token (`xapp-...`) if using Socket Mode
94
+
95
+ ## Usage Examples
96
+
97
+ ### Basic Message Handling
98
+
99
+ ```typescript
100
+ import { addCommand, MessageCommand } from 'zhin.js'
101
+
102
+ addCommand(new MessageCommand('hello')
103
+ .action(async (message) => {
104
+ return 'Hello from Slack!'
105
+ })
106
+ )
107
+ ```
108
+
109
+ ### Send Rich Messages
110
+
111
+ ```typescript
112
+ addCommand(new MessageCommand('info')
113
+ .action(async (message) => {
114
+ return [
115
+ { type: 'text', data: { text: '*Bold* and _italic_ text\n' } },
116
+ { type: 'link', data: { url: 'https://slack.com', text: 'Visit Slack' } }
117
+ ]
118
+ })
119
+ )
120
+ ```
121
+
122
+ ### Mention Users
123
+
124
+ ```typescript
125
+ addCommand(new MessageCommand('mention <userId:text>')
126
+ .action(async (message, result) => {
127
+ return [
128
+ { type: 'at', data: { id: result.params.userId } },
129
+ { type: 'text', data: { text: ' Hello!' } }
130
+ ]
131
+ })
132
+ )
133
+ ```
134
+
135
+ ### Reply in Thread
136
+
137
+ ```typescript
138
+ addCommand(new MessageCommand('thread')
139
+ .action(async (message) => {
140
+ // Reply in a thread by passing the message timestamp
141
+ await message.$reply('This is a threaded reply!', true)
142
+ })
143
+ )
144
+ ```
145
+
146
+ ## Slack-Specific Features
147
+
148
+ ### Slack Formatting
149
+
150
+ Slack uses mrkdwn format:
151
+ - `*bold*` for **bold**
152
+ - `_italic_` for *italic*
153
+ - `~strike~` for ~~strikethrough~~
154
+ - `` `code` `` for `code`
155
+ - `> quote` for blockquotes
156
+
157
+ ### User and Channel Mentions
158
+
159
+ The adapter automatically converts:
160
+ - `<@U12345678>` to user mentions
161
+ - `<#C12345678>` to channel mentions
162
+
163
+ ### File Uploads
164
+
165
+ Upload files using the `file` segment type with a local file path.
166
+
167
+ ## Limitations
168
+
169
+ - Message recall requires channel information (not available from message ID alone)
170
+ - Some Slack features like interactive components require additional setup
171
+
172
+ ## License
173
+
174
+ MIT
package/lib/index.d.ts ADDED
@@ -0,0 +1,40 @@
1
+ import { LogLevel } from "@slack/bolt";
2
+ import type { KnownEventFromType } from "@slack/bolt";
3
+ import { Bot, Adapter, Message, SendOptions } from "zhin.js";
4
+ declare module "@zhin.js/types" {
5
+ interface RegisteredAdapters {
6
+ slack: Adapter<SlackBot>;
7
+ }
8
+ }
9
+ export type SlackBotConfig = Bot.Config & {
10
+ context: "slack";
11
+ token: string;
12
+ name: string;
13
+ signingSecret: string;
14
+ appToken?: string;
15
+ socketMode?: boolean;
16
+ port?: number;
17
+ logLevel?: LogLevel;
18
+ };
19
+ export interface SlackBot {
20
+ $config: SlackBotConfig;
21
+ }
22
+ type SlackMessageEvent = KnownEventFromType<"message">;
23
+ export declare class SlackBot implements Bot<SlackMessageEvent, SlackBotConfig> {
24
+ $config: SlackBotConfig;
25
+ $connected?: boolean;
26
+ private app;
27
+ private client;
28
+ constructor($config: SlackBotConfig);
29
+ $connect(): Promise<void>;
30
+ $disconnect(): Promise<void>;
31
+ private handleSlackMessage;
32
+ $formatMessage(msg: SlackMessageEvent): Message<SlackMessageEvent>;
33
+ private parseMessageContent;
34
+ private parseSlackText;
35
+ $sendMessage(options: SendOptions): Promise<string>;
36
+ private sendContentToChannel;
37
+ $recallMessage(id: string): Promise<void>;
38
+ }
39
+ export {};
40
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../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FhB,YAAY,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,MAAM,CAAC;YAkB3C,oBAAoB;IAmF5B,cAAc,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAShD"}
package/lib/index.js ADDED
@@ -0,0 +1,390 @@
1
+ import { App as SlackApp, LogLevel } from "@slack/bolt";
2
+ import { WebClient } from "@slack/web-api";
3
+ import { Adapter, registerAdapter, Message, segment, usePlugin, } from "zhin.js";
4
+ const plugin = usePlugin();
5
+ export class SlackBot {
6
+ $config;
7
+ $connected;
8
+ app;
9
+ client;
10
+ constructor($config) {
11
+ this.$config = $config;
12
+ this.$connected = false;
13
+ // Initialize Slack app
14
+ if ($config.socketMode && $config.appToken) {
15
+ // Socket Mode
16
+ this.app = new SlackApp({
17
+ token: $config.token,
18
+ signingSecret: $config.signingSecret,
19
+ appToken: $config.appToken,
20
+ socketMode: true,
21
+ logLevel: $config.logLevel || LogLevel.INFO,
22
+ });
23
+ }
24
+ else {
25
+ // HTTP Mode
26
+ this.app = new SlackApp({
27
+ token: $config.token,
28
+ signingSecret: $config.signingSecret,
29
+ socketMode: false,
30
+ logLevel: $config.logLevel || LogLevel.INFO,
31
+ });
32
+ }
33
+ this.client = new WebClient($config.token);
34
+ }
35
+ async $connect() {
36
+ try {
37
+ // Set up message event handler
38
+ this.app.message(async ({ message, say }) => {
39
+ await this.handleSlackMessage(message);
40
+ });
41
+ // Set up app mention handler
42
+ this.app.event("app_mention", async ({ event, say }) => {
43
+ await this.handleSlackMessage(event);
44
+ });
45
+ // Start the app
46
+ const port = this.$config.port || 3000;
47
+ if (this.$config.socketMode) {
48
+ await this.app.start();
49
+ }
50
+ else {
51
+ await this.app.start(port);
52
+ }
53
+ this.$connected = true;
54
+ // Get bot info
55
+ const authTest = await this.client.auth.test();
56
+ plugin.logger.info(`Slack bot ${this.$config.name} connected successfully as @${authTest.user}`);
57
+ if (!this.$config.socketMode) {
58
+ plugin.logger.info(`Slack bot listening on port ${port}`);
59
+ }
60
+ }
61
+ catch (error) {
62
+ plugin.logger.error("Failed to connect Slack bot:", error);
63
+ this.$connected = false;
64
+ throw error;
65
+ }
66
+ }
67
+ async $disconnect() {
68
+ try {
69
+ await this.app.stop();
70
+ this.$connected = false;
71
+ plugin.logger.info(`Slack bot ${this.$config.name} disconnected`);
72
+ }
73
+ catch (error) {
74
+ plugin.logger.error("Error disconnecting Slack bot:", error);
75
+ throw error;
76
+ }
77
+ }
78
+ async handleSlackMessage(msg) {
79
+ // Ignore bot messages and message changes
80
+ if ("subtype" in msg && (msg.subtype === "bot_message" || msg.subtype === "message_changed")) {
81
+ return;
82
+ }
83
+ const message = this.$formatMessage(msg);
84
+ plugin.dispatch("message.receive", message);
85
+ plugin.logger.info(`${this.$config.name} recv ${message.$channel.type}(${message.$channel.id}): ${segment.raw(message.$content)}`);
86
+ plugin.dispatch(`message.${message.$channel.type}.receive`, message);
87
+ }
88
+ $formatMessage(msg) {
89
+ // Determine channel type based on channel ID
90
+ const channelType = "channel_type" in msg && msg.channel_type === "im" ? "private" : "group";
91
+ const channelId = msg.channel;
92
+ // Parse message content
93
+ const content = this.parseMessageContent(msg);
94
+ // Extract user info safely
95
+ const userId = ("user" in msg ? msg.user : "") || "";
96
+ const userName = ("username" in msg ? msg.username : null) || userId || "Unknown";
97
+ const messageText = ("text" in msg ? msg.text : "") || "";
98
+ const result = Message.from(msg, {
99
+ $id: msg.ts,
100
+ $adapter: "slack",
101
+ $bot: this.$config.name,
102
+ $sender: {
103
+ id: userId,
104
+ name: userName,
105
+ },
106
+ $channel: {
107
+ id: channelId,
108
+ type: channelType,
109
+ },
110
+ $content: content,
111
+ $raw: messageText,
112
+ $timestamp: parseFloat(msg.ts) * 1000,
113
+ $recall: async () => {
114
+ try {
115
+ await this.client.chat.delete({
116
+ channel: channelId,
117
+ ts: result.$id,
118
+ });
119
+ }
120
+ catch (error) {
121
+ plugin.logger.error("Error recalling Slack message:", error);
122
+ throw error;
123
+ }
124
+ },
125
+ $reply: async (content, quote) => {
126
+ if (!Array.isArray(content))
127
+ content = [content];
128
+ const sendOptions = {
129
+ channel: channelId,
130
+ };
131
+ // Handle thread reply
132
+ if (quote) {
133
+ const threadTs = typeof quote === "boolean" ? result.$id : quote;
134
+ sendOptions.thread_ts = threadTs;
135
+ }
136
+ const sentMsg = await this.sendContentToChannel(channelId, content, sendOptions);
137
+ return sentMsg.ts || "";
138
+ },
139
+ });
140
+ return result;
141
+ }
142
+ parseMessageContent(msg) {
143
+ const segments = [];
144
+ // Handle text
145
+ if ("text" in msg && msg.text) {
146
+ // Parse Slack formatting
147
+ segments.push(...this.parseSlackText(msg.text));
148
+ }
149
+ // Handle files
150
+ if ("files" in msg && msg.files) {
151
+ for (const file of msg.files) {
152
+ if (file.mimetype?.startsWith("image/")) {
153
+ segments.push({
154
+ type: "image",
155
+ data: {
156
+ id: file.id,
157
+ name: file.name,
158
+ url: file.url_private || file.permalink,
159
+ size: file.size,
160
+ mimetype: file.mimetype,
161
+ },
162
+ });
163
+ }
164
+ else if (file.mimetype?.startsWith("video/")) {
165
+ segments.push({
166
+ type: "video",
167
+ data: {
168
+ id: file.id,
169
+ name: file.name,
170
+ url: file.url_private || file.permalink,
171
+ size: file.size,
172
+ mimetype: file.mimetype,
173
+ },
174
+ });
175
+ }
176
+ else if (file.mimetype?.startsWith("audio/")) {
177
+ segments.push({
178
+ type: "audio",
179
+ data: {
180
+ id: file.id,
181
+ name: file.name,
182
+ url: file.url_private || file.permalink,
183
+ size: file.size,
184
+ mimetype: file.mimetype,
185
+ },
186
+ });
187
+ }
188
+ else {
189
+ segments.push({
190
+ type: "file",
191
+ data: {
192
+ id: file.id,
193
+ name: file.name,
194
+ url: file.url_private || file.permalink,
195
+ size: file.size,
196
+ mimetype: file.mimetype,
197
+ },
198
+ });
199
+ }
200
+ }
201
+ }
202
+ // Handle attachments
203
+ if ("attachments" in msg && msg.attachments) {
204
+ for (const attachment of msg.attachments) {
205
+ if (attachment.image_url) {
206
+ segments.push({
207
+ type: "image",
208
+ data: {
209
+ url: attachment.image_url,
210
+ title: attachment.title,
211
+ text: attachment.text,
212
+ },
213
+ });
214
+ }
215
+ }
216
+ }
217
+ return segments.length > 0
218
+ ? segments
219
+ : [{ type: "text", data: { text: "" } }];
220
+ }
221
+ parseSlackText(text) {
222
+ const segments = [];
223
+ let lastIndex = 0;
224
+ // Match user mentions <@U12345678>
225
+ const userMentionRegex = /<@([UW][A-Z0-9]+)(?:\|([^>]+))?>/g;
226
+ // Match channel mentions <#C12345678|general>
227
+ const channelMentionRegex = /<#([C][A-Z0-9]+)(?:\|([^>]+))?>/g;
228
+ // Match links <http://example.com|Example>
229
+ const linkRegex = /<(https?:\/\/[^|>]+)(?:\|([^>]+))?>/g;
230
+ const allMatches = [];
231
+ // Collect all matches
232
+ let match;
233
+ while ((match = userMentionRegex.exec(text)) !== null) {
234
+ allMatches.push({ match, type: "user" });
235
+ }
236
+ while ((match = channelMentionRegex.exec(text)) !== null) {
237
+ allMatches.push({ match, type: "channel" });
238
+ }
239
+ while ((match = linkRegex.exec(text)) !== null) {
240
+ allMatches.push({ match, type: "link" });
241
+ }
242
+ // Sort by position
243
+ allMatches.sort((a, b) => a.match.index - b.match.index);
244
+ // Process matches
245
+ for (const { match, type } of allMatches) {
246
+ const matchStart = match.index;
247
+ const matchEnd = matchStart + match[0].length;
248
+ // Add text before match
249
+ if (matchStart > lastIndex) {
250
+ const beforeText = text.slice(lastIndex, matchStart);
251
+ if (beforeText.trim()) {
252
+ segments.push({ type: "text", data: { text: beforeText } });
253
+ }
254
+ }
255
+ // Add special segment
256
+ switch (type) {
257
+ case "user":
258
+ segments.push({
259
+ type: "at",
260
+ data: {
261
+ id: match[1],
262
+ name: match[2] || match[1],
263
+ text: match[0],
264
+ },
265
+ });
266
+ break;
267
+ case "channel":
268
+ segments.push({
269
+ type: "channel_mention",
270
+ data: {
271
+ id: match[1],
272
+ name: match[2] || match[1],
273
+ text: match[0],
274
+ },
275
+ });
276
+ break;
277
+ case "link":
278
+ segments.push({
279
+ type: "link",
280
+ data: {
281
+ url: match[1],
282
+ text: match[2] || match[1],
283
+ },
284
+ });
285
+ break;
286
+ }
287
+ lastIndex = matchEnd;
288
+ }
289
+ // Add remaining text
290
+ if (lastIndex < text.length) {
291
+ const remainingText = text.slice(lastIndex);
292
+ if (remainingText.trim()) {
293
+ segments.push({ type: "text", data: { text: remainingText } });
294
+ }
295
+ }
296
+ return segments.length > 0
297
+ ? segments
298
+ : [{ type: "text", data: { text } }];
299
+ }
300
+ async $sendMessage(options) {
301
+ options = await plugin.app.handleBeforeSend(options);
302
+ try {
303
+ const result = await this.sendContentToChannel(options.id, options.content);
304
+ plugin.logger.info(`${this.$config.name} send ${options.type}(${options.id}): ${segment.raw(options.content)}`);
305
+ return result.ts || "";
306
+ }
307
+ catch (error) {
308
+ plugin.logger.error("Failed to send Slack message:", error);
309
+ throw error;
310
+ }
311
+ }
312
+ async sendContentToChannel(channel, content, extraOptions = {}) {
313
+ if (!Array.isArray(content))
314
+ content = [content];
315
+ let textContent = "";
316
+ const attachments = [];
317
+ for (const segment of content) {
318
+ if (typeof segment === "string") {
319
+ textContent += segment;
320
+ continue;
321
+ }
322
+ const { type, data } = segment;
323
+ switch (type) {
324
+ case "text":
325
+ textContent += data.text || "";
326
+ break;
327
+ case "at":
328
+ textContent += `<@${data.id}>`;
329
+ break;
330
+ case "channel_mention":
331
+ textContent += `<#${data.id}>`;
332
+ break;
333
+ case "link":
334
+ if (data.text && data.text !== data.url) {
335
+ textContent += `<${data.url}|${data.text}>`;
336
+ }
337
+ else {
338
+ textContent += `<${data.url}>`;
339
+ }
340
+ break;
341
+ case "image":
342
+ if (data.url) {
343
+ attachments.push({
344
+ image_url: data.url,
345
+ title: data.name || data.title,
346
+ });
347
+ }
348
+ break;
349
+ case "file":
350
+ // Files need to be uploaded separately
351
+ if (data.file) {
352
+ try {
353
+ await this.client.files.upload({
354
+ channels: channel,
355
+ file: data.file,
356
+ filename: data.name,
357
+ });
358
+ }
359
+ catch (error) {
360
+ plugin.logger.error("Failed to upload file:", error);
361
+ }
362
+ }
363
+ break;
364
+ default:
365
+ textContent += data.text || `[${type}]`;
366
+ }
367
+ }
368
+ // Send message
369
+ const messageOptions = {
370
+ channel,
371
+ text: textContent.trim() || "Message",
372
+ ...extraOptions,
373
+ };
374
+ if (attachments.length > 0) {
375
+ messageOptions.attachments = attachments;
376
+ }
377
+ const result = await this.client.chat.postMessage(messageOptions);
378
+ return result.message || {};
379
+ }
380
+ async $recallMessage(id) {
381
+ // Slack requires both channel and ts (timestamp) to delete a message
382
+ // The Bot interface only provides message ID (ts), making recall impossible
383
+ // Users should use message.$recall() instead, which has the full context
384
+ throw new Error("SlackBot.$recallMessage: Message recall not supported without channel information. " +
385
+ "Use message.$recall() method instead, which contains the required context.");
386
+ }
387
+ }
388
+ // Register the adapter
389
+ registerAdapter(new Adapter("slack", (config) => new SlackBot(config)));
390
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,IAAI,QAAQ,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACxD,OAAO,EAAE,SAAS,EAA4B,MAAM,gBAAgB,CAAC;AAErE,OAAO,EAEL,OAAO,EACP,eAAe,EACf,OAAO,EAIP,OAAO,EACP,SAAS,GACV,MAAM,SAAS,CAAC;AAyBjB,MAAM,MAAM,GAAG,SAAS,EAAE,CAAC;AAK3B,MAAM,OAAO,QAAQ;IAKA;IAJnB,UAAU,CAAW;IACb,GAAG,CAAW;IACd,MAAM,CAAY;IAE1B,YAAmB,OAAuB;QAAvB,YAAO,GAAP,OAAO,CAAgB;QACxC,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC;QAExB,uBAAuB;QACvB,IAAI,OAAO,CAAC,UAAU,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC;YAC3C,cAAc;YACd,IAAI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AC;YAC3B,cAAc,CAAC,WAAW,GAAG,WAAW,CAAC;QAC3C,CAAC;QAED,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,cAA0C,CAAC,CAAC;QAC9F,OAAO,MAAM,CAAC,OAAO,IAAI,EAAE,CAAC;IAC9B,CAAC;IAED,KAAK,CAAC,cAAc,CAAC,EAAU;QAC7B,qEAAqE;QACrE,8EAA8E;QAC9E,yEAAyE;QACzE,MAAM,IAAI,KAAK,CACb,qFAAqF;YACrF,4EAA4E,CAC7E,CAAC;IACJ,CAAC;CACF;AAED,uBAAuB;AACvB,eAAe,CACb,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC,MAAW,EAAE,EAAE,CAAC,IAAI,QAAQ,CAAC,MAAwB,CAAC,CAAC,CAC9E,CAAC"}
package/package.json ADDED
@@ -0,0 +1,53 @@
1
+ {
2
+ "name": "@zhin.js/adapter-slack",
3
+ "version": "1.0.1",
4
+ "description": "zhin adapter for slack",
5
+ "type": "module",
6
+ "main": "./lib/index.js",
7
+ "types": "./lib/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./lib/index.d.ts",
11
+ "import": "./lib/index.js"
12
+ }
13
+ },
14
+ "keywords": [
15
+ "zhin",
16
+ "adapter",
17
+ "slack"
18
+ ],
19
+ "author": "lc-cn",
20
+ "license": "MIT",
21
+ "repository": {
22
+ "url": "git+https://github.com/zhinjs/zhin.git",
23
+ "type": "git",
24
+ "directory": "plugins/adapters/slack"
25
+ },
26
+ "dependencies": {
27
+ "@slack/bolt": "^4.6.0",
28
+ "@slack/web-api": "^7.10.0"
29
+ },
30
+ "devDependencies": {
31
+ "@types/node": "^22.9.0",
32
+ "typescript": "^5.3.0"
33
+ },
34
+ "peerDependencies": {
35
+ "zhin.js": "1.0.16",
36
+ "@zhin.js/types": "1.0.5"
37
+ },
38
+ "peerDependenciesMeta": {
39
+ "@zhin.js/types": {
40
+ "optional": true
41
+ }
42
+ },
43
+ "files": [
44
+ "lib",
45
+ "README.md",
46
+ "CHANGELOG.md"
47
+ ],
48
+ "scripts": {
49
+ "build": "pnpm build:node",
50
+ "clean": "rm -rf lib",
51
+ "build:node": "tsc"
52
+ }
53
+ }