# Description: # Hubot interface for timezone.io # # Configuration: # HUBOT_TIMEZONEIO_URL - full team url eg: https://timezone.io/team/buffer # # Commands: # hubot tz - Show team's local time across time zones via timezone.io # # Dependencies: # moment-timezone # # Author: # @benwtr # moment = require 'moment-timezone' timezoneio_url = process.env.HUBOT_TIMEZONEIO_URL || 'https://timezone.io/team/buffer' data_regex = /appData = (.*);/g module.exports = (robot) -> robot.respond /tz/i, (res) -> robot.http(timezoneio_url) .get() (err, result, body) -> if m = data_regex.exec body d = m[1] d = JSON.parse d reply = '' cur_time = new Date().getTime() for z in d.timezones tz = z.tz time = moment(cur_time).tz(tz).format("ddd h:mmA|zZZ") names = for person in z.people person.name names = names.join(', ') reply += "#{tz}|#{time} - #{names}\n" res.reply reply