aboutsummaryrefslogtreecommitdiff
path: root/src/server/routes/slack.js
blob: 5dc7047b72b508b9ab0d87daad337909591ee3fd (plain)
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
const express = require('express')
const router = express.Router()

router.all('/', function (req, res, next) {
  if (!/^[0-9]+$/.test(req.body.text)) {
    res.json({
      "response_type": "ephemeral",
      "text": "Only student id's are currently supported, more comming soon!"
    })
    return
  }
  res.json({
    "response_type": "in_channel",
    "text": `Here is the schedule of _${req.body.text}_`,
    "mrkdwn": true,
    "attachments": [
      {
        "fallback": `https://beta.rooster.hetmml.nl/s/${req.body.text}`,
        "image_url": `https://beta.rooster.hetmml.nl/get/s/${req.body.text}.png`
      }
    ]
  })
})

module.exports = router