Assign emoji for different /edcal article statuses
Thanks to Nia for deciding the emoji!
This commit is contained in:
parent
1b9d542b88
commit
4b0cde33e6
1 changed files with 18 additions and 1 deletions
19
index.js
19
index.js
|
@ -74,10 +74,26 @@ app.post("/edcal", (req, res) => {
|
|||
}
|
||||
|
||||
if (req.body.command != 'edcal') {
|
||||
let statusToEmoji = new Map([
|
||||
['Published', ':grin:'],
|
||||
['Scheduled', ':alarm_clock:'],
|
||||
['WIP', ':roundpup:'],
|
||||
['Waiting for response', ':zzz:'],
|
||||
['Stalled', ':clown_face:'],
|
||||
])
|
||||
|
||||
// format the articles into a table
|
||||
articleTable = (articles
|
||||
.reverse()
|
||||
.map(a => `|${a.title}|${a.in_charge.map(u=>u.name[0]).join(',')}|${a.due_date}|${a.publish_date}|${a.status}|`)
|
||||
.map(a => `|${a.title}|${a.in_charge.map(u=>u.name[0]).join(',')}|${a.due_date}|${a.publish_date}|${statusToEmoji.get(a.status) || a.status}|`)
|
||||
.join("\n"))
|
||||
|
||||
// an emoji -> status message legend to display at the end
|
||||
emojiKey = ([...statusToEmoji.entries()]
|
||||
.map((x) => `${x[1]} ${x[0]}`)
|
||||
.join(' '))
|
||||
|
||||
// ...and we're out!
|
||||
res.send({
|
||||
response_type: "in_channel",
|
||||
text: `
|
||||
|
@ -86,6 +102,7 @@ app.post("/edcal", (req, res) => {
|
|||
|:roundpup: Title|PP|Due Date|Publish Date|Status|
|
||||
|:---------------|:-|:-------|:-----------|:-----|
|
||||
${articleTable}
|
||||
${emojiKey}
|
||||
`,
|
||||
})
|
||||
} else {
|
||||
|
|
Loading…
Reference in a new issue