module Slack::Ruby3
Constants
- VERSION
Public Class Methods
push(webhook_url: "", message: "hoi!")
click to toggle source
# File lib/slack/ruby3.rb, line 10 def self.push webhook_url: "", message: "hoi!" uri = URI.parse(webhook_url) http = Net::HTTP.new(uri.host, uri.port) http.use_ssl = true http.verify_mode = OpenSSL::SSL::VERIFY_NONE req = Net::HTTP::Post.new(uri.path, initheader = { "Content-Type" => "application/json" }) req.body = { text: message }.to_json status_code = http.request(req).code return "Sent Message: #{message}" if status_code.to_i == 200 "Error Code: #{status_code}\nSomething wrong." end