概要
最近社用でhubotを使って遊んでいるが、ふと自分の作ったスクリプトのうちどれがよく使われるのか気になったので、スクリプトの実行回数をカウントするスクリプトをつくってみた。
機能
- hubotで何かしらのコマンドを実行する度にそれぞれのコマンドの実行回数をカウント
- sc(script count)コマンドによる実行回数の参照、更新
インストール
インストールコマンド
install
$ cd path/to/myhubot #package.jsonがあるディレクトリへ移動
$ npm install hubot-script-counter -save
設定の編集
external_scripts.json
["hubot-script-counter"] #"hubot-script-counter"を配列に追加(既に何か追加されている場合はカンマ区切りで追加)
使い方
scコマンド
Hubot> hubot sc # 各スクリプトの実行回数表示
Hubot> ship : 1
time : 2
ping : 1
sc : 1
Hubot> hubot sc set ship 10 # shipスクリプトの実行回数を10に設定
Hubot> set 10 to script_ship
Hubot> hubot sc
Hubot> time : 2
ping : 1
sc : 3
ship : 10
Hubot> hubot remove time # timeスクリプトの実行回数を削除
Hubot> hubot sc remove time
Hubot> removed script_time
Hubot> hubot sc
Hubot> ping : 1
sc : 5
ship : 10
Hubot> hubot sc reset # 全スクリプトの実行回数を削除
Hubot> sc reset done
Hubot> hubot sc
Hubot> sc : 1
ソースコード