Skip to content

Instantly share code, notes, and snippets.

@zulhfreelancer
Forked from marckohlbrugge/push_more.rb
Created April 14, 2018 11:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zulhfreelancer/798f47837fb4629ead71f9af13c245ee to your computer and use it in GitHub Desktop.
Save zulhfreelancer/798f47837fb4629ead71f9af13c245ee to your computer and use it in GitHub Desktop.
Example code for sending notification with Telegram's @PushMoreBot
require "net/https"
class PushMore
WEBHOOK_URL = "https://pushmore.io/webhook/REPLACE_WITH_YOUR_TOKEN"
def initialize(body)
@body = body
end
def deliver
req = Net::HTTP::Post.new(webhook_url.path)
req.body = @body
res = Net::HTTP.new(webhook_url.host, webhook_url.port)
res.use_ssl = true
res.verify_mode = OpenSSL::SSL::VERIFY_PEER
res.start { |http| http.request(req) }
end
private
def webhook_url
URI.parse WEBHOOK_URL
end
end
PushMore.new("hello world").deliver
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment