Sha256: b07e3e788d258c424c610e99f9157003e811ee1d52ac4a36e457a2f029cd8ce6
Contents?: true
Size: 1.14 KB
Versions: 1
Compression:
Stored size: 1.14 KB
Contents
require "json" require "faraday" require 'slack/configurable' require "slack/error" require "slack/connection" require "slack/payload" module Slack class Client include Slack::Configurable include Slack::Connection 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 def same_options?(opts) opts.hash == options.hash end def post_message(text, channel, options = {}) payload = Slack::Payload.new( text: text, channel: channel, username: @username, token: @token ) response = post('chat.postMessage', payload) valid_response?(response) end def channels @channels ||= _channels end private def _channels response = get('channels.list') JSON.parse(response.body)['channels'] end def valid_response?(response) body = JSON.parse(response.body) ["true", 1].include? body['ok'] end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
slack.rb-0.0.5 | lib/slack/client.rb |