class Google::Hangout::Webhook::Message
Attributes
config_path[RW]
pre_message[RW]
response[RW]
settings[RW]
Public Class Methods
new(config_path)
click to toggle source
# File lib/google/hangout/webhook.rb, line 17 def initialize(config_path) self.config_path = config_path self.settings = YAML.load_file(config_path) self.pre_message = '' end
Public Instance Methods
broadcast(channel, message)
click to toggle source
# File lib/google/hangout/webhook.rb, line 27 def broadcast(channel, message) raise "Channel name #{channel.to_s} not found" if settings['channels'][channel.to_s].nil? raise "Channel url is missing" if settings['channels'][channel.to_s]['url'].nil? self.response = RestClient.post( settings['channels'][channel.to_s]['url'], { text: [pre_message, message].join }.to_json, { content_type: :json, accept: :json } ) rescue StandardError => e error = "Google Hangout Error: #{e.message}" puts error raise error end
reload()
click to toggle source
# File lib/google/hangout/webhook.rb, line 23 def reload self.settings = YAML.load_file(config_path) end