forked from claudeisakeeb/ctc-slackbot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
59 lines (49 loc) · 1.55 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
const schedule = require("node-schedule");
const mongoose = require("mongoose");
const Bot = require("./utils/bot");
const {
openCreatePRModal,
handleCreatePRSubmitted,
updateIssueOptions,
} = require("./utils/pr");
const {
openUpdateProfileModal,
handleUpdateProfileSubmitted,
} = require("./utils/profile");
const { generateMatchyMeetups, clearMatchy } = require("./utils/matchy");
const {
openCreateIssueModal,
handleCreateIssueSubmitted,
} = require("./utils/issue");
// Mongoose for connecting to MongoDB
mongoose.connect(process.env.MONGO_URI, {
useNewUrlParser: true,
useUnifiedTopology: true,
});
const mongoConnection = mongoose.connection;
mongoConnection.once("open", () => {
console.log("MongoDB database connection established successfully");
});
Bot.command("/pr", openCreatePRModal);
Bot.command("/profile", openUpdateProfileModal);
Bot.command("/issue", openCreateIssueModal);
// Bot.command("/matchy", generateMatchyMeetups);
Bot.command("/clear", clearMatchy);
Bot.action("repository", updateIssueOptions);
Bot.view("create-pr", handleCreatePRSubmitted);
Bot.view("create-issue", handleCreateIssueSubmitted);
Bot.view("update-profile", handleUpdateProfileSubmitted);
(async () => {
const port = 5000;
// Start your app
await Bot.start();
console.log(`⚡️ Slack Bolt app is running on port ${port}!`);
const rule = new schedule.RecurrenceRule();
rule.tz = 'America/Los_Angeles';
rule.dayOfWeek = 4;
rule.hour = 17;
rule.minute = 0;
schedule.scheduleJob(rule, async () => {
await generateMatchyMeetups();
});
})();