@pipedream/slack_v2 0.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/LICENSE +41 -0
- package/actions/add-emoji-reaction/add-emoji-reaction.mjs +48 -0
- package/actions/approve-workflow/approve-workflow.mjs +92 -0
- package/actions/archive-channel/archive-channel.mjs +38 -0
- package/actions/common/build-blocks.mjs +182 -0
- package/actions/common/send-message.mjs +264 -0
- package/actions/create-channel/create-channel.mjs +40 -0
- package/actions/create-reminder/create-reminder.mjs +52 -0
- package/actions/delete-file/delete-file.mjs +39 -0
- package/actions/delete-message/delete-message.mjs +45 -0
- package/actions/find-message/find-message.mjs +83 -0
- package/actions/find-user-by-email/find-user-by-email.mjs +32 -0
- package/actions/get-current-user/get-current-user.mjs +68 -0
- package/actions/get-file/get-file.mjs +59 -0
- package/actions/invite-user-to-channel/invite-user-to-channel.mjs +45 -0
- package/actions/kick-user/kick-user.mjs +56 -0
- package/actions/list-channels/list-channels.mjs +52 -0
- package/actions/list-files/list-files.mjs +93 -0
- package/actions/list-group-members/list-group-members.mjs +68 -0
- package/actions/list-members-in-channel/list-members-in-channel.mjs +71 -0
- package/actions/list-replies/list-replies.mjs +74 -0
- package/actions/list-users/list-users.mjs +60 -0
- package/actions/reply-to-a-message/reply-to-a-message.mjs +54 -0
- package/actions/send-block-kit-message/send-block-kit-message.mjs +48 -0
- package/actions/send-large-message/send-large-message.mjs +95 -0
- package/actions/send-message/send-message.mjs +56 -0
- package/actions/send-message-advanced/send-message-advanced.mjs +75 -0
- package/actions/send-message-to-channel/send-message-to-channel.mjs +45 -0
- package/actions/send-message-to-user-or-group/send-message-to-user-or-group.mjs +93 -0
- package/actions/set-channel-description/set-channel-description.mjs +37 -0
- package/actions/set-channel-topic/set-channel-topic.mjs +37 -0
- package/actions/set-status/set-status.mjs +49 -0
- package/actions/update-group-members/update-group-members.mjs +72 -0
- package/actions/update-message/update-message.mjs +59 -0
- package/actions/update-profile/update-profile.mjs +94 -0
- package/actions/upload-file/upload-file.mjs +104 -0
- package/common/constants.mjs +31 -0
- package/package.json +22 -0
- package/slack_v2.app.mjs +1112 -0
- package/sources/common/base.mjs +184 -0
- package/sources/common/constants.mjs +58 -0
- package/sources/new-channel-created/new-channel-created.mjs +32 -0
- package/sources/new-channel-created/test-event.mjs +44 -0
- package/sources/new-interaction-event-received/README.md +85 -0
- package/sources/new-interaction-event-received/new-interaction-event-received.mjs +105 -0
- package/sources/new-interaction-event-received/test-event.mjs +86 -0
- package/sources/new-keyword-mention/new-keyword-mention.mjs +99 -0
- package/sources/new-keyword-mention/test-event.mjs +28 -0
- package/sources/new-message-in-channels/new-message-in-channels.mjs +106 -0
- package/sources/new-message-in-channels/test-event.mjs +45 -0
- package/sources/new-reaction-added/new-reaction-added.mjs +119 -0
- package/sources/new-reaction-added/test-event.mjs +193 -0
- package/sources/new-saved-message/new-saved-message.mjs +32 -0
- package/sources/new-saved-message/test-event.mjs +37 -0
- package/sources/new-user-added/new-user-added.mjs +32 -0
- package/sources/new-user-added/test-event.mjs +48 -0
- package/sources/new-user-mention/new-user-mention.mjs +124 -0
- package/sources/new-user-mention/test-event.mjs +28 -0
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import slack from "../../slack_v2.app.mjs";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
key: "slack_v2-create-channel",
|
|
5
|
+
name: "Create a Channel",
|
|
6
|
+
description: "Create a new channel. [See the documentation](https://api.slack.com/methods/conversations.create)",
|
|
7
|
+
version: "0.0.26",
|
|
8
|
+
annotations: {
|
|
9
|
+
destructiveHint: false,
|
|
10
|
+
openWorldHint: true,
|
|
11
|
+
readOnlyHint: false,
|
|
12
|
+
},
|
|
13
|
+
type: "action",
|
|
14
|
+
props: {
|
|
15
|
+
slack,
|
|
16
|
+
channelName: {
|
|
17
|
+
label: "Channel name",
|
|
18
|
+
description: "Name of the public or private channel to create",
|
|
19
|
+
type: "string",
|
|
20
|
+
},
|
|
21
|
+
isPrivate: {
|
|
22
|
+
label: "Is private?",
|
|
23
|
+
type: "boolean",
|
|
24
|
+
description: "`false` by default. Pass `true` to create a private channel instead of a public one.",
|
|
25
|
+
default: false,
|
|
26
|
+
optional: true,
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
async run({ $ }) {
|
|
30
|
+
// parse name
|
|
31
|
+
const name = this.channelName.replace(/\s+/g, "-").toLowerCase();
|
|
32
|
+
|
|
33
|
+
const response = await this.slack.createConversations({
|
|
34
|
+
name,
|
|
35
|
+
is_private: this.isPrivate,
|
|
36
|
+
});
|
|
37
|
+
$.export("$summary", `Successfully created channel ${this.channelName}`);
|
|
38
|
+
return response;
|
|
39
|
+
},
|
|
40
|
+
};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import slack from "../../slack_v2.app.mjs";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
key: "slack_v2-create-reminder",
|
|
5
|
+
name: "Create Reminder",
|
|
6
|
+
description: "Create a reminder. [See the documentation](https://api.slack.com/methods/reminders.add)",
|
|
7
|
+
version: "0.0.26",
|
|
8
|
+
annotations: {
|
|
9
|
+
destructiveHint: false,
|
|
10
|
+
openWorldHint: true,
|
|
11
|
+
readOnlyHint: false,
|
|
12
|
+
},
|
|
13
|
+
type: "action",
|
|
14
|
+
props: {
|
|
15
|
+
slack,
|
|
16
|
+
text: {
|
|
17
|
+
propDefinition: [
|
|
18
|
+
slack,
|
|
19
|
+
"text",
|
|
20
|
+
],
|
|
21
|
+
},
|
|
22
|
+
timestamp: {
|
|
23
|
+
type: "string",
|
|
24
|
+
label: "Timestamp",
|
|
25
|
+
description: "When this reminder should happen: the Unix timestamp (up to five years from now), the number of seconds until the reminder (if within 24 hours), or a natural language description (Ex. in 15 minutes, or every Thursday)",
|
|
26
|
+
},
|
|
27
|
+
team_id: {
|
|
28
|
+
propDefinition: [
|
|
29
|
+
slack,
|
|
30
|
+
"team",
|
|
31
|
+
],
|
|
32
|
+
optional: true,
|
|
33
|
+
},
|
|
34
|
+
user: {
|
|
35
|
+
propDefinition: [
|
|
36
|
+
slack,
|
|
37
|
+
"user",
|
|
38
|
+
],
|
|
39
|
+
optional: true,
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
async run({ $ }) {
|
|
43
|
+
const response = await this.slack.addReminders({
|
|
44
|
+
text: this.text,
|
|
45
|
+
team_id: this.team_id,
|
|
46
|
+
time: this.timestamp,
|
|
47
|
+
user: this.user,
|
|
48
|
+
});
|
|
49
|
+
$.export("$summary", `Successfully created reminder with ID ${response.reminder.id}`);
|
|
50
|
+
return response;
|
|
51
|
+
},
|
|
52
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import slack from "../../slack_v2.app.mjs";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
key: "slack_v2-delete-file",
|
|
5
|
+
name: "Delete File",
|
|
6
|
+
description: "Delete a file. [See the documentation](https://api.slack.com/methods/files.delete)",
|
|
7
|
+
version: "0.0.25",
|
|
8
|
+
annotations: {
|
|
9
|
+
destructiveHint: true,
|
|
10
|
+
openWorldHint: true,
|
|
11
|
+
readOnlyHint: false,
|
|
12
|
+
},
|
|
13
|
+
type: "action",
|
|
14
|
+
props: {
|
|
15
|
+
slack,
|
|
16
|
+
conversation: {
|
|
17
|
+
propDefinition: [
|
|
18
|
+
slack,
|
|
19
|
+
"conversation",
|
|
20
|
+
],
|
|
21
|
+
},
|
|
22
|
+
file: {
|
|
23
|
+
propDefinition: [
|
|
24
|
+
slack,
|
|
25
|
+
"file",
|
|
26
|
+
(c) => ({
|
|
27
|
+
channel: c.conversation,
|
|
28
|
+
}),
|
|
29
|
+
],
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
async run({ $ }) {
|
|
33
|
+
const response = await this.slack.deleteFiles({
|
|
34
|
+
file: this.file,
|
|
35
|
+
});
|
|
36
|
+
$.export("$summary", `Successfully deleted file with ID ${this.file}`);
|
|
37
|
+
return response;
|
|
38
|
+
},
|
|
39
|
+
};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import slack from "../../slack_v2.app.mjs";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
key: "slack_v2-delete-message",
|
|
5
|
+
name: "Delete Message",
|
|
6
|
+
description: "Delete a message. [See the documentation](https://api.slack.com/methods/chat.delete)",
|
|
7
|
+
version: "0.1.0",
|
|
8
|
+
annotations: {
|
|
9
|
+
destructiveHint: true,
|
|
10
|
+
openWorldHint: true,
|
|
11
|
+
readOnlyHint: false,
|
|
12
|
+
},
|
|
13
|
+
type: "action",
|
|
14
|
+
props: {
|
|
15
|
+
slack,
|
|
16
|
+
conversation: {
|
|
17
|
+
propDefinition: [
|
|
18
|
+
slack,
|
|
19
|
+
"conversation",
|
|
20
|
+
],
|
|
21
|
+
},
|
|
22
|
+
timestamp: {
|
|
23
|
+
propDefinition: [
|
|
24
|
+
slack,
|
|
25
|
+
"messageTs",
|
|
26
|
+
],
|
|
27
|
+
},
|
|
28
|
+
as_user: {
|
|
29
|
+
propDefinition: [
|
|
30
|
+
slack,
|
|
31
|
+
"as_user",
|
|
32
|
+
],
|
|
33
|
+
description: "Pass true to update the message as the authed user. Bot users in this context are considered authed users.",
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
async run({ $ }) {
|
|
37
|
+
const response = await this.slack.deleteMessage({
|
|
38
|
+
channel: this.conversation,
|
|
39
|
+
ts: this.timestamp,
|
|
40
|
+
as_user: this.as_user,
|
|
41
|
+
});
|
|
42
|
+
$.export("$summary", "Successfully deleted message.");
|
|
43
|
+
return response;
|
|
44
|
+
},
|
|
45
|
+
};
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import slack from "../../slack_v2.app.mjs";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
key: "slack_v2-find-message",
|
|
5
|
+
name: "Find Message",
|
|
6
|
+
description: "Find a Slack message. [See the documentation](https://api.slack.com/methods/assistant.search.context)",
|
|
7
|
+
version: "0.1.0",
|
|
8
|
+
annotations: {
|
|
9
|
+
destructiveHint: false,
|
|
10
|
+
openWorldHint: true,
|
|
11
|
+
readOnlyHint: true,
|
|
12
|
+
},
|
|
13
|
+
type: "action",
|
|
14
|
+
props: {
|
|
15
|
+
slack,
|
|
16
|
+
query: {
|
|
17
|
+
propDefinition: [
|
|
18
|
+
slack,
|
|
19
|
+
"query",
|
|
20
|
+
],
|
|
21
|
+
},
|
|
22
|
+
maxResults: {
|
|
23
|
+
type: "integer",
|
|
24
|
+
label: "Max Results",
|
|
25
|
+
description: "The maximum number of messages to return",
|
|
26
|
+
default: 20,
|
|
27
|
+
optional: true,
|
|
28
|
+
},
|
|
29
|
+
sort: {
|
|
30
|
+
type: "string",
|
|
31
|
+
label: "Sort",
|
|
32
|
+
description: "Return matches sorted by either `score` or `timestamp`",
|
|
33
|
+
options: [
|
|
34
|
+
"score",
|
|
35
|
+
"timestamp",
|
|
36
|
+
],
|
|
37
|
+
optional: true,
|
|
38
|
+
},
|
|
39
|
+
sortDirection: {
|
|
40
|
+
type: "string",
|
|
41
|
+
label: "Sort Direction",
|
|
42
|
+
description: "Sort ascending (asc) or descending (desc)",
|
|
43
|
+
options: [
|
|
44
|
+
"desc",
|
|
45
|
+
"asc",
|
|
46
|
+
],
|
|
47
|
+
optional: true,
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
methods: {
|
|
51
|
+
async searchWithAssistant(baseParams, maxResults) {
|
|
52
|
+
const matches = [];
|
|
53
|
+
let cursor;
|
|
54
|
+
|
|
55
|
+
do {
|
|
56
|
+
const response = await this.slack.assistantSearch({
|
|
57
|
+
...baseParams,
|
|
58
|
+
channel_types: "public_channel,private_channel",
|
|
59
|
+
cursor,
|
|
60
|
+
});
|
|
61
|
+
matches.push(...response.results?.messages || []);
|
|
62
|
+
cursor = response.response_metadata?.next_cursor;
|
|
63
|
+
} while (cursor && matches.length < maxResults);
|
|
64
|
+
|
|
65
|
+
return matches.slice(0, maxResults);
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
async run({ $ }) {
|
|
69
|
+
const maxResults = Math.max(this.maxResults ?? 20, 1);
|
|
70
|
+
const baseParams = {
|
|
71
|
+
query: this.query,
|
|
72
|
+
sort: this.sort,
|
|
73
|
+
sort_dir: this.sortDirection,
|
|
74
|
+
};
|
|
75
|
+
const matches = await this.searchWithAssistant(baseParams, maxResults);
|
|
76
|
+
|
|
77
|
+
$.export("$summary", `Found ${matches.length} matching message${matches.length === 1
|
|
78
|
+
? ""
|
|
79
|
+
: "s"}`);
|
|
80
|
+
|
|
81
|
+
return matches;
|
|
82
|
+
},
|
|
83
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import slack from "../../slack_v2.app.mjs";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
key: "slack_v2-find-user-by-email",
|
|
5
|
+
name: "Find User by Email",
|
|
6
|
+
description: "Find a user by matching against their email. [See the documentation](https://api.slack.com/methods/users.lookupByEmail)",
|
|
7
|
+
version: "0.0.25",
|
|
8
|
+
annotations: {
|
|
9
|
+
destructiveHint: false,
|
|
10
|
+
openWorldHint: true,
|
|
11
|
+
readOnlyHint: true,
|
|
12
|
+
},
|
|
13
|
+
type: "action",
|
|
14
|
+
props: {
|
|
15
|
+
slack,
|
|
16
|
+
email: {
|
|
17
|
+
propDefinition: [
|
|
18
|
+
slack,
|
|
19
|
+
"email",
|
|
20
|
+
],
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
async run({ $ }) {
|
|
24
|
+
const response = await this.slack.lookupUserByEmail({
|
|
25
|
+
email: this.email,
|
|
26
|
+
});
|
|
27
|
+
if (response.ok) {
|
|
28
|
+
$.export("$summary", `Successfully found user with ID ${response.user.id}`);
|
|
29
|
+
}
|
|
30
|
+
return response;
|
|
31
|
+
},
|
|
32
|
+
};
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import slack from "../../slack_v2.app.mjs";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
key: "slack_v2-get-current-user",
|
|
5
|
+
name: "Get Current User",
|
|
6
|
+
description: "Retrieve comprehensive context about the authenticated Slack member, combining `auth.test`, `users.info`, `users.profile.get`, and `team.info` payloads. Returns the user’s profile (name variants, email, locale, timezone, status, admin flags), raw auth test data, and workspace metadata (domain, enterprise info, icons). Ideal when you need to confirm which user token is active, tailor messages to their locale/timezone, or ground an LLM in the member’s role and workspace before executing other Slack actions. [See Slack API docs](https://api.slack.com/methods/auth.test).",
|
|
7
|
+
version: "0.0.1",
|
|
8
|
+
type: "action",
|
|
9
|
+
annotations: {
|
|
10
|
+
destructiveHint: false,
|
|
11
|
+
openWorldHint: true,
|
|
12
|
+
readOnlyHint: true,
|
|
13
|
+
},
|
|
14
|
+
props: {
|
|
15
|
+
slack,
|
|
16
|
+
},
|
|
17
|
+
async run({ $ }) {
|
|
18
|
+
const authContext = await this.slack.authTest();
|
|
19
|
+
|
|
20
|
+
const userId = authContext.user_id || authContext.user;
|
|
21
|
+
if (!userId) {
|
|
22
|
+
throw new Error(`Unable to determine user ID from auth context. Received: ${JSON.stringify(authContext)}`);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
let userInfo;
|
|
26
|
+
try {
|
|
27
|
+
userInfo = await this.slack.usersInfo({
|
|
28
|
+
user: userId,
|
|
29
|
+
include_locale: true,
|
|
30
|
+
});
|
|
31
|
+
} catch (error) {
|
|
32
|
+
// Gracefully degrade if scope not available
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
let userProfile;
|
|
36
|
+
try {
|
|
37
|
+
userProfile = await this.slack.getUserProfile({
|
|
38
|
+
user: userId,
|
|
39
|
+
});
|
|
40
|
+
} catch (error) {
|
|
41
|
+
// Gracefully degrade if scope not available
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
let teamInfo;
|
|
45
|
+
try {
|
|
46
|
+
teamInfo = await this.slack.getTeamInfo();
|
|
47
|
+
} catch (error) {
|
|
48
|
+
// Gracefully degrade if scope not available
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const user = userInfo?.user;
|
|
52
|
+
const profile = userProfile?.profile ?? user?.profile;
|
|
53
|
+
const summaryName =
|
|
54
|
+
profile?.real_name_normalized
|
|
55
|
+
|| profile?.display_name_normalized
|
|
56
|
+
|| authContext.user
|
|
57
|
+
|| userId;
|
|
58
|
+
|
|
59
|
+
$.export("$summary", `Retrieved Slack user ${summaryName}`);
|
|
60
|
+
|
|
61
|
+
return {
|
|
62
|
+
authContext,
|
|
63
|
+
user,
|
|
64
|
+
profile,
|
|
65
|
+
team: teamInfo?.team,
|
|
66
|
+
};
|
|
67
|
+
},
|
|
68
|
+
};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import constants from "../../common/constants.mjs";
|
|
2
|
+
import slack from "../../slack_v2.app.mjs";
|
|
3
|
+
|
|
4
|
+
export default {
|
|
5
|
+
key: "slack_v2-get-file",
|
|
6
|
+
name: "Get File",
|
|
7
|
+
description: "Return information about a file. [See the documentation](https://api.slack.com/methods/files.info)",
|
|
8
|
+
version: "0.1.0",
|
|
9
|
+
annotations: {
|
|
10
|
+
destructiveHint: false,
|
|
11
|
+
openWorldHint: true,
|
|
12
|
+
readOnlyHint: true,
|
|
13
|
+
},
|
|
14
|
+
type: "action",
|
|
15
|
+
props: {
|
|
16
|
+
slack,
|
|
17
|
+
conversation: {
|
|
18
|
+
propDefinition: [
|
|
19
|
+
slack,
|
|
20
|
+
"conversation",
|
|
21
|
+
() => ({
|
|
22
|
+
types: [
|
|
23
|
+
constants.CHANNEL_TYPE.PUBLIC,
|
|
24
|
+
constants.CHANNEL_TYPE.PRIVATE,
|
|
25
|
+
],
|
|
26
|
+
}),
|
|
27
|
+
],
|
|
28
|
+
description: "Select a public or private channel",
|
|
29
|
+
},
|
|
30
|
+
addToChannel: {
|
|
31
|
+
propDefinition: [
|
|
32
|
+
slack,
|
|
33
|
+
"addToChannel",
|
|
34
|
+
],
|
|
35
|
+
},
|
|
36
|
+
file: {
|
|
37
|
+
propDefinition: [
|
|
38
|
+
slack,
|
|
39
|
+
"file",
|
|
40
|
+
(c) => ({
|
|
41
|
+
channel: c.conversation,
|
|
42
|
+
}),
|
|
43
|
+
],
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
async run({ $ }) {
|
|
47
|
+
if (this.addToChannel) {
|
|
48
|
+
await this.slack.maybeAddAppToChannels([
|
|
49
|
+
this.conversation,
|
|
50
|
+
]);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const response = await this.slack.getFileInfo({
|
|
54
|
+
file: this.file,
|
|
55
|
+
});
|
|
56
|
+
$.export("$summary", `Successfully retrieved file with ID ${this.file}`);
|
|
57
|
+
return response;
|
|
58
|
+
},
|
|
59
|
+
};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import slack from "../../slack_v2.app.mjs";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
key: "slack_v2-invite-user-to-channel",
|
|
5
|
+
name: "Invite User to Channel",
|
|
6
|
+
description: "Invite a user to an existing channel. [See the documentation](https://api.slack.com/methods/conversations.invite)",
|
|
7
|
+
version: "0.0.25",
|
|
8
|
+
annotations: {
|
|
9
|
+
destructiveHint: false,
|
|
10
|
+
openWorldHint: true,
|
|
11
|
+
readOnlyHint: false,
|
|
12
|
+
},
|
|
13
|
+
type: "action",
|
|
14
|
+
props: {
|
|
15
|
+
slack,
|
|
16
|
+
conversation: {
|
|
17
|
+
propDefinition: [
|
|
18
|
+
slack,
|
|
19
|
+
"conversation",
|
|
20
|
+
],
|
|
21
|
+
},
|
|
22
|
+
user: {
|
|
23
|
+
propDefinition: [
|
|
24
|
+
slack,
|
|
25
|
+
"user",
|
|
26
|
+
],
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
async run({ $ }) {
|
|
30
|
+
try {
|
|
31
|
+
const response = await this.slack.inviteToConversation({
|
|
32
|
+
channel: this.conversation,
|
|
33
|
+
users: this.user,
|
|
34
|
+
});
|
|
35
|
+
$.export("$summary", `Successfully invited user ${this.user} to channel with ID ${this.conversation}`);
|
|
36
|
+
return response;
|
|
37
|
+
} catch (error) {
|
|
38
|
+
if (`${error}`.includes("already_in_channel")) {
|
|
39
|
+
$.export("$summary", `The user ${this.user} is already in the channel`);
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
throw error;
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import slack from "../../slack_v2.app.mjs";
|
|
2
|
+
import constants from "../../common/constants.mjs";
|
|
3
|
+
|
|
4
|
+
export default {
|
|
5
|
+
key: "slack_v2-kick-user",
|
|
6
|
+
name: "Kick User",
|
|
7
|
+
description: "Remove a user from a conversation. [See the documentation](https://api.slack.com/methods/conversations.kick)",
|
|
8
|
+
version: "0.0.25",
|
|
9
|
+
annotations: {
|
|
10
|
+
destructiveHint: true,
|
|
11
|
+
openWorldHint: true,
|
|
12
|
+
readOnlyHint: false,
|
|
13
|
+
},
|
|
14
|
+
type: "action",
|
|
15
|
+
props: {
|
|
16
|
+
slack,
|
|
17
|
+
conversation: {
|
|
18
|
+
propDefinition: [
|
|
19
|
+
slack,
|
|
20
|
+
"conversation",
|
|
21
|
+
() => ({
|
|
22
|
+
types: [
|
|
23
|
+
constants.CHANNEL_TYPE.PUBLIC,
|
|
24
|
+
constants.CHANNEL_TYPE.PRIVATE,
|
|
25
|
+
constants.CHANNEL_TYPE.MPIM,
|
|
26
|
+
],
|
|
27
|
+
}),
|
|
28
|
+
],
|
|
29
|
+
},
|
|
30
|
+
user: {
|
|
31
|
+
propDefinition: [
|
|
32
|
+
slack,
|
|
33
|
+
"user",
|
|
34
|
+
(c) => ({
|
|
35
|
+
channelId: c.conversation,
|
|
36
|
+
}),
|
|
37
|
+
],
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
async run({ $ }) {
|
|
41
|
+
try {
|
|
42
|
+
const response = await this.slack.kickUserFromConversation({
|
|
43
|
+
channel: this.conversation,
|
|
44
|
+
user: this.user,
|
|
45
|
+
});
|
|
46
|
+
$.export("$summary", `Successfully kicked user ${this.user} from channel with ID ${this.conversation}`);
|
|
47
|
+
return response;
|
|
48
|
+
} catch (error) {
|
|
49
|
+
if (`${error}`.includes("not_in_channel")) {
|
|
50
|
+
$.export("$summary", `The user ${this.user} is not in the channel`);
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
throw error;
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import slack from "../../slack_v2.app.mjs";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
key: "slack_v2-list-channels",
|
|
5
|
+
name: "List Channels",
|
|
6
|
+
description: "Return a list of all channels in a workspace. [See the documentation](https://api.slack.com/methods/conversations.list)",
|
|
7
|
+
version: "0.0.25",
|
|
8
|
+
annotations: {
|
|
9
|
+
destructiveHint: false,
|
|
10
|
+
openWorldHint: true,
|
|
11
|
+
readOnlyHint: true,
|
|
12
|
+
},
|
|
13
|
+
type: "action",
|
|
14
|
+
props: {
|
|
15
|
+
slack,
|
|
16
|
+
pageSize: {
|
|
17
|
+
propDefinition: [
|
|
18
|
+
slack,
|
|
19
|
+
"pageSize",
|
|
20
|
+
],
|
|
21
|
+
},
|
|
22
|
+
numPages: {
|
|
23
|
+
propDefinition: [
|
|
24
|
+
slack,
|
|
25
|
+
"numPages",
|
|
26
|
+
],
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
async run({ $ }) {
|
|
30
|
+
const allChannels = [];
|
|
31
|
+
const params = {
|
|
32
|
+
limit: this.pageSize,
|
|
33
|
+
};
|
|
34
|
+
let page = 0;
|
|
35
|
+
|
|
36
|
+
do {
|
|
37
|
+
const {
|
|
38
|
+
channels, response_metadata: { next_cursor: nextCursor },
|
|
39
|
+
} = await this.slack.conversationsList(params);
|
|
40
|
+
allChannels.push(...channels);
|
|
41
|
+
params.cursor = nextCursor;
|
|
42
|
+
page++;
|
|
43
|
+
} while (params.cursor && page < this.numPages);
|
|
44
|
+
|
|
45
|
+
$.export("$summary", `Successfully found ${allChannels.length} channel${allChannels.length === 1
|
|
46
|
+
? ""
|
|
47
|
+
: "s"}`);
|
|
48
|
+
return {
|
|
49
|
+
channels: allChannels,
|
|
50
|
+
};
|
|
51
|
+
},
|
|
52
|
+
};
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import constants from "../../common/constants.mjs";
|
|
2
|
+
import slack from "../../slack_v2.app.mjs";
|
|
3
|
+
|
|
4
|
+
export default {
|
|
5
|
+
key: "slack_v2-list-files",
|
|
6
|
+
name: "List Files",
|
|
7
|
+
description: "Return a list of files within a team. [See the documentation](https://api.slack.com/methods/files.list)",
|
|
8
|
+
version: "0.1.0",
|
|
9
|
+
annotations: {
|
|
10
|
+
destructiveHint: false,
|
|
11
|
+
openWorldHint: true,
|
|
12
|
+
readOnlyHint: true,
|
|
13
|
+
},
|
|
14
|
+
type: "action",
|
|
15
|
+
props: {
|
|
16
|
+
slack,
|
|
17
|
+
conversation: {
|
|
18
|
+
propDefinition: [
|
|
19
|
+
slack,
|
|
20
|
+
"conversation",
|
|
21
|
+
() => ({
|
|
22
|
+
types: [
|
|
23
|
+
constants.CHANNEL_TYPE.PUBLIC,
|
|
24
|
+
constants.CHANNEL_TYPE.PRIVATE,
|
|
25
|
+
],
|
|
26
|
+
}),
|
|
27
|
+
],
|
|
28
|
+
description: "Select a public or private channel",
|
|
29
|
+
},
|
|
30
|
+
addToChannel: {
|
|
31
|
+
propDefinition: [
|
|
32
|
+
slack,
|
|
33
|
+
"addToChannel",
|
|
34
|
+
],
|
|
35
|
+
},
|
|
36
|
+
team_id: {
|
|
37
|
+
propDefinition: [
|
|
38
|
+
slack,
|
|
39
|
+
"team",
|
|
40
|
+
],
|
|
41
|
+
optional: true,
|
|
42
|
+
},
|
|
43
|
+
user: {
|
|
44
|
+
propDefinition: [
|
|
45
|
+
slack,
|
|
46
|
+
"user",
|
|
47
|
+
],
|
|
48
|
+
optional: true,
|
|
49
|
+
},
|
|
50
|
+
pageSize: {
|
|
51
|
+
propDefinition: [
|
|
52
|
+
slack,
|
|
53
|
+
"pageSize",
|
|
54
|
+
],
|
|
55
|
+
},
|
|
56
|
+
numPages: {
|
|
57
|
+
propDefinition: [
|
|
58
|
+
slack,
|
|
59
|
+
"numPages",
|
|
60
|
+
],
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
async run({ $ }) {
|
|
64
|
+
if (this.addToChannel) {
|
|
65
|
+
await this.slack.maybeAddAppToChannels([
|
|
66
|
+
this.conversation,
|
|
67
|
+
]);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const allFiles = [];
|
|
71
|
+
const params = {
|
|
72
|
+
channel: this.conversation,
|
|
73
|
+
user: this.user,
|
|
74
|
+
team_id: this.team_id,
|
|
75
|
+
page: 1,
|
|
76
|
+
count: this.pageSize,
|
|
77
|
+
};
|
|
78
|
+
let hasMore;
|
|
79
|
+
|
|
80
|
+
do {
|
|
81
|
+
const { files } = await this.slack.listFiles(params);
|
|
82
|
+
allFiles.push(...files);
|
|
83
|
+
hasMore = files.length;
|
|
84
|
+
params.page++;
|
|
85
|
+
} while (hasMore && params.page <= this.numPages);
|
|
86
|
+
|
|
87
|
+
$.export("$summary", `Successfully retrieved ${allFiles.length} file${allFiles.length === 1
|
|
88
|
+
? ""
|
|
89
|
+
: "s"}`);
|
|
90
|
+
|
|
91
|
+
return allFiles;
|
|
92
|
+
},
|
|
93
|
+
};
|