@pipedream/slack 0.4.11 → 0.4.13
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/actions/add-emoji-reaction/add-emoji-reaction.mjs +43 -0
- package/actions/add-star/add-star.mjs +1 -1
- package/actions/archive-channel/archive-channel.mjs +1 -1
- package/actions/complete-reminder/complete-reminder.mjs +1 -1
- package/actions/create-channel/create-channel.mjs +1 -1
- package/actions/create-reminder/create-reminder.mjs +1 -1
- package/actions/delete-file/delete-file.mjs +1 -1
- package/actions/delete-message/delete-message.mjs +1 -1
- package/actions/delete-reminder/delete-reminder.mjs +1 -1
- package/actions/find-message/find-message.mjs +4 -3
- package/actions/find-user-by-email/find-user-by-email.mjs +1 -1
- package/actions/get-channel/get-channel.mjs +1 -1
- package/actions/get-file/get-file.mjs +1 -1
- package/actions/get-reminder/get-reminder.mjs +1 -1
- package/actions/invite-user-to-channel/invite-user-to-channel.mjs +1 -2
- package/actions/join-channel/join-channel.mjs +1 -1
- package/actions/kick-user/kick-user.mjs +1 -1
- package/actions/leave-channel/leave-channel.mjs +1 -1
- package/actions/list-channels/list-channels.mjs +1 -1
- package/actions/list-files/list-files.mjs +1 -1
- package/actions/list-members-in-channel/list-members-in-channel.mjs +1 -1
- package/actions/list-reminders/list-reminders.mjs +1 -1
- package/actions/list-replies/list-replies.mjs +1 -1
- package/actions/list-user-groups-users/list-user-groups-users.mjs +1 -1
- package/actions/list-users/list-users.mjs +5 -3
- package/actions/remove-star/remove-star.mjs +1 -1
- package/actions/reply-to-a-message/reply-to-a-message.mjs +1 -1
- package/actions/send-block-kit-message/send-block-kit-message.mjs +1 -1
- package/actions/send-custom-message/send-custom-message.mjs +1 -1
- package/actions/send-direct-message/send-direct-message.mjs +1 -1
- package/actions/send-group-message/send-group-message.mjs +1 -1
- package/actions/send-large-message/send-large-message.mjs +1 -1
- package/actions/send-message-private-channel/send-message-private-channel.mjs +8 -2
- package/actions/send-message-public-channel/send-message-public-channel.mjs +8 -2
- package/actions/set-channel-purpose/set-channel-purpose.mjs +1 -1
- package/actions/set-channel-topic/set-channel-topic.mjs +1 -1
- package/actions/unarchive-channel/unarchive-channel.mjs +1 -1
- package/actions/update-message/update-message.mjs +1 -1
- package/actions/update-profile/update-profile.mjs +1 -1
- package/actions/update-user-groups-users/update-user-groups-users.mjs +1 -1
- package/actions/upload-file/upload-file.mjs +1 -1
- package/actions/verify-slack-signature/verify-slack-signature.mjs +1 -1
- package/common/constants.mjs +15 -0
- package/package.json +1 -1
- package/slack.app.mjs +333 -158
- package/sources/common/constants.mjs +12 -1
- package/sources/new-direct-message/new-direct-message.mjs +1 -1
- package/sources/new-interaction-event-received/new-interaction-event-received.mjs +1 -1
- package/sources/new-mention/new-mention.mjs +34 -12
- package/sources/new-message-in-channels/new-message-in-channels.mjs +1 -1
- package/sources/new-reaction-added/new-reaction-added.mjs +1 -1
- package/sources/new-star-added/new-star-added.mjs +4 -7
package/slack.app.mjs
CHANGED
|
@@ -1,51 +1,10 @@
|
|
|
1
1
|
import { WebClient } from "@slack/web-api";
|
|
2
|
+
import constants from "./common/constants.mjs";
|
|
2
3
|
|
|
3
4
|
export default {
|
|
4
5
|
type: "app",
|
|
5
6
|
app: "slack",
|
|
6
7
|
propDefinitions: {
|
|
7
|
-
publicChannel: {
|
|
8
|
-
type: "string",
|
|
9
|
-
label: "Channel",
|
|
10
|
-
description: "Select a public channel",
|
|
11
|
-
async options({ prevContext }) {
|
|
12
|
-
const { cursor } = prevContext;
|
|
13
|
-
const types = [
|
|
14
|
-
"public_channel",
|
|
15
|
-
];
|
|
16
|
-
const resp = await this.availableConversations(types.join(), cursor);
|
|
17
|
-
return {
|
|
18
|
-
options: resp.conversations.map((c) => ({
|
|
19
|
-
label: `${c.name}`,
|
|
20
|
-
value: c.id,
|
|
21
|
-
})),
|
|
22
|
-
context: {
|
|
23
|
-
cursor: resp.cursor,
|
|
24
|
-
},
|
|
25
|
-
};
|
|
26
|
-
},
|
|
27
|
-
},
|
|
28
|
-
privateChannel: {
|
|
29
|
-
type: "string",
|
|
30
|
-
label: "Channel",
|
|
31
|
-
description: "Select a private channel",
|
|
32
|
-
async options({ prevContext }) {
|
|
33
|
-
const { cursor } = prevContext;
|
|
34
|
-
const types = [
|
|
35
|
-
"private_channel",
|
|
36
|
-
];
|
|
37
|
-
const resp = await this.availableConversations(types.join(), cursor);
|
|
38
|
-
return {
|
|
39
|
-
options: resp.conversations.map((c) => ({
|
|
40
|
-
label: `${c.name}`,
|
|
41
|
-
value: c.id,
|
|
42
|
-
})),
|
|
43
|
-
context: {
|
|
44
|
-
cursor: resp.cursor,
|
|
45
|
-
},
|
|
46
|
-
};
|
|
47
|
-
},
|
|
48
|
-
},
|
|
49
8
|
user: {
|
|
50
9
|
type: "string",
|
|
51
10
|
label: "User",
|
|
@@ -64,7 +23,7 @@ export default {
|
|
|
64
23
|
return {
|
|
65
24
|
options: conversationsResp.conversations.map((c) => ({
|
|
66
25
|
label: `@${userNames[c.user]}`,
|
|
67
|
-
value: c.id,
|
|
26
|
+
value: c.user || c.id,
|
|
68
27
|
})),
|
|
69
28
|
context: {
|
|
70
29
|
userNames,
|
|
@@ -117,8 +76,8 @@ export default {
|
|
|
117
76
|
label: "User Group",
|
|
118
77
|
description: "The encoded ID of the User Group.",
|
|
119
78
|
async options() {
|
|
120
|
-
const
|
|
121
|
-
return
|
|
79
|
+
const { usergroups } = await this.usergroupsList();
|
|
80
|
+
return usergroups.map((c) => ({
|
|
122
81
|
label: c.name,
|
|
123
82
|
value: c.id,
|
|
124
83
|
}));
|
|
@@ -128,20 +87,12 @@ export default {
|
|
|
128
87
|
type: "string",
|
|
129
88
|
label: "Reminder",
|
|
130
89
|
description: "Select a reminder",
|
|
131
|
-
async options(
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
label: c.text,
|
|
138
|
-
value: c.id,
|
|
139
|
-
};
|
|
140
|
-
}),
|
|
141
|
-
context: {
|
|
142
|
-
cursor: cursor,
|
|
143
|
-
},
|
|
144
|
-
};
|
|
90
|
+
async options() {
|
|
91
|
+
const { reminders } = await this.remindersList();
|
|
92
|
+
return reminders.map((c) => ({
|
|
93
|
+
label: c.text,
|
|
94
|
+
value: c.id,
|
|
95
|
+
}));
|
|
145
96
|
},
|
|
146
97
|
},
|
|
147
98
|
conversation: {
|
|
@@ -155,7 +106,7 @@ export default {
|
|
|
155
106
|
userNames: userNamesOrPromise,
|
|
156
107
|
} = prevContext;
|
|
157
108
|
if (types == null) {
|
|
158
|
-
const scopes = await this.
|
|
109
|
+
const { response_metadata: { scopes } } = await this.authTest();
|
|
159
110
|
types = [
|
|
160
111
|
"public_channel",
|
|
161
112
|
];
|
|
@@ -206,23 +157,78 @@ export default {
|
|
|
206
157
|
};
|
|
207
158
|
},
|
|
208
159
|
},
|
|
160
|
+
channelId: {
|
|
161
|
+
type: "string",
|
|
162
|
+
label: "Channel ID",
|
|
163
|
+
description: "Select the channel's id.",
|
|
164
|
+
async options({
|
|
165
|
+
prevContext, types = [], channelsFilter = (channel) => channel, excludeArchived = true,
|
|
166
|
+
}) {
|
|
167
|
+
const {
|
|
168
|
+
channels,
|
|
169
|
+
response_metadata: { next_cursor: cursor },
|
|
170
|
+
} = await this.conversationsList({
|
|
171
|
+
types: types.join(),
|
|
172
|
+
cursor: prevContext.cursor,
|
|
173
|
+
limit: constants.LIMIT,
|
|
174
|
+
exclude_archived: excludeArchived,
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
const resourcesInfo = await Promise.all(
|
|
178
|
+
channels
|
|
179
|
+
.filter(channelsFilter)
|
|
180
|
+
.map(async ({
|
|
181
|
+
id: channelId,
|
|
182
|
+
is_im: isIm,
|
|
183
|
+
user,
|
|
184
|
+
}) => ({
|
|
185
|
+
channelId,
|
|
186
|
+
resource: isIm
|
|
187
|
+
? await this.usersInfo({
|
|
188
|
+
user,
|
|
189
|
+
})
|
|
190
|
+
: await this.conversationsInfo({
|
|
191
|
+
channel: channelId,
|
|
192
|
+
}),
|
|
193
|
+
})),
|
|
194
|
+
);
|
|
195
|
+
|
|
196
|
+
const options =
|
|
197
|
+
resourcesInfo.map(({
|
|
198
|
+
channelId, resource,
|
|
199
|
+
}) => ({
|
|
200
|
+
value: channelId,
|
|
201
|
+
label: this.getChannelLabel(resource),
|
|
202
|
+
}));
|
|
203
|
+
|
|
204
|
+
return {
|
|
205
|
+
options,
|
|
206
|
+
context: {
|
|
207
|
+
cursor,
|
|
208
|
+
},
|
|
209
|
+
};
|
|
210
|
+
},
|
|
211
|
+
},
|
|
209
212
|
team: {
|
|
210
213
|
type: "string",
|
|
211
214
|
label: "Team",
|
|
212
215
|
description: "Select a team.",
|
|
213
216
|
async options({ prevContext }) {
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
+
const {
|
|
218
|
+
teams,
|
|
219
|
+
response_metadata: { next_cursor: cursor },
|
|
220
|
+
} = await this.authTeamsList({
|
|
221
|
+
cursor: prevContext.cursor,
|
|
222
|
+
});
|
|
217
223
|
|
|
218
224
|
return {
|
|
219
|
-
options:
|
|
225
|
+
options: teams.map((team) => ({
|
|
220
226
|
label: team.name,
|
|
221
227
|
value: team.id,
|
|
222
228
|
})),
|
|
223
229
|
|
|
224
230
|
context: {
|
|
225
|
-
cursor
|
|
231
|
+
cursor,
|
|
226
232
|
},
|
|
227
233
|
};
|
|
228
234
|
},
|
|
@@ -334,6 +340,9 @@ export default {
|
|
|
334
340
|
label: "Icon (emoji)",
|
|
335
341
|
description: "Optionally provide an emoji to use as the icon for this message. E.g., `:fire:` Overrides `icon_url`. Must be used in conjunction with `as_user` set to `false`, otherwise ignored.",
|
|
336
342
|
optional: true,
|
|
343
|
+
async options() {
|
|
344
|
+
return await this.getCustomEmojis()
|
|
345
|
+
}
|
|
337
346
|
},
|
|
338
347
|
content: {
|
|
339
348
|
label: "File Path",
|
|
@@ -439,30 +448,51 @@ export default {
|
|
|
439
448
|
},
|
|
440
449
|
},
|
|
441
450
|
methods: {
|
|
451
|
+
getChannelLabel(resource) {
|
|
452
|
+
if (resource.user) {
|
|
453
|
+
return `Direct Messaging with: @${resource.user.name}`;
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
const {
|
|
457
|
+
is_private: isPrivate,
|
|
458
|
+
name,
|
|
459
|
+
} = resource.channel;
|
|
460
|
+
|
|
461
|
+
return `${isPrivate && "Private" || "Public"} channel #${name}`;
|
|
462
|
+
},
|
|
442
463
|
mySlackId() {
|
|
443
464
|
return this.$auth.oauth_uid;
|
|
444
465
|
},
|
|
466
|
+
getToken() {
|
|
467
|
+
return this.$auth.oauth_access_token;
|
|
468
|
+
},
|
|
445
469
|
/**
|
|
446
470
|
* Returns a Slack Web Client object authenticated with the user's access
|
|
447
471
|
* token
|
|
448
472
|
*/
|
|
449
473
|
sdk() {
|
|
450
|
-
return new WebClient(this
|
|
451
|
-
},
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
}
|
|
463
|
-
console.log(
|
|
464
|
-
throw
|
|
474
|
+
return new WebClient(this.getToken());
|
|
475
|
+
},
|
|
476
|
+
async makeRequest({
|
|
477
|
+
method = "", ...args
|
|
478
|
+
} = {}) {
|
|
479
|
+
let response;
|
|
480
|
+
const props = method.split(".");
|
|
481
|
+
const sdk = props.reduce((reduction, prop) =>
|
|
482
|
+
reduction[prop], this.sdk());
|
|
483
|
+
|
|
484
|
+
try {
|
|
485
|
+
response = await sdk(args);
|
|
486
|
+
} catch (error) {
|
|
487
|
+
console.log(`Error calling ${method}`, error);
|
|
488
|
+
throw error;
|
|
465
489
|
}
|
|
490
|
+
|
|
491
|
+
if (!response.ok) {
|
|
492
|
+
console.log(`Error in response with method ${method}`, response.error);
|
|
493
|
+
throw response.error;
|
|
494
|
+
}
|
|
495
|
+
return response;
|
|
466
496
|
},
|
|
467
497
|
/**
|
|
468
498
|
* Returns a list of channel-like conversations in a workspace. The
|
|
@@ -477,73 +507,19 @@ export default {
|
|
|
477
507
|
* page of conversations
|
|
478
508
|
*/
|
|
479
509
|
async availableConversations(types, cursor) {
|
|
480
|
-
const
|
|
510
|
+
const {
|
|
511
|
+
channels: conversations,
|
|
512
|
+
response_metadata: { next_cursor: nextCursor },
|
|
513
|
+
} = await this.usersConversations({
|
|
481
514
|
types,
|
|
482
515
|
cursor,
|
|
483
|
-
limit:
|
|
516
|
+
limit: constants.LIMIT,
|
|
484
517
|
exclude_archived: true,
|
|
485
|
-
user: this.$auth.oauth_uid,
|
|
486
|
-
};
|
|
487
|
-
const resp = await this.sdk().users.conversations(params);
|
|
488
|
-
if (resp.ok) {
|
|
489
|
-
return {
|
|
490
|
-
cursor: resp.response_metadata.next_cursor,
|
|
491
|
-
conversations: resp.channels,
|
|
492
|
-
};
|
|
493
|
-
} else {
|
|
494
|
-
console.log("Error getting conversations", resp.error);
|
|
495
|
-
throw (resp.error);
|
|
496
|
-
}
|
|
497
|
-
},
|
|
498
|
-
/**
|
|
499
|
-
* This method lists reminders created by or for a given user
|
|
500
|
-
*
|
|
501
|
-
* @returns an object containing a list of reminders
|
|
502
|
-
*/
|
|
503
|
-
async getRemindersForTeam() {
|
|
504
|
-
const resp = await this.sdk().reminders.list();
|
|
505
|
-
if (resp.ok) {
|
|
506
|
-
return {
|
|
507
|
-
reminders: resp.reminders,
|
|
508
|
-
};
|
|
509
|
-
} else {
|
|
510
|
-
throw (resp.error);
|
|
511
|
-
}
|
|
512
|
-
},
|
|
513
|
-
/**
|
|
514
|
-
* Returns a list of all users in the workspace. This includes
|
|
515
|
-
* deleted/deactivated users.
|
|
516
|
-
*
|
|
517
|
-
* @param {string} [cursor] - a cursor returned by the previous API call,
|
|
518
|
-
* used to paginate through collections of data
|
|
519
|
-
* @returns an object containing a list of users and the cursor for the next
|
|
520
|
-
* page of users
|
|
521
|
-
*/
|
|
522
|
-
async users(cursor) {
|
|
523
|
-
const resp = await this.sdk().users.list({
|
|
524
|
-
cursor,
|
|
525
518
|
});
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
};
|
|
531
|
-
} else {
|
|
532
|
-
console.log("Error getting users", resp.error);
|
|
533
|
-
throw (resp.error);
|
|
534
|
-
}
|
|
535
|
-
},
|
|
536
|
-
/**
|
|
537
|
-
* Returns a list of all users groups in the workspace.
|
|
538
|
-
*/
|
|
539
|
-
async userGroups() {
|
|
540
|
-
const resp = await this.sdk().usergroups.list();
|
|
541
|
-
if (resp.ok) {
|
|
542
|
-
return resp.usergroups;
|
|
543
|
-
} else {
|
|
544
|
-
console.log("Error getting user groups", resp.error);
|
|
545
|
-
throw (resp.error);
|
|
546
|
-
}
|
|
519
|
+
return {
|
|
520
|
+
cursor: nextCursor,
|
|
521
|
+
conversations,
|
|
522
|
+
};
|
|
547
523
|
},
|
|
548
524
|
/**
|
|
549
525
|
* Returns a mapping from user ID to user name for all users in the workspace
|
|
@@ -555,30 +531,229 @@ export default {
|
|
|
555
531
|
const userNames = {};
|
|
556
532
|
do {
|
|
557
533
|
const {
|
|
558
|
-
users,
|
|
559
|
-
|
|
560
|
-
} = await this.
|
|
534
|
+
members: users,
|
|
535
|
+
response_metadata: { next_cursor: nextCursor },
|
|
536
|
+
} = await this.usersList({
|
|
537
|
+
cursor,
|
|
538
|
+
});
|
|
539
|
+
|
|
561
540
|
for (const user of users) {
|
|
562
541
|
userNames[user.id] = user.name;
|
|
563
542
|
}
|
|
543
|
+
|
|
564
544
|
cursor = nextCursor;
|
|
565
545
|
} while (cursor);
|
|
566
546
|
return userNames;
|
|
567
547
|
},
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
548
|
+
/**
|
|
549
|
+
* Checks authentication & identity.
|
|
550
|
+
* @param {*} args Arguments object
|
|
551
|
+
* @returns Promise
|
|
552
|
+
*/
|
|
553
|
+
authTest(args = {}) {
|
|
554
|
+
return this.makeRequest({
|
|
555
|
+
method: "auth.test",
|
|
556
|
+
...args,
|
|
557
|
+
});
|
|
558
|
+
},
|
|
559
|
+
/**
|
|
560
|
+
* Lists all reminders created by or for a given user.
|
|
561
|
+
* @param {*} args Arguments object
|
|
562
|
+
* @param {string} [args.team_id] Encoded team id, required if org token is passed.
|
|
563
|
+
* E.g. `T1234567890`
|
|
564
|
+
* @returns Promise
|
|
565
|
+
*/
|
|
566
|
+
remindersList(args = {}) {
|
|
567
|
+
return this.makeRequest({
|
|
568
|
+
method: "reminders.list",
|
|
569
|
+
...args,
|
|
570
|
+
});
|
|
571
|
+
},
|
|
572
|
+
/**
|
|
573
|
+
* List all User Groups for a team
|
|
574
|
+
* @param {*} args
|
|
575
|
+
* @returns Promise
|
|
576
|
+
*/
|
|
577
|
+
usergroupsList(args = {}) {
|
|
578
|
+
return this.makeRequest({
|
|
579
|
+
method: "usergroups.list",
|
|
580
|
+
...args,
|
|
581
|
+
});
|
|
582
|
+
},
|
|
583
|
+
authTeamsList(args = {}) {
|
|
584
|
+
return this.makeRequest({
|
|
585
|
+
method: "auth.teams.list",
|
|
586
|
+
...args,
|
|
571
587
|
});
|
|
588
|
+
},
|
|
589
|
+
/**
|
|
590
|
+
* List conversations the calling user may access.
|
|
591
|
+
* Bot Scopes: `channels:read` `groups:read` `im:read` `mpim:read`
|
|
592
|
+
* @param {UsersConversationsArguments} args Arguments object
|
|
593
|
+
* @param {string} [args.cursor] Pagination value e.g. (`dXNlcjpVMDYxTkZUVDI=`)
|
|
594
|
+
* @param {boolean} [args.exclude_archived] Set to `true` to exclude archived channels
|
|
595
|
+
* from the list. Defaults to `false`
|
|
596
|
+
* @param {number} [args.limit] Pagination value. Defaults to `0`
|
|
597
|
+
* @param {string} [args.team_id] Encoded team id to list users in,
|
|
598
|
+
* required if org token is used
|
|
599
|
+
* @param {string} [args.types] Mix and match channel types by providing a
|
|
600
|
+
* comma-separated list of any combination of `public_channel`, `private_channel`, `mpim`, `im`
|
|
601
|
+
* Defaults to `public_channel`. E.g. `im,mpim`
|
|
602
|
+
* @param {string} [args.user] Browse conversations by a specific
|
|
603
|
+
* user ID's membership. Non-public channels are restricted to those where the calling user
|
|
604
|
+
* shares membership. E.g `W0B2345D`
|
|
605
|
+
* @returns Promise
|
|
606
|
+
*/
|
|
607
|
+
usersConversations(args = {}) {
|
|
608
|
+
return this.makeRequest({
|
|
609
|
+
method: "users.conversations",
|
|
610
|
+
user: this.$auth.oauth_uid,
|
|
611
|
+
...args,
|
|
612
|
+
});
|
|
613
|
+
},
|
|
614
|
+
/**
|
|
615
|
+
* Lists all users in a Slack team.
|
|
616
|
+
* Bot Scopes: `users:read`
|
|
617
|
+
* @param {UsersListArguments} args Arguments object
|
|
618
|
+
* @param {string} [args.cursor] Pagination value e.g. (`dXNlcjpVMDYxTkZUVDI=`)
|
|
619
|
+
* @param {boolean} [args.include_locale] Set this to `true` to receive the locale
|
|
620
|
+
* for users. Defaults to `false`
|
|
621
|
+
* @param {number} [args.limit] Pagination value. Defaults to `0`
|
|
622
|
+
* @param {string} [args.team_id] Encoded team id to list users in,
|
|
623
|
+
* required if org token is used
|
|
624
|
+
* @returns Promise
|
|
625
|
+
*/
|
|
626
|
+
usersList(args = {}) {
|
|
627
|
+
return this.makeRequest({
|
|
628
|
+
method: "users.list",
|
|
629
|
+
...args,
|
|
630
|
+
});
|
|
631
|
+
},
|
|
632
|
+
/**
|
|
633
|
+
* Lists all channels in a Slack team.
|
|
634
|
+
* Bot Scopes: `channels:read` `groups:read` `im:read` `mpim:read`
|
|
635
|
+
* @param {ConversationsListArguments} args Arguments object
|
|
636
|
+
* @param {string} [args.cursor] Pagination value e.g. (`dXNlcjpVMDYxTkZUVDI=`)
|
|
637
|
+
* @param {boolean} [args.exclude_archived] Set to `true` to exclude archived channels
|
|
638
|
+
* from the list. Defaults to `false`
|
|
639
|
+
* @param {number} [args.limit] pagination value. Defaults to `0`
|
|
640
|
+
* @param {string} [args.team_id] encoded team id to list users in,
|
|
641
|
+
* required if org token is used
|
|
642
|
+
* @param {string} [args.types] Mix and match channel types by providing a
|
|
643
|
+
* comma-separated list of any combination of `public_channel`, `private_channel`, `mpim`, `im`
|
|
644
|
+
* Defaults to `public_channel`. E.g. `im,mpim`
|
|
645
|
+
* @returns Promise
|
|
646
|
+
*/
|
|
647
|
+
conversationsList(args = {}) {
|
|
648
|
+
return this.makeRequest({
|
|
649
|
+
method: "conversations.list",
|
|
650
|
+
...args,
|
|
651
|
+
});
|
|
652
|
+
},
|
|
653
|
+
/**
|
|
654
|
+
* Fetches a conversation's history of messages and events.
|
|
655
|
+
* Bot Scopes: `channels:history` `groups:history` `im:history` `mpim:history`
|
|
656
|
+
* @param {ConversationsHistoryArguments} args Arguments object
|
|
657
|
+
* @param {string} args.channel Conversation ID to fetch history for. E.g. `C1234567890`
|
|
658
|
+
* @param {string} [args.cursor] Pagination value e.g. (`dXNlcjpVMDYxTkZUVDI=`)
|
|
659
|
+
* @param {boolean} [args.include_all_metadata]
|
|
660
|
+
* @param {boolean} [args.inclusive]
|
|
661
|
+
* @param {string} [args.latest]
|
|
662
|
+
* @param {number} [args.limit]
|
|
663
|
+
* @param {string} [args.oldest]
|
|
664
|
+
* @returns Promise
|
|
665
|
+
*/
|
|
666
|
+
conversationsHistory(args = {}) {
|
|
667
|
+
return this.makeRequest({
|
|
668
|
+
method: "conversations.history",
|
|
669
|
+
...args,
|
|
670
|
+
});
|
|
671
|
+
},
|
|
672
|
+
/**
|
|
673
|
+
* Retrieve information about a conversation.
|
|
674
|
+
* Bot Scopes: `channels:read` `groups:read` `im:read` `mpim:read`
|
|
675
|
+
* @param {ConversationsInfoArguments} args Arguments object
|
|
676
|
+
* @param {string} args.channel Conversation ID to learn more about. E.g. `C1234567890`
|
|
677
|
+
* @param {boolean} [args.include_locale] Set this to `true` to receive the locale
|
|
678
|
+
* for users. Defaults to `false`
|
|
679
|
+
* @param {boolean} [args.include_num_members] Set to true to include the
|
|
680
|
+
* member count for the specified conversation. Defaults to `false`
|
|
681
|
+
* @returns Promise
|
|
682
|
+
*/
|
|
683
|
+
conversationsInfo(args = {}) {
|
|
684
|
+
return this.makeRequest({
|
|
685
|
+
method: "conversations.info",
|
|
686
|
+
...args,
|
|
687
|
+
});
|
|
688
|
+
},
|
|
689
|
+
/**
|
|
690
|
+
* Retrieve information about a conversation.
|
|
691
|
+
* Bot Scopes: `users:read`
|
|
692
|
+
* @param {UsersInfoArguments} args arguments object
|
|
693
|
+
* @param {string} args.user User to get info on. E.g. `W1234567890`
|
|
694
|
+
* @param {boolean} [args.include_locale] Set this to true to receive the locale
|
|
695
|
+
* for this user. Defaults to `false`
|
|
696
|
+
* @returns Promise
|
|
697
|
+
*/
|
|
698
|
+
usersInfo(args = {}) {
|
|
699
|
+
return this.makeRequest({
|
|
700
|
+
method: "users.info",
|
|
701
|
+
...args,
|
|
702
|
+
});
|
|
703
|
+
},
|
|
704
|
+
/**
|
|
705
|
+
* Searches for messages matching a query.
|
|
706
|
+
* User Scopes: `search:read`
|
|
707
|
+
* @param {SearchMessagesArguments} args Arguments object
|
|
708
|
+
* @param {string} args.query Search query
|
|
709
|
+
* @param {number} [args.count] Number of items to return per page. Default `20`
|
|
710
|
+
* @param {string} [args.cursor] Use this when getting results with cursormark
|
|
711
|
+
* pagination. For first call send `*` for subsequent calls, send the value of
|
|
712
|
+
* `next_cursor` returned in the previous call's results
|
|
713
|
+
* @param {boolean} [args.highlight]
|
|
714
|
+
* @param {number} [args.page]
|
|
715
|
+
* @param {string} [args.sort]
|
|
716
|
+
* @param {string} [args.sort_dir]
|
|
717
|
+
* @param {string} [args.team_id] Encoded team id to search in,
|
|
718
|
+
* required if org token is used. E.g. `T1234567890`
|
|
719
|
+
* @returns Promise
|
|
720
|
+
*/
|
|
721
|
+
searchMessages(args = {}) {
|
|
722
|
+
return this.makeRequest({
|
|
723
|
+
method: "search.messages",
|
|
724
|
+
...args,
|
|
725
|
+
});
|
|
726
|
+
},
|
|
727
|
+
/**
|
|
728
|
+
* Lists reactions made by a user.
|
|
729
|
+
* User Scopes: `reactions:read`
|
|
730
|
+
* Bot Scopes: `reactions:read`
|
|
731
|
+
* @param {ReactionsListArguments} args Arguments object
|
|
732
|
+
* @param {number} [args.count] Number of items to return per page. Default `100`
|
|
733
|
+
* @param {string} [args.cursor] Parameter for pagination. Set cursor equal to the
|
|
734
|
+
* `next_cursor` attribute returned by the previous request's response_metadata.
|
|
735
|
+
* This parameter is optional, but pagination is mandatory: the default value simply
|
|
736
|
+
* fetches the first "page" of the collection.
|
|
737
|
+
* @param {boolean} [args.full] If true always return the complete reaction list.
|
|
738
|
+
* @param {number} [args.limit] The maximum number of items to return.
|
|
739
|
+
* Fewer than the requested number of items may be returned, even if the end of the
|
|
740
|
+
* list hasn't been reached.
|
|
741
|
+
* @param {number} [args.page] Page number of results to return. Defaults to `1`.
|
|
742
|
+
* @param {string} [args.team_id] Encoded team id to list reactions in,
|
|
743
|
+
* required if org token is used
|
|
744
|
+
* @param {string} [args.user] Show reactions made by this user. Defaults to the authed user.
|
|
745
|
+
* @returns Promise
|
|
746
|
+
*/
|
|
747
|
+
reactionsList(args = {}) {
|
|
748
|
+
return this.makeRequest({
|
|
749
|
+
method: "reactions.list",
|
|
750
|
+
...args,
|
|
751
|
+
});
|
|
752
|
+
},
|
|
753
|
+
async getCustomEmojis(cursor) {
|
|
754
|
+
const resp = await this.sdk().emoji.list();
|
|
572
755
|
|
|
573
|
-
|
|
574
|
-
return {
|
|
575
|
-
cursor: resp.response_metadata.next_cursor,
|
|
576
|
-
teams: resp.teams,
|
|
577
|
-
};
|
|
578
|
-
} else {
|
|
579
|
-
console.log("Error getting teams", resp.error);
|
|
580
|
-
throw (resp.error);
|
|
581
|
-
}
|
|
756
|
+
return Object.keys(resp.emoji)
|
|
582
757
|
},
|
|
583
758
|
},
|
|
584
759
|
};
|
|
@@ -24,7 +24,18 @@ const eventsOptions = [
|
|
|
24
24
|
},
|
|
25
25
|
];
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
const SUBTYPE = {
|
|
28
|
+
NULL: null,
|
|
29
|
+
BOT_MESSAGE: "bot_message",
|
|
30
|
+
FILE_SHARE: "file_share",
|
|
31
|
+
PD_HISTORY_MESSAGE: "pd_history_message",
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
const ALLOWED_SUBTYPES = Object.values(SUBTYPE);
|
|
35
|
+
|
|
36
|
+
export default {
|
|
28
37
|
events,
|
|
29
38
|
eventsOptions,
|
|
39
|
+
SUBTYPE,
|
|
40
|
+
ALLOWED_SUBTYPES,
|
|
30
41
|
};
|
|
@@ -4,7 +4,7 @@ export default {
|
|
|
4
4
|
...common,
|
|
5
5
|
key: "slack-new-direct-message",
|
|
6
6
|
name: "New Direct Message (Instant)",
|
|
7
|
-
version: "1.0.
|
|
7
|
+
version: "1.0.6",
|
|
8
8
|
description: "Emit new event when a message was posted in a direct message channel",
|
|
9
9
|
type: "source",
|
|
10
10
|
dedupe: "unique",
|
|
@@ -2,7 +2,7 @@ import common from "../common/base.mjs";
|
|
|
2
2
|
|
|
3
3
|
export default {
|
|
4
4
|
name: "New Interaction Events",
|
|
5
|
-
version: "0.0.
|
|
5
|
+
version: "0.0.3",
|
|
6
6
|
key: "slack-new-interaction-event-received",
|
|
7
7
|
description:
|
|
8
8
|
"Emit new events on new Slack [interactivity events](https://api.slack.com/interactivity) sourced from [Block Kit interactive elements](https://api.slack.com/interactivity/components), [Slash commands](https://api.slack.com/interactivity/slash-commands), or [Shortcuts](https://api.slack.com/interactivity/shortcuts).",
|