LoginSignup
7

More than 5 years have passed since last update.

部分的なチャット履歴を記録する hubot-rec の使い方

Last updated at Posted at 2015-03-18

概要

チャット、手軽でいいけどフロー情報なのでどんどんログが流れていく。
特に大事な部分だけ抜粋してストック情報として残しておきたい場面もあると思う。
たとえば、

  • イベントがあった特定の 1 日の twitter タイムラインを保存しておきたい
  • IRC で特定の期間だけのログを保存しておきたい
  • 重要なメンテナンスのはじまりから終わりまでのログを保存してチケットに添付しておきたい

みたいな感じ (個人的には一番最後)。
探してみたけど、ありそうでなかったので tily/hubot-rec という hubot スクリプトを作ってみた。
adragomir/hubot-logger というのが似ているけど、これは IRC の全ログを収集して保存するもののようなので少し用途が違うように思う。

コマンド一覧

hubot rec start <title> - 記録スタート、タイトルの指定も可能
hubot rec cancel - スタートした記録のキャンセル
hubot rec stop - 記録ストップ
hubot rec title <title> - 今記録しているレコーディングのタイトルを変更
hubot rec status - 記録しているかどうかを表示
hubot rec list - 記録の一覧を表示
hubot rec delete <number> - 記録を消す

使い方の例

## 記録スタート
Hubot> Hubot rec start Some Chat History
Shell: started recording: Some Chat History at 2015/03/18 09:13:56 (room=Shell, duration=00:00:00, messages=0)

## 記録してるかどうか確認
Hubot> Hubot rec status
Shell: now recording: Some Chat History at 2015/03/18 09:13:56 (room=Shell, duration=00:00:04, messages=1)

## 記録キャンセル
Hubot> Hubot rec cancel
Shell: cancelled recording: Some Chat History at 2015/03/18 09:13:56 (room=Shell, duration=00:00:09, messages=2)

## また記録スタート
Hubot> Hubot rec start Other Chat History
Shell: started recording: Other Chat History at 2015/03/18 09:14:13 (room=Shell, duration=00:00:00, messages=0)

## 記録のタイトルを変更
Hubot> Hubot rec title Other Chat History for README
Shell: renamed Other Chat History to Other Chat History for README

## しばしご歓談
Hubot> this is message

Hubot> this is message again

Hubot> this is another one

## 記録ストップ
Hubot> Hubot rec stop
Shell: stopped recording: Other Chat History for README at 2015/03/18 09:14:13 (room=Shell, duration=00:01:09, messages=5)

## 記録したものの一覧
Hubot> Hubot rec list
Shell: [0] Other Chat History for README at 2015/03/18 09:14:13 (room=Shell, duration=00:01:09, messages=5)

## 記録したものを消す
Hubot> Hubot rec delete 0

## 一覧してみると空になっている
Hubot> Hubot rec list
Shell: (no recordings)

イベント

rec stop で記録を停止したときに recStopped というイベントが発生するので、これを捕捉してメールを送るとか redmine のチケットにチャットログを添付するとかなんでもできるはず。

recStopped - {rec: <rec>, msg: <msg>}

イベント発生時には rec というプロパティで今録音したレコーディングに関する情報が取得できる。rec の中身はこんな感じ。

{
  room: <room>,
  title: <title>,
  startedAt: <timestamp>,
  stoppedAt: <timestamp>,
  messages: <list of msgs>
}

ウェブ画面

ウェブ画面から記録されたチャットの履歴を確認できます (v0.0.3 から)。

/rec
/rec/:id

その他

あまりテストしていない、かつアダプターもそれほど試していないので、環境によってはうまく動かないことがあるかもしれません。

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
7