Sha256: c2575d971a9a4a4aa2515fe0c15ebc21750e23b6f1ddfd258a383945a10d4121

Contents?: true

Size: 966 Bytes

Versions: 4

Compression:

Stored size: 966 Bytes

Contents

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)
    # 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

    plugins.each do |plugin|
      begin
        rsp = plugin.handle(time, 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
robut-0.5.2 lib/robut/presence.rb
robut-0.5.1 lib/robut/presence.rb
robut-0.5.0 lib/robut/presence.rb
robut-0.4.0 lib/robut/presence.rb