LoginSignup
6
6

More than 5 years have passed since last update.

Litaで突然の死

Posted at

Lita

Lita

最近仕事でもプライベートでも、jimmycuadra/litaをhipchat上に常駐させています。

基本的にはgithub/hubotと同じようなchat bot frameworkなのですが、
hubotがjavascript/coffeescriptでbotの挙動を実装するのに対して、
litaはrubyで記述できる(使い慣れたgemを使用できる)ところが気に入っています。

突然の死

例えば、litaが常駐しているroomでsuddenly 突然の死という発言を拾って例のあれを表示するためのhandlerはこんな感じに書きます。

# http://rubygems.org/gems/pebbles-suddenly_death_string
require 'pebbles/suddenly_death_string'

module Lita
  module Handlers
    class Suddenly < Handler
      route /^suddenly\s+(\S.*)+/, :suddenly_death

      def suddenly_death(response)
        word = response.matches[0][0]
        response.reply word.to_suddenly_death
      end
    end
    Lita.register_handler(Suddenly)
  end
end

Screen Shot 2013-09-30 at 15.07.45.png

6
6
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
6
6