Sha256: 131988c9267e6fdc6d16fd65e4a9a26bfe26f9a5c1650a54ad443d06d7ced27f

Contents?: true

Size: 842 Bytes

Versions: 5

Compression:

Stored size: 842 Bytes

Contents

# Handles connections and responses to different rooms. 
class Robut::Room < Robut::Presence

  # The MUC that wraps the Jabber Chat protocol.
  attr_accessor :muc

  # The room jid
  attr_accessor :name

  def initialize(connection, room_name)
    self.muc        = Jabber::MUC::SimpleMUCClient.new(connection.client)
    self.connection = connection
    self.name       = room_name
  end

  def join
    # Add the callback from messages that occur inside the room
    muc.on_message do |time, nick, message|
      plugins = Robut::Plugin.plugins.map { |p| p.new(self) }
      handle_message(plugins, time, nick, message)
    end

    muc.join(self.name + '/' + connection.config.nick)
  end

  # Send +message+ to the room we're currently connected to
  def reply(message, to)
    muc.send(Jabber::Message.new(muc.room, message))
  end
end

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
sclemmer-robut-0.5.2 lib/robut/room.rb
robut-0.5.2 lib/robut/room.rb
robut-0.5.1 lib/robut/room.rb
robut-0.5.0 lib/robut/room.rb
robut-0.4.0 lib/robut/room.rb