Add script for notifying Kosmos channels from Ruby #279
							
								
								
									
										15
									
								
								scripts/util/notify_xmpp.rb
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										15
									
								
								scripts/util/notify_xmpp.rb
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,15 @@
 | 
			
		||||
require 'uri'
 | 
			
		||||
require 'net/http'
 | 
			
		||||
require 'json'
 | 
			
		||||
 | 
			
		||||
WEBHOOK_TOKEN = "foo"
 | 
			
		||||
 | 
			
		||||
def send_notification(msg)
 | 
			
		||||
  uri = URI.parse('https://hal8000.chat.kosmos.org/incoming/#{WEBHOOK_TOKEN}')
 | 
			
		||||
  https = Net::HTTP.new(uri.host, uri.port)
 | 
			
		||||
  https.use_ssl = true
 | 
			
		||||
  request = Net::HTTP::Post.new(uri.request_uri, 'Content-Type' => 'application/json')
 | 
			
		||||
  request.body = { room: "ops@kosmos.chat", message: msg }.to_json
 | 
			
		||||
  response = https.request(request)
 | 
			
		||||
  puts response.inspect
 | 
			
		||||
end
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user