-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
168 lines (127 loc) · 4.57 KB
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
require('dotenv').config();
const {App} = require('@slack/bolt');
const app = new App({
token:process.env.SLACK_APP_BOT_TOKEN,
socketMode:true,
appToken:process.env.SLACK_APP_TOKEN,
signingSecret:process.env.SLACK_APP_SIGNING_SECRET
})
app.message('@1y', async ({ message, say }) => {
const mentionedUsers = [
message.user, // Mentioning the user who sent the message
'anshul240903', // Replace with the user ID of the person you want to tag
];
const userTags = mentionedUsers.map(userId => `<@${userId}>`).join(' ');
const channelId = message.channel; // Get the channel ID where the message was received
const triggerWord = '@1y'; // The trigger word used to call the bot
const text = message.text.trim().toLowerCase();
if (text.includes(triggerWord)) {
await say({
text: `Hello, ${userTags}`,
channel: channelId,
});
}
});
app.message('@2y', async ({ message, say }) => {
const mentionedUsers = [
message.user, // Mentioning the user who sent the message
'anshul240903', // Replace with the user ID of the person you want to tag
];
const userTags = mentionedUsers.map(userId => `<@${userId}>`).join(' ');
const channelId = message.channel; // Get the channel ID where the message was received
const triggerWord = '@2y'; // The trigger word used to call the bot
const text = message.text.trim().toLowerCase();
if (text.includes(triggerWord)) {
await say({
text: `Hello, ${userTags}`,
channel: channelId,
});
}
});
app.message('@3y', async ({ message, say }) => {
const mentionedUsers = [
message.user, // Mentioning the user who sent the message
'anshul240903', // Replace with the user ID of the person you want to tag
];
const userTags = mentionedUsers.map(userId => `<@${userId}>`).join(' ');
const channelId = message.channel; // Get the channel ID where the message was received
const triggerWord = '@3y'; // The trigger word used to call the bot
const text = message.text.trim().toLowerCase();
if (text.includes(triggerWord)) {
await say({
text: `Hello, ${userTags}`,
channel: channelId,
});
}
});
app.message('@4y', async ({ message, say }) => {
const mentionedUsers = [
message.user, // Mentioning the user who sent the message
'anshul240903', // Replace with the user ID of the person you want to tag
];
const userTags = mentionedUsers.map(userId => `<@${userId}>`).join(' ');
const channelId = message.channel; // Get the channel ID where the message was received
const triggerWord = '@4y'; // The trigger word used to call the bot
const text = message.text.trim().toLowerCase();
if (text.includes(triggerWord)) {
await say({
text: `Hello, ${userTags}`,
channel: channelId,
});
}
});
(async () => {
console.log("Working")
// await app.start(3000)
await app.start(process.env.PORT || 3000);
})();
app.event('app_home_opened',async ({event,say,client}) =>{
try {
/* view.publish is the method that your app uses to push a view to the Home tab */
await client.views.publish({
/* the user that opened your app's app home */
user_id: event.user,
/* the view object that appears in the app home*/
view: {
type: 'home',
callback_id: 'home_view',
/* body of the view */
blocks: [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "*Welcome to your _TikTags's Home_* :tada:"
}
},
{
"type": "divider"
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "This bot tags members of IMG according to their year"
}
},
// {
// "type": "actions",
// "elements": [
// {
// "type": "button",
// "text": {
// "type": "plain_text",
// "text": "Click me!",
// }
// "action_id": "button_click",
// }
// ]
// }
]
}
});
}
catch (error) {
console.error(error);
}
})