DEV Community

D
D

Posted on

オフィス周辺にポケモンが現れたら Slack チャンネルに通知するようにした

タイトル通りにオフィス周辺(半径変更可)にポケモンが現れたらSlackのチャンネルに通知するようにしてみた。

packge.jsonに pokego-scan 追加

{ "dependencies": { "pokego-scan": "0.1.5" } } 
Enter fullscreen mode Exit fullscreen mode

pokemon-go.coffee 作ってhubotのscriptsに入れる。

 cronJob = require('cron').CronJob pokegoScan = require('pokego-scan') # 自分の環境合わせて設定してください(http://www.latlong.net) coords = { latitude: 35.664134, longitude: 139.713854 }; module.exports = (robot) -> cronjob = new cronJob('*/5 * * * *', () => channel = room: "#pokemon" # 自分の環境に合わせて変更 pokegoScan coords, { distance: 50 }, (err, pokemons) -> if pokemons != undefined message = "" pokemons.forEach (pokemon) -> message += pokemon.name + "\n" message += pokemon.despawns_in_str + "\n" message += pokemon.image + "\n" if message != "" robot.send channel, message ) cronjob.start() 
Enter fullscreen mode Exit fullscreen mode

Screen Shot 2016-07-26 at 6.00.32 PM.png

こんな感じで通知してくれます。
二行目の数字は、ポケモンが消えるまでの時間です。

その後

Screen Shot 2016-07-26 at 6.00.32 PM.png

追記(2016-07-27)

https://github.com/dgoguerra/pokego-scan
https://www.npmjs.com/package/pokego-scan

パッケージと開発がクローズされたみたいです、、、

Top comments (0)