Giter Club home page Giter Club logo

voicewarp-automation's Introduction

voicewarp-automation

Deploy

NTT 東日本のひかり電話のボイスワープの転送先設定の切り替え作業を自動化します。 また、パスワードの有効期限が切れた際は自動的に新しいパスワードを生成して設定、通知します。

必要なもの

Heroku で動作させることを前提としており、Heroku へデプロイした後に Heroku Add-ons の Temporise Scheduler でスケジュールを設定し、転送先設定を切り替えることで動作します。

基本設定

以下の config vars が必要です:

  • PHONE_NO - ログインに使う電話番号
  • PASSWORD - ログインに使う現在のパスワード

スケジュール設定

Temporise Scheduler の Recurring event で以下を登録することで、切り替えが実行されます。

  • URL: https://<HOST>/switch/<LIST_NO>
  • HTTP Method: GET

例えば、リスト番号 3 に切り替える URL は https://<HOST>/switch/3 になります。

Slash Command

Slack の Slash Command で操作することが可能です。 設定すると、 /<設定したコマンド> <LIST_NO> (例: /voicewarp 3) のような形式で利用できます。

  • URL: https://<HOST>/slack/slash
  • Method: POST

なお、Slash Command は 3 秒以内に最初の応答を返す必要があるため、Heroku の Free Dyno でスリープしているとタイムアウトしてしまいます。 利用には外形監視などで常に起こしておくか、Hobby Dyno 等のスリープしない Dyno を選ぶ必要があります。

なお、Slash Command 作成時に発行するトークンを SLACK_SLASH_TOKEN config vars に設定すると、そのトークン以外からの呼び出しをブロックすることができます。 セキュリティのため設定をお勧めします。

Heroku のパスワード更新

Heroku の Config Vars のパスワードも Slash Command で変更することが可能です。 なお、安全のため REST API では提供していません。

設定には予め以下を実施する必要があります:

  • Heroku CLI でトークンを生成
  • PLATFORM_TOKEN Config Vars に設定
  • Dyno Metadata の有効化

コマンド操作は以下の通りです:

$ heroku authorizations:create -d "voicewarp"
$ heroku config:set --app <APP_NAME> PLATFORM_TOKEN=<TOKEN>
$ heroku labs:enable runtime-dyno-metadata -a <APP_NAME>

これで、 /<設定したコマンド> heroku PASSWORD=<PASSWORD> (例: /voicewarp heroku PASSWORD=foo) という Slash Command で新しいパスワードを Config Var に設定できるようになります。

開発

ローカルで実行するには、はじめに Node.js を用意した上で以下のコマンドを実行します:

npm i

次に、電話番号とパスワードを伝えるために以下のような .env ファイルを作ります:

PHONE_NO=xxxxxxxxxx
PASSWORD=xxxxxxxxxx

サーバープログラムを起動するには、以下のコマンドを実行します:

npm run dev

サーバーは localhost:3000 で起動します。 ブラウザや curl 等を用いて利用してください。

ライセンス

ISC

作者

mikan

voicewarp-automation's People

Contributors

mikan avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Forkers

1484

voicewarp-automation's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.