@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.
Files changed (58) hide show
  1. package/LICENSE +41 -0
  2. package/actions/add-emoji-reaction/add-emoji-reaction.mjs +48 -0
  3. package/actions/approve-workflow/approve-workflow.mjs +92 -0
  4. package/actions/archive-channel/archive-channel.mjs +38 -0
  5. package/actions/common/build-blocks.mjs +182 -0
  6. package/actions/common/send-message.mjs +264 -0
  7. package/actions/create-channel/create-channel.mjs +40 -0
  8. package/actions/create-reminder/create-reminder.mjs +52 -0
  9. package/actions/delete-file/delete-file.mjs +39 -0
  10. package/actions/delete-message/delete-message.mjs +45 -0
  11. package/actions/find-message/find-message.mjs +83 -0
  12. package/actions/find-user-by-email/find-user-by-email.mjs +32 -0
  13. package/actions/get-current-user/get-current-user.mjs +68 -0
  14. package/actions/get-file/get-file.mjs +59 -0
  15. package/actions/invite-user-to-channel/invite-user-to-channel.mjs +45 -0
  16. package/actions/kick-user/kick-user.mjs +56 -0
  17. package/actions/list-channels/list-channels.mjs +52 -0
  18. package/actions/list-files/list-files.mjs +93 -0
  19. package/actions/list-group-members/list-group-members.mjs +68 -0
  20. package/actions/list-members-in-channel/list-members-in-channel.mjs +71 -0
  21. package/actions/list-replies/list-replies.mjs +74 -0
  22. package/actions/list-users/list-users.mjs +60 -0
  23. package/actions/reply-to-a-message/reply-to-a-message.mjs +54 -0
  24. package/actions/send-block-kit-message/send-block-kit-message.mjs +48 -0
  25. package/actions/send-large-message/send-large-message.mjs +95 -0
  26. package/actions/send-message/send-message.mjs +56 -0
  27. package/actions/send-message-advanced/send-message-advanced.mjs +75 -0
  28. package/actions/send-message-to-channel/send-message-to-channel.mjs +45 -0
  29. package/actions/send-message-to-user-or-group/send-message-to-user-or-group.mjs +93 -0
  30. package/actions/set-channel-description/set-channel-description.mjs +37 -0
  31. package/actions/set-channel-topic/set-channel-topic.mjs +37 -0
  32. package/actions/set-status/set-status.mjs +49 -0
  33. package/actions/update-group-members/update-group-members.mjs +72 -0
  34. package/actions/update-message/update-message.mjs +59 -0
  35. package/actions/update-profile/update-profile.mjs +94 -0
  36. package/actions/upload-file/upload-file.mjs +104 -0
  37. package/common/constants.mjs +31 -0
  38. package/package.json +22 -0
  39. package/slack_v2.app.mjs +1112 -0
  40. package/sources/common/base.mjs +184 -0
  41. package/sources/common/constants.mjs +58 -0
  42. package/sources/new-channel-created/new-channel-created.mjs +32 -0
  43. package/sources/new-channel-created/test-event.mjs +44 -0
  44. package/sources/new-interaction-event-received/README.md +85 -0
  45. package/sources/new-interaction-event-received/new-interaction-event-received.mjs +105 -0
  46. package/sources/new-interaction-event-received/test-event.mjs +86 -0
  47. package/sources/new-keyword-mention/new-keyword-mention.mjs +99 -0
  48. package/sources/new-keyword-mention/test-event.mjs +28 -0
  49. package/sources/new-message-in-channels/new-message-in-channels.mjs +106 -0
  50. package/sources/new-message-in-channels/test-event.mjs +45 -0
  51. package/sources/new-reaction-added/new-reaction-added.mjs +119 -0
  52. package/sources/new-reaction-added/test-event.mjs +193 -0
  53. package/sources/new-saved-message/new-saved-message.mjs +32 -0
  54. package/sources/new-saved-message/test-event.mjs +37 -0
  55. package/sources/new-user-added/new-user-added.mjs +32 -0
  56. package/sources/new-user-added/test-event.mjs +48 -0
  57. package/sources/new-user-mention/new-user-mention.mjs +124 -0
  58. package/sources/new-user-mention/test-event.mjs +28 -0
@@ -0,0 +1,124 @@
1
+ import common from "../common/base.mjs";
2
+ import constants from "../common/constants.mjs";
3
+ import sampleEmit from "./test-event.mjs";
4
+ import sharedConstants from "../../common/constants.mjs";
5
+
6
+ export default {
7
+ ...common,
8
+ key: "slack_v2-new-user-mention",
9
+ name: "New User Mention (Instant)",
10
+ version: "0.1.0",
11
+ description: "Emit new event when a username or specific keyword is mentioned in a channel",
12
+ type: "source",
13
+ dedupe: "unique",
14
+ props: {
15
+ ...common.props,
16
+ conversations: {
17
+ propDefinition: [
18
+ common.props.slack,
19
+ "conversation",
20
+ () => ({
21
+ types: [
22
+ sharedConstants.CHANNEL_TYPE.PUBLIC,
23
+ sharedConstants.CHANNEL_TYPE.PRIVATE,
24
+ ],
25
+ }),
26
+ ],
27
+ type: "string[]",
28
+ label: "Channels",
29
+ description: "Select one or more channels to monitor for new messages.",
30
+ optional: true,
31
+ },
32
+ // eslint-disable-next-line pipedream/props-description,pipedream/props-label
33
+ slackApphook: {
34
+ type: "$.interface.apphook",
35
+ appProp: "slack",
36
+ async eventNames() {
37
+ return this.conversations || [
38
+ "message",
39
+ ];
40
+ },
41
+ },
42
+ user: {
43
+ propDefinition: [
44
+ common.props.slack,
45
+ "user",
46
+ ],
47
+ },
48
+ keyword: {
49
+ propDefinition: [
50
+ common.props.slack,
51
+ "keyword",
52
+ ],
53
+ optional: true,
54
+ },
55
+ ignoreBot: {
56
+ propDefinition: [
57
+ common.props.slack,
58
+ "ignoreBot",
59
+ ],
60
+ },
61
+ },
62
+ methods: {
63
+ ...common.methods,
64
+ getSummary() {
65
+ return "New mention received";
66
+ },
67
+ async processEvent(event) {
68
+ const {
69
+ type: msgType,
70
+ subtype,
71
+ bot_id: botId,
72
+ text,
73
+ blocks = [],
74
+ } = event;
75
+ const [
76
+ {
77
+ elements: [
78
+ { elements = [] } = {},
79
+ ] = [],
80
+ } = {},
81
+ ] = blocks;
82
+
83
+ if (msgType !== "message") {
84
+ console.log(`Ignoring event with unexpected type "${msgType}"`);
85
+ return;
86
+ }
87
+
88
+ // This source is designed to just emit an event for each new message received.
89
+ // Due to inconsistencies with the shape of message_changed and message_deleted
90
+ // events, we are ignoring them for now. If you want to handle these types of
91
+ // events, feel free to change this code!!
92
+ if (subtype && !constants.ALLOWED_SUBTYPES.includes(subtype)) {
93
+ console.log(`Ignoring message with subtype. "${subtype}"`);
94
+ return;
95
+ }
96
+
97
+ if ((this.ignoreBot) && (subtype === constants.SUBTYPE.BOT_MESSAGE || botId)) {
98
+ return;
99
+ }
100
+
101
+ let emitEvent = false;
102
+ if (elements) {
103
+ let userMatch = false;
104
+ for (const item of elements) {
105
+ if (item.user_id && item.user_id === this.user) {
106
+ userMatch = true;
107
+ break;
108
+ }
109
+ }
110
+ if (userMatch && (!this.keyword || text.indexOf(this.keyword) !== -1)) {
111
+ emitEvent = true;
112
+ }
113
+ }
114
+ if (subtype === constants.SUBTYPE.PD_HISTORY_MESSAGE) {
115
+ emitEvent = true;
116
+ }
117
+
118
+ if (emitEvent) {
119
+ return event;
120
+ }
121
+ },
122
+ },
123
+ sampleEmit,
124
+ };
@@ -0,0 +1,28 @@
1
+ export default {
2
+ "user": "US676PZLY",
3
+ "type": "message",
4
+ "ts": "1716404766.096289",
5
+ "client_msg_id": "b26387fd-5afe-46a9-bf63-a7aabd6fb40f",
6
+ "text": "hello",
7
+ "team": "TS8319547",
8
+ "blocks": [
9
+ {
10
+ "type": "rich_text",
11
+ "block_id": "aY6KK",
12
+ "elements": [
13
+ {
14
+ "type": "rich_text_section",
15
+ "elements": [
16
+ {
17
+ "type": "text",
18
+ "text": "hello"
19
+ }
20
+ ]
21
+ }
22
+ ]
23
+ }
24
+ ],
25
+ "channel": "CS8319KD5",
26
+ "event_ts": "1716404766.096289",
27
+ "channel_type": "channel"
28
+ }