Sha256: 3dd58451ae10b668fc884ca96896069ac6e38f0272eee004f32a266bfbb1fb42
Contents?: true
Size: 900 Bytes
Versions: 12
Compression:
Stored size: 900 Bytes
Contents
module Slack module Web module Api module Mixins module Channels # # This method returns a channel ID given a channel name. # # @option options [channel] :channel # Channel to get ID for, prefixed with #. def channels_id(options = {}) name = options[:channel] throw ArgumentError.new('Required arguments :channel missing') if name.nil? return { 'ok' => true, 'channel' => { 'id' => name } } unless name[0] == '#' channels_list.tap do |list| list.channels.each do |channel| return Slack::Messages::Message.new('ok' => true, 'channel' => { 'id' => channel.id }) if channel.name == name[1..-1] end end fail Slack::Web::Api::Error, 'channel_not_found' end end end end end end
Version data entries
12 entries across 12 versions & 1 rubygems