-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
67 lines (62 loc) · 2.02 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
require('dotenv').config();
const { App } = require('@slack/bolt');
// #emoji-watch
const NOTIFY_CHANNEL = "C1VMYMPN2";
const app = new App({
socketMode: true,
token: process.env.SLACK_BOT_TOKEN,
signingSecret: process.env.SLACK_SIGNING_SECRET,
appToken: process.env.SLACK_APP_TOKEN,
});
app.view("modal-id", async ({ ack, view, logger }) => {
logger.info(`Submitted data: ${view.state.values}`);
await ack();
});
app.event("emoji_changed", async ({ event, client, logger }) => {
try {
var type = event.subtype;
if (type === "add") {
var name = event.name;
var value = event.value;
if (!value.includes("alias")) {
const result = await client.chat.postMessage({
channel: NOTIFY_CHANNEL,
blocks: [
{
type: "section",
text: {
type: "mrkdwn",
text: ":raising_hand: Added::" + name + ": (" + name + ")"
},
accessory: {
type: "image",
image_url: value,
alt_text: name
}
}
]
});
}
else{
const result = await client.chat.postMessage({
channel: NOTIFY_CHANNEL,
text: ":raising_hand: Alias Added::" + name + ": (" + name + ")"
});
}
}
else if (type === "remove") {
var name = event.names;
const result = await client.chat.postMessage({
channel: NOTIFY_CHANNEL,
text: ":wave: Removed: " + name
});
}
}
catch (error) {
logger.error(error);
}
});
(async () => {
await app.start();
console.log('⚡️ Bolt app is running!');
})();