Class: Slackbot
- Inherits:
-
Object
- Object
- Slackbot
- Defined in:
- lib/slackbot.rb
Constant Summary collapse
- REMOTE_ENDPOINT =
"https://%s.slack.com"
- REMOTE_PATH =
"/services/hooks/slackbot?token=%s&channel=%s"
Instance Method Summary collapse
-
#initialize(subdomain, token) ⇒ Slackbot
constructor
A new instance of Slackbot.
- #send(channel, message) ⇒ Object
Constructor Details
#initialize(subdomain, token) ⇒ Slackbot
Returns a new instance of Slackbot.
10 11 12 13 |
# File 'lib/slackbot.rb', line 10 def initialize(subdomain, token) @endpoint = URI(REMOTE_ENDPOINT % URI.encode(subdomain)) @token = token end |
Instance Method Details
#send(channel, message) ⇒ Object
15 16 17 18 19 20 21 22 23 |
# File 'lib/slackbot.rb', line 15 def send(channel, ) http = Net::HTTP.new(@endpoint.host, @endpoint.port) http.use_ssl = true request = Net::HTTP::Post.new(path(channel)) request.body = http.request(request) end |