Module: Slack::Web::Api::Endpoints::Channels

Included in:
Slack::Web::Api::Endpoints
Defined in:
lib/slack/web/api/endpoints/channels.rb

Instance Method Summary collapse

Instance Method Details

#channels_archive(options = {}) ⇒ Object

Archives a channel.

Parameters:

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :channel (channel)

    Channel to archive.

See Also:



16
17
18
19
20
21
# File 'lib/slack/web/api/endpoints/channels.rb', line 16

def channels_archive(options = {})
  throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
  options = options.merge(channel: conversations_id(options)['channel']['id']) if options[:channel]
  logger.warn('channels.archive: This method is deprecated. It will stop functioning in February 2021 and will not work with newly created apps after June 10th, 2020. Alternative methods: conversations.archive.')
  post('channels.archive', options)
end

#channels_create(options = {}) ⇒ Object

Creates a channel.

Parameters:

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :name (Object)

    Name of channel to create.

  • :team_id (Object)

    encoded team id to create the channel in, required if org token is used.

  • :validate (Object)

    Whether to return errors on invalid channel name instead of modifying it to meet the specified criteria.

See Also:



34
35
36
37
38
# File 'lib/slack/web/api/endpoints/channels.rb', line 34

def channels_create(options = {})
  throw ArgumentError.new('Required arguments :name missing') if options[:name].nil?
  logger.warn('channels.create: This method is deprecated. It will stop functioning in February 2021 and will not work with newly created apps after June 10th, 2020. Alternative methods: conversations.create.')
  post('channels.create', options)
end

#channels_delete(options = {}) ⇒ Object

Delete a channel (undocumented)

Parameters:

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :channel (channel)

    Channel to delete.

See Also:



46
47
48
49
50
51
# File 'lib/slack/web/api/endpoints/channels.rb', line 46

def channels_delete(options = {})
  throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
  options = options.merge(channel: conversations_id(options)['channel']['id']) if options[:channel]
  logger.warn('The channels.delete method is undocumented.')
  post('channels.delete', options)
end

#channels_history(options = {}) ⇒ Object

Fetches history of messages and events from a channel.

Parameters:

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :channel (channel)

    Channel to fetch history for.

  • :inclusive (Object)

    Include messages with latest or oldest timestamp in results.

  • :latest (timestamp)

    End of time range of messages to include in results.

  • :oldest (timestamp)

    Start of time range of messages to include in results.

  • :unreads (Object)

    Include unread_count_display in the output?.

See Also:



68
69
70
71
72
73
# File 'lib/slack/web/api/endpoints/channels.rb', line 68

def channels_history(options = {})
  throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
  options = options.merge(channel: conversations_id(options)['channel']['id']) if options[:channel]
  logger.warn('channels.history: This method is deprecated. It will stop functioning in February 2021 and will not work with newly created apps after June 10th, 2020. Alternative methods: conversations.history.')
  post('channels.history', options)
end

#channels_info(options = {}) ⇒ Object

Gets information about a channel.

Parameters:

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :channel (channel)

    Channel to get info on.

  • :include_locale (Object)

    Set this to true to receive the locale for this channel. Defaults to false.

See Also:



84
85
86
87
88
89
# File 'lib/slack/web/api/endpoints/channels.rb', line 84

def channels_info(options = {})
  throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
  options = options.merge(channel: conversations_id(options)['channel']['id']) if options[:channel]
  logger.warn('channels.info: This method is deprecated. It will stop functioning in February 2021 and will not work with newly created apps after June 10th, 2020. Alternative methods: conversations.info.')
  post('channels.info', options)
end

#channels_invite(options = {}) ⇒ Object

Invites a user to a channel.

Parameters:

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :channel (channel)

    Channel to invite user to.

  • :user (user)

    User to invite to channel.

See Also:



100
101
102
103
104
105
106
107
# File 'lib/slack/web/api/endpoints/channels.rb', line 100

def channels_invite(options = {})
  throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
  throw ArgumentError.new('Required arguments :user missing') if options[:user].nil?
  options = options.merge(channel: conversations_id(options)['channel']['id']) if options[:channel]
  options = options.merge(user: users_id(options)['user']['id']) if options[:user]
  logger.warn('channels.invite: This method is deprecated. It will stop functioning in February 2021 and will not work with newly created apps after June 10th, 2020. Alternative methods: conversations.invite.')
  post('channels.invite', options)
end

#channels_join(options = {}) ⇒ Object

Joins a channel, creating it if needed.

Parameters:

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :name (Object)

    Name of channel to join.

  • :team_id (Object)

    encoded team id to list channels in, required if org token is used.

  • :validate (Object)

    Whether to return errors on invalid channel name instead of modifying it to meet the specified criteria.

See Also:



120
121
122
123
124
# File 'lib/slack/web/api/endpoints/channels.rb', line 120

def channels_join(options = {})
  throw ArgumentError.new('Required arguments :name missing') if options[:name].nil?
  logger.warn('channels.join: This method is deprecated. It will stop functioning in February 2021 and will not work with newly created apps after June 10th, 2020. Alternative methods: conversations.join.')
  post('channels.join', options)
end

#channels_kick(options = {}) ⇒ Object

Removes a user from a channel.

Parameters:

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :channel (channel)

    Channel to remove user from.

  • :user (user)

    User to remove from channel.

See Also:



135
136
137
138
139
140
141
142
# File 'lib/slack/web/api/endpoints/channels.rb', line 135

def channels_kick(options = {})
  throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
  throw ArgumentError.new('Required arguments :user missing') if options[:user].nil?
  options = options.merge(channel: conversations_id(options)['channel']['id']) if options[:channel]
  options = options.merge(user: users_id(options)['user']['id']) if options[:user]
  logger.warn('channels.kick: This method is deprecated. It will stop functioning in February 2021 and will not work with newly created apps after June 10th, 2020. Alternative methods: conversations.kick.')
  post('channels.kick', options)
end

#channels_leave(options = {}) ⇒ Object

Leaves a channel.

Parameters:

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :channel (channel)

    Channel to leave.

See Also:



151
152
153
154
155
156
# File 'lib/slack/web/api/endpoints/channels.rb', line 151

def channels_leave(options = {})
  throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
  options = options.merge(channel: conversations_id(options)['channel']['id']) if options[:channel]
  logger.warn('channels.leave: This method is deprecated. It will stop functioning in February 2021 and will not work with newly created apps after June 10th, 2020. Alternative methods: conversations.leave.')
  post('channels.leave', options)
end

#channels_list(options = {}) ⇒ Object

Lists all channels in a Slack team.

Parameters:

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :cursor (Object)

    Paginate through collections of data by setting the cursor parameter to a next_cursor attribute returned by a previous request’s response_metadata. Default value fetches the first “page” of the collection. See pagination for more detail.

  • :exclude_archived (Object)

    Exclude archived channels from the list.

  • :exclude_members (Object)

    Exclude the members collection from each channel.

  • :limit (Object)

    The maximum number of items to return. Fewer than the requested number of items may be returned, even if the end of the users list hasn’t been reached.

  • :team_id (Object)

    encoded team id to list channels in, required if org token is used.

See Also:



173
174
175
176
177
178
179
180
181
182
# File 'lib/slack/web/api/endpoints/channels.rb', line 173

def channels_list(options = {})
  logger.warn('channels.list: This method is deprecated. It will stop functioning in February 2021 and will not work with newly created apps after June 10th, 2020. Alternative methods: conversations.list, users.conversations.')
  if block_given?
    Pagination::Cursor.new(self, :channels_list, options).each do |page|
      yield page
    end
  else
    post('channels.list', options)
  end
end

#channels_mark(options = {}) ⇒ Object

Sets the read cursor in a channel.

Parameters:

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :channel (channel)

    Channel or conversation to set the read cursor for.

  • :ts (timestamp)

    Unique identifier of message you want marked as most recently seen in this conversation.

See Also:



193
194
195
196
197
198
199
# File 'lib/slack/web/api/endpoints/channels.rb', line 193

def channels_mark(options = {})
  throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
  throw ArgumentError.new('Required arguments :ts missing') if options[:ts].nil?
  options = options.merge(channel: conversations_id(options)['channel']['id']) if options[:channel]
  logger.warn('channels.mark: This method is deprecated. It will stop functioning in February 2021 and will not work with newly created apps after June 10th, 2020. Alternative methods: conversations.mark.')
  post('channels.mark', options)
end

#channels_rename(options = {}) ⇒ Object

Renames a channel.

Parameters:

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :channel (channel)

    Channel to rename.

  • :name (Object)

    New name for channel.

  • :validate (Object)

    Whether to return errors on invalid channel name instead of modifying it to meet the specified criteria.

See Also:



212
213
214
215
216
217
218
# File 'lib/slack/web/api/endpoints/channels.rb', line 212

def channels_rename(options = {})
  throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
  throw ArgumentError.new('Required arguments :name missing') if options[:name].nil?
  options = options.merge(channel: conversations_id(options)['channel']['id']) if options[:channel]
  logger.warn('channels.rename: This method is deprecated. It will stop functioning in February 2021 and will not work with newly created apps after June 10th, 2020. Alternative methods: conversations.rename.')
  post('channels.rename', options)
end

#channels_replies(options = {}) ⇒ Object

Retrieve a thread of messages posted to a channel

Parameters:

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :channel (channel)

    Channel to fetch thread from.

  • :thread_ts (Object)

    Unique identifier of a thread’s parent message.

See Also:



229
230
231
232
233
234
235
# File 'lib/slack/web/api/endpoints/channels.rb', line 229

def channels_replies(options = {})
  throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
  throw ArgumentError.new('Required arguments :thread_ts missing') if options[:thread_ts].nil?
  options = options.merge(channel: conversations_id(options)['channel']['id']) if options[:channel]
  logger.warn('channels.replies: This method is deprecated. It will stop functioning in February 2021 and will not work with newly created apps after June 10th, 2020. Alternative methods: conversations.replies.')
  post('channels.replies', options)
end

#channels_setPurpose(options = {}) ⇒ Object

Sets the purpose for a channel.

Parameters:

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :channel (channel)

    Channel to set the purpose of.

  • :purpose (Object)

    The new purpose.

  • :name_tagging (Object)

    if it is true, treat this like a message and not an unescaped thing.

See Also:



248
249
250
251
252
253
254
# File 'lib/slack/web/api/endpoints/channels.rb', line 248

def channels_setPurpose(options = {})
  throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
  throw ArgumentError.new('Required arguments :purpose missing') if options[:purpose].nil?
  options = options.merge(channel: conversations_id(options)['channel']['id']) if options[:channel]
  logger.warn('channels.setPurpose: This method is deprecated. It will stop functioning in February 2021 and will not work with newly created apps after June 10th, 2020. Alternative methods: conversations.setPurpose.')
  post('channels.setPurpose', options)
end

#channels_setTopic(options = {}) ⇒ Object

Sets the topic for a channel.

Parameters:

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :channel (channel)

    Channel to set the topic of.

  • :topic (Object)

    The new topic.

See Also:



265
266
267
268
269
270
271
# File 'lib/slack/web/api/endpoints/channels.rb', line 265

def channels_setTopic(options = {})
  throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
  throw ArgumentError.new('Required arguments :topic missing') if options[:topic].nil?
  options = options.merge(channel: conversations_id(options)['channel']['id']) if options[:channel]
  logger.warn('channels.setTopic: This method is deprecated. It will stop functioning in February 2021 and will not work with newly created apps after June 10th, 2020. Alternative methods: conversations.setTopic.')
  post('channels.setTopic', options)
end

#channels_unarchive(options = {}) ⇒ Object

Unarchives a channel.

Parameters:

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :channel (channel)

    Channel to unarchive.

See Also:



280
281
282
283
284
285
# File 'lib/slack/web/api/endpoints/channels.rb', line 280

def channels_unarchive(options = {})
  throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
  options = options.merge(channel: conversations_id(options)['channel']['id']) if options[:channel]
  logger.warn('channels.unarchive: This method is deprecated. It will stop functioning in February 2021 and will not work with newly created apps after June 10th, 2020. Alternative methods: conversations.unarchive.')
  post('channels.unarchive', options)
end