UNPKG

hubot-slack-reading-list

Version:

Build a reading list from emojied reactions on Slack

34 lines (27 loc) 751 B
'use strict'; const brain = require('../brain'); function isFriday(dayOfWeek) { return (dayOfWeek === 5); } module.exports = function(robot) { const postReadingList = list => { const md = list.markdown.join('\n-----\n'); robot.adapter.client.web.files.upload(`${list.name}.md`, { title: list.name, filetype: 'post', content: md, channels: list.channels[0] }); }; return dayOfWeek => { let readingLists = brain.getReadingLists(); if (!isFriday(dayOfWeek)) { // If it's not Friday, only post the daily // reading lists. readingLists = readingLists.filter(list => list.frequency === 'daily'); } for(let list of readingLists) { postReadingList(list); } }; };