-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
50 lines (43 loc) · 1.35 KB
/
app.js
File metadata and controls
50 lines (43 loc) · 1.35 KB
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
/*
---general list of things we need to do-----
1. Make this scaleable to strings of messages, use NLP, etc
a. TRY NOT TO RELY ON EVENT LISTENERS
---list of items we need to code ----
-----core----
1. app.message needs to listen to everything <--- make it scalable as well
2. how do we detect spam?
a. machine learning and neural networks <-- overkill imo
b. natural langauge processing
c. other scalable algorithm
3. Warning message as a courtesy - highly recommended.
4. Alert admins. That way they can audit the whole process and stuff.
---extensions and other fun things we can do
*/
//objects and instantiating
var spam_handle = require("./spam_handle.js");
var object = new spam_handle("hi");
//assinging slack signing secret and bot token
const { App } = require("@slack/bolt");
const app = new App({
token: process.env.SLACK_BOT_TOKEN,
signingSecret: process.env.SLACK_SIGNING_SECRET
});
//message event
app.message("hi", async ({ payload, context }) => {
try {
const result = await app.client.chat.postMessage({
token: context.botToken,
channel: payload.channel,
text: object.response
});
console.log(result);
} catch (error) {
console.error(error);
}
});
//async function
(async () => {
// starts the app
await app.start(process.env.PORT || 3000);
console.log("⚡️ Bolt app is running!");
})();