Sha256: 4ccfca1b2b7605d4dd96f6fe0f6e5a204eb6363fe4e942c84753a8d318710040

Contents?: true

Size: 985 Bytes

Versions: 3

Compression:

Stored size: 985 Bytes

Contents

# For Twitter updates you need the 'twitter' gem
#   (gem install twitter)
#
# Configure your watches like this:
#
#   God::Contacts::Twitter.settings = { :username => 'sender@example.com',
#                                       :password  => 'secret' }
#   God.contact(:twitter) do |c|
#     c.name      = 'Tester'
#     c.group     = 'developers'
#   end

require 'twitter'

module God
  module Contacts
    class Twitter < Contact
      class << self
        attr_accessor :settings
      end

      def valid?
        valid = true
      end

      def notify(message, time, priority, category, host)
        begin
          ::Twitter::Base.new(Twitter.settings[:username], 
                              Twitter.settings[:password]).update(message)

          self.info = "sent twitter update as #{Twitter.settings[:username]}"
        rescue => e
          self.info = "failed to send twitter update from #{self.twitter_id}: #{e.message}"
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
god-0.10.1 lib/god/contacts/twitter.rb
god-0.9.0 lib/god/contacts/twitter.rb
god-0.8.0 lib/god/contacts/twitter.rb