Skip to content

Instantly share code, notes, and snippets.

@jtadeulopes
Created August 14, 2014 01:18
Show Gist options
  • Select an option

  • Save jtadeulopes/2cda8f9f5364490a557f to your computer and use it in GitHub Desktop.

Select an option

Save jtadeulopes/2cda8f9f5364490a557f to your computer and use it in GitHub Desktop.

Revisions

  1. jtadeulopes created this gist Aug 14, 2014.
    18 changes: 18 additions & 0 deletions slack.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,18 @@
    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 :)')