Skip to content

Instantly share code, notes, and snippets.

@blue1st
Last active August 29, 2015 14:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save blue1st/d590d69cd230f9765337 to your computer and use it in GitHub Desktop.
Save blue1st/d590d69cd230f9765337 to your computer and use it in GitHub Desktop.
はてなブックマークのITカテゴリのホットエントリを定期的につぶやくHubotスクリプト。package.jsonにcron・xmljson・requestを追記し、scriptディレクトリ以下に収めて使う。
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