Skip to content

Instantly share code, notes, and snippets.

@jtadeulopes
Created August 14, 2014 01:18
Show Gist options
  • Save jtadeulopes/2cda8f9f5364490a557f to your computer and use it in GitHub Desktop.
Save jtadeulopes/2cda8f9f5364490a557f to your computer and use it in GitHub Desktop.
Slack Bot
require 'httparty'
class SlackRuby
include HTTParty
base_uri 'slack.com/api'
def initialize(token)
@token = token
end
def post_message(args)
options = { query: args.merge!(token: @token) }
self.class.post('/chat.postMessage', options)
end
end
slack = SlackRuby.new('slack-token-api')
puts slack.post_message(channel: 'channel-id', text: 'Oi :)')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment