-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
67 lines (56 loc) · 2.01 KB
/
Copy pathapp.js
File metadata and controls
67 lines (56 loc) · 2.01 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
const { App } = require("@slack/bolt")
const { WebClient } = require('@slack/web-api')
const cron = require('node-cron')
const CagnotteManager = require('./cagnotte')
const AperallManager = require('./aperall')
const BirthdayManager = require('./birthday')
require("dotenv").config()
const app = new App({
token: process.env.SLACK_BOT_TOKEN,
signingSecret: process.env.SLACK_SIGNING_SECRET
})
const client = new WebClient(process.env.SLACK_BOT_TOKEN)
const cagnotteManager = new CagnotteManager(client)
const aperallManager = new AperallManager(client)
const birthdayManager = new BirthdayManager(client)
app.command("/cagnotte", async({ command, ack, respond }) => {
await ack()
try {
await cagnotteManager.createCagnotte(command)
} catch (e) {
await respond({ text: `❌ Erreur : ${e.message}`, response_type: 'ephemeral' })
}
});
app.action('exclude_user', async({ action, ack, say }) => {
await ack()
await cagnotteManager.handleExcludeUser(action)
});
app.action('validate', async({ action, ack, say }) => {
await ack()
await cagnotteManager.handleValidate(action)
});
app.action('invite', async({ action, ack, say }) => {
await ack()
await cagnotteManager.handleInvite(action)
});
app.command("/aperall", async({ command, ack, respond }) => {
await ack()
try {
const response = await aperallManager.handleAperallCommand(command)
await respond({ text: response, response_type: 'in_channel' })
} catch (e) {
await respond({ text: `❌ Erreur : ${e.message}`, response_type: 'ephemeral' })
}
});
(async() => {
const port = process.env.PORT || 3000
await app.start(port)
console.log(`⚡️ Slack Bolt app is running on port ${port}!`)
cron.schedule('0 10 * * *', async () => {
console.log('Vérification des anniversaires...')
await birthdayManager.checkAndSendBirthdays()
}, {
timezone: "Europe/Paris"
})
console.log('📅 Cron job d\'anniversaires configuré pour 10h (Europe/Paris)')
})();