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') {
|
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
|
articleTable = (articles
|
||||||
.reverse()
|
.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"))
|
.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({
|
res.send({
|
||||||
response_type: "in_channel",
|
response_type: "in_channel",
|
||||||
text: `
|
text: `
|
||||||
|
@ -86,6 +102,7 @@ app.post("/edcal", (req, res) => {
|
||||||
|:roundpup: Title|PP|Due Date|Publish Date|Status|
|
|:roundpup: Title|PP|Due Date|Publish Date|Status|
|
||||||
|:---------------|:-|:-------|:-----------|:-----|
|
|:---------------|:-|:-------|:-----------|:-----|
|
||||||
${articleTable}
|
${articleTable}
|
||||||
|
${emojiKey}
|
||||||
`,
|
`,
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue