module Slack::Web::Channels

Module for the channels methods. Get info on your team's Slack channels, create or archive channels, invite users, set the topic and purpose, and mark a channel as read.

Constants

SCOPE

Endpoint scope

Public Instance Methods

channels_archive(params = {}) click to toggle source

Archives a channel.

@param [Hash] params

API call arguments

@option params [channel] 'channel'

Channel to archive

@see api.slack.com/methods/channels.archive

# File lib/slack/web/channels.rb, line 21
def channels_archive(params = {})
  fail ArgumentError, "Required arguments 'channel' missing" if params['channel'].nil?
  response = @session.do_post "#{SCOPE}.archive", params
  Slack.parse_response(response)
end
channels_create(params = {}) click to toggle source

Creates a channel.

@param [Hash] params

API call arguments

@option params [Object] 'name'

Name of channel to create

@see api.slack.com/methods/channels.create

# File lib/slack/web/channels.rb, line 35
def channels_create(params = {})
  fail ArgumentError, "Required arguments 'name' missing" if params['name'].nil?
  response = @session.do_post "#{SCOPE}.create", params
  Slack.parse_response(response)
end
channels_history(params = {}) click to toggle source

Fetches history of messages and events from a channel.

@param [Hash] params

API call arguments

@option params [channel] 'channel'

Channel to fetch history for.

@option params [timestamp] 'latest'

Latest message timestamp to include in results.

@option params [timestamp] 'oldest'

Oldest message timestamp to include in results.

@option params [Object] 'inclusive'

Include messages with latest or oldest timestamp in results.

@option params [Object] 'count'

Number of messages to return, between 1 and 1000.

@see api.slack.com/methods/channels.history

# File lib/slack/web/channels.rb, line 57
def channels_history(params = {})
  fail ArgumentError, "Required arguments 'channel' missing" if params['channel'].nil?
  response = @session.do_post "#{SCOPE}.history", params
  Slack.parse_response(response)
end
channels_info(params = {}) click to toggle source

Gets information about a channel.

@param [Hash] params

API call arguments

@option params [channel] 'channel'

Channel to get info on

@see api.slack.com/methods/channels.info

# File lib/slack/web/channels.rb, line 71
def channels_info(params = {})
  fail ArgumentError, "Required arguments 'channel' missing" if params['channel'].nil?
  response = @session.do_post "#{SCOPE}.info", params
  Slack.parse_response(response)
end
channels_invite(params = {}) click to toggle source

Invites a user to a channel.

@param [Hash] params

API call arguments

@option params [channel] 'channel'

Channel to invite user to.

@option params [user] 'user'

User to invite to channel.

@see api.slack.com/methods/channels.invite

# File lib/slack/web/channels.rb, line 87
def channels_invite(params = {})
  fail ArgumentError, "Required arguments 'channel' missing" if params['channel'].nil?
  fail ArgumentError, "Required arguments 'user' missing" if params['user'].nil?
  response = @session.do_post "#{SCOPE}.invite", params
  Slack.parse_response(response)
end
channels_join(params = {}) click to toggle source

Joins a channel, creating it if needed.

@param [Hash] params

API call arguments

@option params [Object] 'name'

Name of channel to join

@see api.slack.com/methods/channels.join

# File lib/slack/web/channels.rb, line 102
def channels_join(params = {})
  fail ArgumentError, "Required arguments 'name' missing" if params['name'].nil?
  response = @session.do_post "#{SCOPE}.join", params
  Slack.parse_response(response)
end
channels_kick(params = {}) click to toggle source

Removes a user from a channel.

@param [Hash] params

API call arguments

@option params [channel] 'channel'

Channel to remove user from.

@option params [user] 'user'

User to remove from channel.

@see api.slack.com/methods/channels.kick

# File lib/slack/web/channels.rb, line 118
def channels_kick(params = {})
  fail ArgumentError, "Required arguments 'channel' missing" if params['channel'].nil?
  fail ArgumentError, "Required arguments 'user' missing" if params['user'].nil?
  response = @session.do_post "#{SCOPE}.kick", params
  Slack.parse_response(response)
end
channels_leave(params = {}) click to toggle source

Leaves a channel.

@param [Hash] params

API call arguments

@option params [channel] 'channel'

Channel to leave

@see api.slack.com/methods/channels.leave

# File lib/slack/web/channels.rb, line 132
def channels_leave(params = {})
  fail ArgumentError, "Required arguments 'channel' missing" if params['channel'].nil?
  response = @session.do_post "#{SCOPE}.leave", params
  Slack.parse_response(response)
end
channels_list(params = {}) click to toggle source

Lists all channels in a Slack team.

@param [Hash] params

API call arguments

@option params [Object] 'exclude_archived'

Don't return archived channels.

@see api.slack.com/methods/channels.list

# File lib/slack/web/channels.rb, line 146
def channels_list(params = {})
  response = @session.do_post "#{SCOPE}.list", params
  Slack.parse_response(response)
end
channels_mark(params = {}) click to toggle source

Sets the read cursor in a channel.

@param [Hash] params

API call arguments

@option params [channel] 'channel'

Channel to set reading cursor in.

@option params [timestamp] 'ts'

Timestamp of the most recently seen message.

@see api.slack.com/methods/channels.mark

# File lib/slack/web/channels.rb, line 161
def channels_mark(params = {})
  fail ArgumentError, "Required arguments 'channel' missing" if params['channel'].nil?
  fail ArgumentError, "Required arguments 'ts' missing" if params['ts'].nil?
  response = @session.do_post "#{SCOPE}.mark", params
  Slack.parse_response(response)
end
channels_rename(params = {}) click to toggle source

Renames a channel.

@param [Hash] params

API call arguments

@option params [channel] 'channel'

Channel to rename

@option params [Object] 'name'

New name for channel.

@see api.slack.com/methods/channels.rename

# File lib/slack/web/channels.rb, line 178
def channels_rename(params = {})
  fail ArgumentError, "Required arguments 'channel' missing" if params['channel'].nil?
  fail ArgumentError, "Required arguments 'name' missing" if params['name'].nil?
  response = @session.do_post "#{SCOPE}.rename", params
  Slack.parse_response(response)
end
channels_set_purpose(params = {}) click to toggle source

Sets the purpose for a channel.

@param [Hash] params

API call arguments

@option params [channel] 'channel'

Channel to set the purpose of

@option params [Object] 'purpose'

The new purpose

@see api.slack.com/methods/channels.setPurpose

# File lib/slack/web/channels.rb, line 195
def channels_set_purpose(params = {})
  fail ArgumentError, "Required arguments 'channel' missing" if params['channel'].nil?
  fail ArgumentError, "Required arguments 'purpose' missing" if params['purpose'].nil?
  response = @session.do_post "#{SCOPE}.setPurpose", params
  Slack.parse_response(response)
end
channels_set_topic(params = {}) click to toggle source

Sets the topic for a channel.

@param [Hash] params

API call arguments

@option params [channel] 'channel'

Channel to set the topic of

@option params [Object] 'topic'

The new topic

@raise [ArgumentError] if 'channel' or 'topic' are not present @see api.slack.com/methods/channels.setTopic

# File lib/slack/web/channels.rb, line 212
def channels_set_topic(params = {})
  fail ArgumentError, "Required arguments 'channel' missing" if params['channel'].nil?
  fail ArgumentError, "Required arguments 'topic' missing" if params['topic'].nil?
  response = @session.do_post "#{SCOPE}.setTopic", params
  Slack.parse_response(response)
end
channels_unarchive(params = {}) click to toggle source

Unarchives a channel.

@param [Hash] params

API call arguments

@option params [channel] 'channel'

Channel to unarchive

@raise [ArgumentError] if 'channel' is not present @see api.slack.com/methods/channels.unarchive

# File lib/slack/web/channels.rb, line 227
def channels_unarchive(params = {})
  fail ArgumentError, "Required arguments 'channel' missing" if params['channel'].nil?
  response = @session.do_post "#{SCOPE}.unarchive", params
  Slack.parse_response(response)
end