DEV Community

D
D

Posted on

2 1

オフィス周辺にポケモンが現れたら 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

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

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay