1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

hubotで実行したスクリプトの回数をカウントするスクリプト

Last updated at Posted at 2014-10-27

概要

最近社用で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

ソースコード

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?