Created
February 20, 2015 07:50
-
-
Save spoike/0b83a325010e7c0cc8da to your computer and use it in GitHub Desktop.
Script for celebrating the Swedish past time of "Fika"
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Description: | |
# Hubot delivers a fika related pic | |
# | |
# Dependencies: | |
# cron | |
# google-images | |
# | |
# Configuration: | |
# None | |
# | |
# Commands: | |
# hubot fika me - Display a fika related picture | |
# | |
# Author: | |
# spoike | |
client = require 'google-images' | |
cronjob = require("cron").CronJob | |
TIME = "00 20 14 * * 1-5" | |
ROOM = "general" | |
fika = ['fikabröd', 'fika bulle', 'apfelstrudel', 'tårta', 'kaffe med påtår'] | |
random = (items) -> | |
items[ Math.floor(Math.random() * items.length) ] | |
module.exports = (robot) -> | |
getRandomFika = (cb) -> | |
client.search random(fika), (err, images) -> | |
cb random images | |
getRandomFikaMessage = (cb) -> | |
getRandomFika (image) -> | |
cb image.url | |
robot.respond /fika( me)?/i, (msg) -> | |
getRandomFikaMessage (fikaMessage) -> | |
msg.reply ":coffee: #{fikaMessage}" | |
dailyUpdate = () -> | |
getRandomFikaMessage (fikaMessage) -> | |
robot.messageRoom ROOM, ":coffee: *FIKA!* #{fikaMessage}" | |
remind = new cronjob TIME, | |
dailyUpdate | |
null | |
true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment