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

This method archives a channel.

Parameters:

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

    a customizable set of options

Options Hash (options):

  • :channel (channel)

    Channel to archive.

See Also:



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

def channels_archive(options = {})
  throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
  options = options.merge(channel: channels_id(options)['channel']['id']) if options[:channel]
  post('channels.archive', options)
end

#channels_create(options = {}) ⇒ Object

This method is used to create a channel.

Parameters:

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

    a customizable set of options

Options Hash (options):

  • :name (Object)

    Name of channel to create.

  • :validate (Object)

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

See Also:



30
31
32
33
# File 'lib/slack/web/api/endpoints/channels.rb', line 30

def channels_create(options = {})
  throw ArgumentError.new('Required arguments :name missing') if options[:name].nil?
  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:



41
42
43
44
45
46
# File 'lib/slack/web/api/endpoints/channels.rb', line 41

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

#channels_history(options = {}) ⇒ Object

This method returns a portion of message events from the specified public 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:



63
64
65
66
67
# File 'lib/slack/web/api/endpoints/channels.rb', line 63

def channels_history(options = {})
  throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
  options = options.merge(channel: channels_id(options)['channel']['id']) if options[:channel]
  post('channels.history', options)
end

#channels_info(options = {}) ⇒ Object

This method returns information about a team 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:



78
79
80
81
82
# File 'lib/slack/web/api/endpoints/channels.rb', line 78

def channels_info(options = {})
  throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
  options = options.merge(channel: channels_id(options)['channel']['id']) if options[:channel]
  post('channels.info', options)
end

#channels_invite(options = {}) ⇒ Object

This method is used to invite a user to a channel. The calling user must be a member of the 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:



93
94
95
96
97
98
99
# File 'lib/slack/web/api/endpoints/channels.rb', line 93

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: channels_id(options)['channel']['id']) if options[:channel]
  options = options.merge(user: users_id(options)['user']['id']) if options[:user]
  post('channels.invite', options)
end

#channels_join(options = {}) ⇒ Object

This method is used to join a channel. If the channel does not exist, it is created.

Parameters:

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

    a customizable set of options

Options Hash (options):

  • :name (Object)

    Name of channel to join.

  • :validate (Object)

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

See Also:



111
112
113
114
# File 'lib/slack/web/api/endpoints/channels.rb', line 111

def channels_join(options = {})
  throw ArgumentError.new('Required arguments :name missing') if options[:name].nil?
  post('channels.join', options)
end

#channels_kick(options = {}) ⇒ Object

This method allows a user to remove another member from a team 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:



125
126
127
128
129
130
131
# File 'lib/slack/web/api/endpoints/channels.rb', line 125

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: channels_id(options)['channel']['id']) if options[:channel]
  options = options.merge(user: users_id(options)['user']['id']) if options[:user]
  post('channels.kick', options)
end

#channels_leave(options = {}) ⇒ Object

This method is used to leave a channel.

Parameters:

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

    a customizable set of options

Options Hash (options):

  • :channel (channel)

    Channel to leave.

See Also:



140
141
142
143
144
# File 'lib/slack/web/api/endpoints/channels.rb', line 140

def channels_leave(options = {})
  throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
  options = options.merge(channel: channels_id(options)['channel']['id']) if options[:channel]
  post('channels.leave', options)
end

#channels_list(options = {}) ⇒ Object

Don’t use this method. Use conversations.list instead.

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.

See Also:



159
160
161
162
163
164
165
166
167
# File 'lib/slack/web/api/endpoints/channels.rb', line 159

def channels_list(options = {})
  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

This method moves the read cursor in a channel.

Parameters:

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

    a customizable set of options

Options Hash (options):

  • :channel (channel)

    Channel to set reading cursor in.

  • :ts (timestamp)

    Timestamp of the most recently seen message.

See Also:



178
179
180
181
182
183
# File 'lib/slack/web/api/endpoints/channels.rb', line 178

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: channels_id(options)['channel']['id']) if options[:channel]
  post('channels.mark', options)
end

#channels_rename(options = {}) ⇒ Object

This method renames a team 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:



196
197
198
199
200
201
# File 'lib/slack/web/api/endpoints/channels.rb', line 196

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: channels_id(options)['channel']['id']) if options[:channel]
  post('channels.rename', options)
end

#channels_replies(options = {}) ⇒ Object

This method returns an entire thread (a message plus all the messages in reply to it).

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:



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

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: channels_id(options)['channel']['id']) if options[:channel]
  post('channels.replies', options)
end

#channels_setPurpose(options = {}) ⇒ Object

This method is used to change the purpose of a channel. The calling user must be a member of the 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:



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

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: channels_id(options)['channel']['id']) if options[:channel]
  post('channels.setPurpose', options)
end

#channels_setTopic(options = {}) ⇒ Object

This method is used to change the topic of a channel. The calling user must be a member of the 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:



246
247
248
249
250
251
# File 'lib/slack/web/api/endpoints/channels.rb', line 246

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: channels_id(options)['channel']['id']) if options[:channel]
  post('channels.setTopic', options)
end

#channels_unarchive(options = {}) ⇒ Object

This method unarchives a channel. The calling user is added to the channel.

Parameters:

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

    a customizable set of options

Options Hash (options):

  • :channel (channel)

    Channel to unarchive.

See Also:



260
261
262
263
264
# File 'lib/slack/web/api/endpoints/channels.rb', line 260

def channels_unarchive(options = {})
  throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
  options = options.merge(channel: channels_id(options)['channel']['id']) if options[:channel]
  post('channels.unarchive', options)
end