Sha256: 49f9e20441a04cc9549ea2a66153cd415dfb769b0735680825004e5dd1607ec9

Contents?: true

Size: 848 Bytes

Versions: 4

Compression:

Stored size: 848 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, name)
    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

4 entries across 4 versions & 1 rubygems

Version Path
sclemmer-robut-0.6.3 lib/robut/room.rb
sclemmer-robut-0.6.2 lib/robut/room.rb
sclemmer-robut-0.6.1 lib/robut/room.rb
sclemmer-robut-0.6.0 lib/robut/room.rb