Sha256: 4846937e5e21dbe33519e1078740950d34dd763915178f93e7a42f2d3547e976

Contents?: true

Size: 1.04 KB

Versions: 4

Compression:

Stored size: 1.04 KB

Contents

STARTED = Time.now

class Robut::Presence

  # The Robut::Connection that has all the connection info.
  attr_accessor :connection

  def initialize(connection)
    self.connection = connection
  end

  # Sends the chat message +message+ through +plugins+.
  def handle_message(plugins, time, nick, message, room_name=nil)
    # ignore all messages sent by robut. If you really want robut to
    # reply to itself, you can use +fake_message+.
    return if nick == connection.config.nick

    time = Time.now
    return if time < (STARTED + 10)
    plugins.each do |plugin|
      begin
        rsp = plugin.handle(room_name, nick, message)
        break if rsp == true
      rescue => e
        error = "UH OH! #{plugin.class.name} just crashed!"

        if nick
          reply(error, nick) # Connection#reply
        else
          reply(error)       # Room#reply
        end
        if connection.config.logger
          connection.config.logger.error e
          connection.config.logger.error e.backtrace.join("\n")
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

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