Sha256: 8d1307ee3e280345bfed0c24a52842cbd2016668906996a9cc5fb467c74bd131

Contents?: true

Size: 1.4 KB

Versions: 3

Compression:

Stored size: 1.4 KB

Contents

require 'nagios-herald/messages/base'
# probs need socket here

module NagiosHerald
  class Message
    class IRC < Message

      attr_accessor :text

      # Public: Initializes a new Message::IRC object.
      #
      # recipients - A list of recipients for this message.
      # options - The options hash from Executor.
      # FIXME: Is that ^^ necessary now with Config.config available?
      #
      # Returns a new Message::IRC object.
      def initialize(recipients, options = {})
        @text = ""
        super(recipients, options)
      end

      # Public: Generates the text portion of the content hash.
      #
      # Returns the full text portion of the content hash.
      def curate_text
        # FIXME: Gonna need to chomp newlines
        @text += self.content[:text][:host_info]
        @text += self.content[:text][:state_info]
        @text += self.content[:text][:alert_ack_url]
      end

      # Public: Prints the text content to the terminal.
      # Useful for debugging.
      #
      # Returns nothing.
      def print
        puts @text
      end

      # Public: Sends the IRC message.
      #
      # Returns nothing.
      def send
        curate_text
        if @no_send
          self.print
          return
        end

        # TODO: Actually make this send to an IRC server
        # I expect the IRC server will be a value in the config
        self.print
      end

    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
nagios-herald-0.0.4 lib/nagios-herald/messages/irc.rb
nagios-herald-0.0.3 lib/nagios-herald/messages/irc.rb
nagios-herald-0.0.2 lib/nagios-herald/messages/irc.rb