class Slack::Client
Public Class Methods
new(options = {})
click to toggle source
# File lib/slack/client.rb, line 14 def initialize(options = {}) # Use options passed in, but fall back to module defaults Slack::Configurable.keys.each do |key| instance_variable_set(:"@#{key}", options[key] || Slack.instance_variable_get(:"@#{key}")) end end
Public Instance Methods
channels()
click to toggle source
# File lib/slack/client.rb, line 39 def channels @channels ||= _channels end
post_message(text, channel, options = {})
click to toggle source
# File lib/slack/client.rb, line 25 def post_message(text, channel, options = {}) payload = Slack::Payload.new( text: text, channel: channel, username: @username, token: @token, icon_url: @icon_url, attachments: options[:attachments] ) response = post('chat.postMessage', payload) valid_response?(response) end
same_options?(opts)
click to toggle source
# File lib/slack/client.rb, line 21 def same_options?(opts) opts.hash == options.hash end
Private Instance Methods
_channels()
click to toggle source
# File lib/slack/client.rb, line 45 def _channels response = get('channels.list') JSON.parse(response.body)['channels'] end
valid_response?(response)
click to toggle source
# File lib/slack/client.rb, line 50 def valid_response?(response) body = JSON.parse(response.body) [true, 1].include? body['ok'] end