Last active
August 29, 2015 14:19
-
-
Save blue1st/d590d69cd230f9765337 to your computer and use it in GitHub Desktop.
はてなブックマークのITカテゴリのホットエントリを定期的につぶやくHubotスクリプト。package.jsonにcron・xmljson・requestを追記し、scriptディレクトリ以下に収めて使う。
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
cronJob = require('cron').CronJob | |
to_json = require('xmljson').to_json | |
request = require 'request' | |
module.exports = (robot) -> | |
new cronJob '00 30 09,12,15,18 * * 1-5', () => | |
url = "http://b.hatena.ne.jp/hotentry/it.rss" | |
options = | |
url: url | |
timeout: 2000 | |
headers: {'user-agent': 'node title fetcher'} | |
request options, (error, response, body) -> | |
to_json body, (err, data) => | |
article = "はてブITカテゴリ ホットエントリ¥n" | |
for id, item of data["rdf:RDF"].item | |
title = item.title | |
link = item.link | |
article += "#{title} #{link}¥n" | |
robot.send {room:"ROOM_ID"}, article | |
, null, true, "Asia/Tokyo" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment