hubot-twitter-userstreamããªãªã¼ã¹ãã¾ãã
å æã®è©±ã«ãªãã¾ãããHubotããTwitterã¸æ稿ããããã®Adapter hubot-twitter-userstreamãnpmã§å ¬éãã¾ããã
Hubotã¨ã¯
Github社ãä½æãããã£ãããããã§ããCoffeeScriptã§æ¸ããã¦ãããNode.jsä¸ã§åä½ãã¾ãã Hubotã¯ãã£ããã«æ¥ç¶ãæ稿ããããã®Adapter, ã¡ãã»ã¼ã¸ãã¤ãã³ãã«ã¬ã¹ãã³ã¹ãè¿ãScriptãªã©ããæ§æããã¦ããã ãããã®ã¢ã¸ã¥ã¼ã«ãå°å ¥ãããã¨ã§ç°¡åã«æ§ã ãªãã£ãããµã¼ãã¹ã§åä½ããBOTãä½ããã¨ãã§ãã¾ãã
hubot-twitter-userstream ã§ä½ãã§ããã®ã
ããããHubotã®Twitterç¨ã®Adapter(MathildeLemee/hubot-twitter · GitHub)ã¯ãã§ã«åå¨ãã¦ããã®ã§ãããå®éBOTãä½ãã«ããã£ã¦ããã¤ã é£ç¹ããã
ã¿ã¤ã ã©ã¤ã³ãããã¤ã¼ããåå¾ã§ããªã
Twitterä¸ã§åãBOTã¯æ®éã¿ã¤ã ã©ã¤ã³ã®ãã¤ã¼ããåå¾ãã¦ããã¤ã¼ãã«ãã£ã¦ã¯åå¿ãã¦ãªããè¿ãã¨ããæåãæå¾ ããã¨æãã®ã§ããã hubot-twirrerã§ã¯statuses/filterãç¨ãã¦ãèªåã®ååãæ¤ç´¢ãã¦ããããããã¤ã¼ããåä¿¡ããã¨ãã ã¡ãã£ã¨ããããããªãæåã«ãªã£ã¦ãã¾ããããã ãã§ããªãã©ã¤ãéã£ããããBOTãä½ãã«ã¯è´å½çã§ãã
ãã©ãã¼ã»ãªã ã¼ããã§ããªã
- ãã¤ã¬ã¯ãã¡ãã»ã¼ã¸ãéããªã
çã è´å½çãªå¼±ç¹ããããBOTãä½ãåã«ãAdapterãèªåã§ä½ã£ã¦ãããã¨æãè³ã£ã次第ã§ãã
hubot-twitter-userstreamã§ã§ãããã¨
- ãã¤ã¼ãã®æ稿ãè¿ä¿¡ãã§ãã
- UserStreamã使ã£ã¦ã¿ã¤ã ã©ã¤ã³ãããã¤ã¼ããåå¾ã§ãã
- ãã©ãã¼ã»ãªã ã¼ããã§ãã
- ãã¤ã¬ã¯ãã¡ãã»ã¼ã¸ã®éåä¿¡ãã§ãã
- ãã©ãã¼ãããããµãã¼ãããçã®ã¤ãã³ããåä¿¡ã§ãã
ã§ããªããã¨
- RT
- ç»åã®ã¢ãããã¼ã
- ãã©ãã¼ã»ãã©ãã¯ã¼ä¸è¦§ã®åå¾(ä¾ãã°BOTãèµ·åãã¦ããªãæã«ãã©ãã¼ããã¦ã¼ã¶ã¼ããªãã©ãã¼ã§ããªã)
å°å ¥æ¹æ³
Hubotèªä½ã®å°å ¥æ¹æ³ã¯ hubot/docs at master · github/hubot · GitHub ã はじめてのHubot - Qiita ãåç §ãã¦ãã ããã
èªåã®BOTããããã£ã¬ã¯ããªmyhubotã¯ç¨æåºæ¥ã¾ãããï¼åºæ¥ã¾ãããï¼
å°å ¥ã¯myhubot/package.jsonãç·¨éãã¦"dependencies"ã«ã"hubot-twitter-userstream": ""ãããããªæãã§è¿½å ãã¦
... "dependencies": { "hubot": ">= 2.6.0 < 3.0.0", "hubot-scripts": ">= 2.5.0 < 3.0.0", "hubot-twitter-userstream": "" }, ...
myhubotãã£ã¬ã¯ããªä¸ã§ npm install ãå®è¡ããã° myhubot/node_modules ãã£ã¬ã¯ããªä¸ã«ã¤ã³ã¹ãã¼ã«ãè¡ããã¾ãã
次ã«ç°å¢å¤æ°ã«Twitterã®API keyãããã¤ãè¨å®ããå¿ è¦ãããã¾ãã
$ export HUBOT_TWITTER_KEY="key" $ export HUBOT_TWITTER_SECRET="secret" $ export HUBOT_TWITTER_TOKEN="token" $ export HUBOT_TWITTER_TOKEN_SECRET="secret"
ãããããèªåã®ã¹ã¯ãªã¼ã³ãã¼ã (ããã§ã¯@hubottestã¨ãã¾ã)ãBOTã®ååã«è¨å®ãã¾ãã
$ export HUBOT_NAME="hubottest"
ããã§æºåã¯å®äºã§ãã
使ãæ¹
pingãè¿ã
myhubotãã£ã¬ã¯ããªä¸ã§ ./bin/hubot -a twitter-userstream ã¨å®è¡ãããã¨ã§BOTãèµ·åãã¾ãã BOTã«ã¯åæç¶æ ã§ããã¤ãScriptãçµã¿è¾¼ã¾ãã¦ããã®ã§ãã¹ããã¦ã¿ã¾ãããã
ã¾ãBOTã®ã¢ã«ã¦ã³ãã§èªåã®ã¢ã«ã¦ã³ãããã©ãã¼ããã¦ããã@hubottest pingãã¨ããããã«ãªãã©ã¤ãé£ã°ãã¦ã¿ã¾ãããã æåããã°ãBOTããPONGãã¨ã¤ã¶ããã¾ãã
ãªãã©ãã¼ãã
BOTããã©ãã¼ããã¦ã¼ã¶ã¼ããã©ãã¼ããã«ã¯ã 以ä¸ã®ãããªã¹ã¯ãªãããç¨æãã¦scriptsãã£ã¬ã¯ããªã«å ¥ãã¦ãBOTãåèµ·åãã¾ãã
# myrules.coffee module.exports = (robot) -> robot.on 'followed', (event) -> robot.logger.info "followed #{event.user.name}!" robot.adapter.join event.user