Sha256: 72114443bca553da60ae412a194aa0ca57b7bd118781d55e046af0fd100776ad

Contents?: true

Size: 745 Bytes

Versions: 1

Compression:

Stored size: 745 Bytes

Contents

module Lita
  module Adapters
    class Campfire < Adapter
      class Callback

        MESSAGE_TYPES = %w( TextMessage PasteMessage ).freeze

        def initialize(robot)
          @robot = robot
        end

        def room_message(room)
          room.listen do |m|
            if MESSAGE_TYPES.include?(m.type)
              text    = m.body
              user    = get_user(m.user)
              source  = Source.new(user, room)
              message = Message.new(@robot, text, source)
              @robot.receive message
            end
          end
        end

        private
        def get_user(user_data)
          user_id = user_data.delete(:id)
          User.new(user_id, user_data)
        end

      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
lita-campfire-0.1 lib/lita/adapters/campfire/callback.rb