RubotyãHerokuã«ãããã¤ãã¦Slackã§ä½¿ã
人æ°ã®ãã£ããã¢ããªã§ããSlack㨠id:r7kamura ãããä½ã£ãRuby製Hubotã¯ãã¼ã³ã§ãã Ruboty ã試ãã¦ã¿ããã£ãã®ã§ãæå¿é²ã
æè¿ãã¼ã ã¡ã³ãã¼ã«ç·¨æããã£ã¦ããã¾ãããã¨ããããã¯ãã¼ã ã®ä»²éãå°ãã®éãæ ã«åºããã¨ã«ãªããã¨ã£ã¦ãå¯ããã®ã§å¯ãããç´ãããããã«ãã¾ããbotããä½ã£ã¦ã¿ããã¨ã«ãã¾ãã
åæ
Rubotyã¯Herokuã«ãããã¤ãã¾ãã®ã§ãHerokuã¢ã«ã¦ã³ãã®ä½æãHeroku Toolbeltã®ã¤ã³ã¹ãã¼ã«ã¯æ¸ã¾ãã¦ãããã¨ãåæã¨ãã¾ãã
Slackå´ã®è¨å®
Gatewayã®è¨å®
Botã¢ã«ã¦ã³ããä½ã
- Administrationã®Manage Your TeamãéããInvite New Membersããé©å½ãªã¡ã¼ã«ã¢ãã¬ã¹ãå ¥åãã¦Invitationã¡ã¼ã«ãéä¿¡ãã¾ã
- Invationã¡ã¼ã«ãå±ããããActivationãã¦é©å½ã«ç»åãè¨å®ãã¦ããã¾ã
Ruboty
ruboty-templateãForkãã
Rubotyãã«ã¹ã¿ãã¤ãºãã¾ãã®ã§ãr7kamuraããã® ruboty-templateãForkãã¾ãã
ForkããRubotyãHerokuä¸ã«ãããã¤ãã
Forkãããªãã¸ããªã®READMEã«ããHerokuãã¿ã³ãæ¼ãã¦ãRubotyãHerokuã«ãããã¤ãã¾ãã
ãããã¤ç»é¢ã§ä»¥ä¸ã®å 容ãå ¥åãã¦Deploy for Freeãã¯ãªãã¯ãã¾ã
- SLACK_PASSWORD
- SLACK_ROOM
- botã常é§ããããRoom Nameãå ¥å
- SLACK_TEAM
- Team Nameï¼xxx.slack.com ã®xxxé¨åï¼
- SLACK_USERNAME
- botã¢ã«ã¦ã³ãã®ååï¼ãã¾ã¯mayubotï¼
ããã§ãHerokuã«Rubotyããããã¤ããã¾ãã
åä½ç¢ºèª
Rubotyããããã¤ã§ããããSlackä¸ã§è©±ãããã¦ã¿ã¾ãã
ãããããããããï¼ï¼ ããã¾ã§ãã³ã¼ãã¯1è¡ãæ¸ãã¦ã¾ããããªãããã
Rubotyã¯Hubotã¨ã¯ç°ãªããRubyã§åä½ãã¦ããããã®æåã¯ãã¹ã¦Gemfileã«ãã£ã¦Gemãã©ã°ã¤ã³ã¨ãã¦ç®¡çããã¦ãã¾ãããã®ãããBotã«æ°ããå½¹å²ãä»»ãããã»æåãå¢ããããå ´åã«ã¯æ°ããGemãä½ã£ã¦å ¬éããå¿ è¦ãããã¾ãã
Hubotã®å ´å㯠script
ãã£ã¬ã¯ããªå
ã« .coffee ãã¡ã¤ã«ãç½®ãã¦Botãåèµ·åããã°æåã追å ã§ããã®ã§ãæ軽ãã¨ããæå³ã§ã¯Hubotã®æ¹ãè¯ãããããã¾ããã
- Rubyã§æåãæ¸ãã
- Gemã§ç®¡çã§ããï¼é å¸ã®ã©ã¯ãï¼
ã¨ãã£ãç¹ã§ã¯Rubotyã«ãè¯ãç¹ã¯ããã¾ããã
ãã©ã°ã¤ã³ã追å ãã
GemãGistã§ä½æãã
ãã¦ãç¡äºSlackã¨Rubotyãé£æºã§ããã®ã§ãèªä½ã®ãã©ã°ã¤ã³ãä½ã£ã¦æ°ããæåã追å ãã¦ã¿ã¾ãããã¾ãããã¯ããããæ¢åµå°æ²¢éå¥ã®ãªããã大好ãã ã£ãã®ã§ãã@mayubot ãªãããã¨å±ããã¨ããããµããµãã¨è¿ããã©ã°ã¤ã³ãä½ã£ã¦ã¿ã¾ããGemã§å ¬éããå¿ è¦ãããã®ã§ãGistã§Gemãå ¬éãããã¨æãã¾ãã
ãã®2ã¤ãGistã§ä½æãã¾ãããããªæãã§ãã
Gemfileã«è¿½å
ç¶ãã¦ããã¼ã«ã«ã«Cloneãããªãã¸ããªã®Gemfileã«ä»¥ä¸ã追è¨ãã¦ã bundle install
ãã¾ãã
source "https://rubygems.org" gem "rake" gem "ruboty-alias" gem "ruboty-cron" gem "ruboty-google_image" gem "ruboty-redis" gem "ruboty-slack" gem "nfu", :git => "https://gist.github.com/e0f5147312c921ba6ee0.gitâ # ããã追è¨
Gemãã¤ã³ã¹ãã¼ã«ã§ããããherokuã¸pushãã¦ãããã¤ãã¾ãã
$ git add .
$ git commit -m âadd nfu gemâ
$ git push heroku master
ãªãããå±ãã¦ã¿ã
ãããã¤ãå®äºããããããããSlackä¸ã§ @mayubot ã¸åãã¦åªæãçºåã
åãããï¼ï¼ï¼ï¼ï¼ã«ã³ã¿ã³ã«ãã©ã°ã¤ã³ã追å ã§ãã¾ããã
ææ
- Rubyã§ãã©ã°ã¤ã³ãä½ããã®ãGood
- Hubotã¯Node.jsã§CoffeeScriptã§ãã©ã°ã¤ã³ãæ¸ãã®ã§ãããRubyã§æ¸ããã®ã¯ããããã§ãã
- Gemã§ç®¡çã§ããã®ãè¯ã
- ãã©ã°ã¤ã³ãGemã§ç®¡çããã®ã¯ã¨ã¬ã¬ã³ãã¨ããããã¹ãã¼ããªã®ã§è³å¦ããã¨æããã©å人çã«ã¯å¥½ã
- Gistã§Gemãå
¬éããã®ã¯ãã°ãã
- ãããr7kamuraããã®ã¨ã³ããªãåèã«ãã¾ããããã°ãããæ®éGemãå
¬éãããªãã
bundle gem
ãã¦ãgem build
ãã¦gem push
ããã¿ãããªãã¨ãå¿ è¦ãªãã§ãããçç¥ã§ãã¾ãã
- ãããr7kamuraããã®ã¨ã³ããªãåèã«ãã¾ããããã°ãããæ®éGemãå
¬éãããªãã
- Herokuãã¿ã³ããã
- Herokuãã¿ã³ããããã§ããè¶ ã«ã³ã¿ã³ã«ã¢ããªãHerokuä¸ã«ãããã¤ã§ãã¾ãã
- Ruboty-Template
- ããã¤ãForkããã°èªåã好ãã«ããããã®ã§TravisCIãçµã¿åãããã°master mergeãå¥æ©ã«ãããã¤ãèµ°ãããã¿ãããªãã¨ãã§ãã¦Goodã§ã
- Botãæ¬äººåããã®ããªã¢ãã¤
- ä»ç¤¾ã§è¦ã¦ã¦è¯ãã¨æã£ã¦ãã£ã¦ã¿ãã®ã§ãããå®éè¯ãã£ãã§ãããªã¢ãã¤ã§ãããªã¢ãã¤ã ããããªãã¦ããã®äººã®ã¢ã¤ãã³ãã£ãã£ã¨ããããä¾ãã°ãã¾ãããã®å ´åã ã¨ããã¹ããå ±æã好ããªã¨ã³ã¸ãã¢ã ã£ãã®ã§ãã @mayubot ãã¹ããããããSTãããã¨ããé¡ããããã¨ã§ãE2Eã®ãã¹ããSTç°å¢ã§å®è¡ãããã¨ãããããã¤ããã¨ãã«ããããã¤ããã ãã¾ãããã¨ãã§ãããæ´ã«ãªã¢ããã¦ä¾¿å©ã«ãªããªãã¨æãã¾ãããåè«æãã§ãåæ¥ããã¡ã³ãã¼ããããBotã«ããã¨ãã¯é¢ç½ãããã¨èãã¦ããããã¾ãã
ãã¾ãï¼Herokuã®è¨å®ï¼
Herokuã¢ããªããã¼ã«ã«ã«Cloneãã¦ããããã¤ãã
SSHå ¬ééµã®ç»é²
$ heroku keys:add
ã§å
¬ééµãç»é²ãã¾ããéµããªããã° ssh-keygen
ã³ãã³ãã使ã£ã¦éµãã¢ãä½æãã¦å度ä¸è¨ã³ãã³ããå®è¡ãã¾ãã
Herokuã¢ããªãCloneãã
$ heroku git:clone -a $heroku_project_name
ã§Herokuã¢ããªãCloneã§ãã¾ãã
Herokuã¢ããªããããã¤ãã
$ git push heroku master
ã§Herokuã¸ãã¼ã«ã«ã®ãªãã¸ããªãpushãã¦ãããã¤ã§ãã¾ãã
次åã¯ãRubotyãµã¼ãã¨GitHubãé£æºãã¦èªåãããã¤ãããããéããã¾ãï¼ä»®ï¼ã