Add script for notifying Kosmos channels from Ruby

An example for notifying Kosmos XMPP channels from plain Ruby, with no
dependencies.
This commit is contained in:
Basti 2021-01-06 11:27:50 +01:00
parent 333a76f086
commit eb4764026b
Signed by untrusted user: basti
GPG Key ID: 9F88009D31D99C72
1 changed files with 15 additions and 0 deletions

View 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