Module: Slack::Web::Channels

Included in:
Slack::Web
Defined in:
lib/slack/web/channels.rb

Overview

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.

Constant Summary collapse

SCOPE =

Endpoint scope

'channels'

Instance Method Summary collapse

Instance Method Details

#channels_archive(params = {}) ⇒ Object

Archives a channel.

Parameters:

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

    API call arguments

Options Hash (params):

  • 'channel' (channel)

    Channel to archive

See Also:



21
22
23
24
25
# 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 = {}) ⇒ Object

Creates a channel.

Parameters:

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

    API call arguments

Options Hash (params):

  • 'name' (Object)

    Name of channel to create

See Also:



35
36
37
38
39
# 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 = {}) ⇒ Object

Fetches history of messages and events from a channel.

Parameters:

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

    API call arguments

Options Hash (params):

  • 'channel' (channel)

    Channel to fetch history for.

  • 'latest' (timestamp)

    Latest message timestamp to include in results.

  • 'oldest' (timestamp)

    Oldest message timestamp to include in results.

  • 'inclusive' (Object)

    Include messages with latest or oldest timestamp in results.

  • 'count' (Object)

    Number of messages to return, between 1 and 1000.

See Also:



57
58
59
60
61
# 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 = {}) ⇒ Object

Gets information about a channel.

Parameters:

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

    API call arguments

Options Hash (params):

  • 'channel' (channel)

    Channel to get info on

See Also:



71
72
73
74
75
# 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 = {}) ⇒ Object

Invites a user to a channel.

Parameters:

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

    API call arguments

Options Hash (params):

  • 'channel' (channel)

    Channel to invite user to.

  • 'user' (user)

    User to invite to channel.

See Also:



87
88
89
90
91
92
# 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 = {}) ⇒ Object

Joins a channel, creating it if needed.

Parameters:

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

    API call arguments

Options Hash (params):

  • 'name' (Object)

    Name of channel to join

See Also:



102
103
104
105
106
# 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 = {}) ⇒ Object

Removes a user from a channel.

Parameters:

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

    API call arguments

Options Hash (params):

  • 'channel' (channel)

    Channel to remove user from.

  • 'user' (user)

    User to remove from channel.

See Also:



118
119
120
121
122
123
# 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 = {}) ⇒ Object

Leaves a channel.

Parameters:

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

    API call arguments

Options Hash (params):

  • 'channel' (channel)

    Channel to leave

See Also:



132
133
134
135
136
# 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 = {}) ⇒ Object

Lists all channels in a Slack team.

Parameters:

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

    API call arguments

Options Hash (params):

  • 'exclude_archived' (Object)

    Don't return archived channels.

See Also:



146
147
148
149
# 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 = {}) ⇒ Object

Sets the read cursor in a channel.

Parameters:

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

    API call arguments

Options Hash (params):

  • 'channel' (channel)

    Channel to set reading cursor in.

  • 'ts' (timestamp)

    Timestamp of the most recently seen message.

See Also:



161
162
163
164
165
166
# 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 = {}) ⇒ Object

Renames a channel.

Parameters:

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

    API call arguments

Options Hash (params):

  • 'channel' (channel)

    Channel to rename

  • 'name' (Object)

    New name for channel.

See Also:



178
179
180
181
182
183
# 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 = {}) ⇒ Object

Sets the purpose for a channel.

Parameters:

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

    API call arguments

Options Hash (params):

  • 'channel' (channel)

    Channel to set the purpose of

  • 'purpose' (Object)

    The new purpose

See Also:



195
196
197
198
199
200
# 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 = {}) ⇒ Object

Sets the topic for a channel.

Parameters:

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

    API call arguments

Options Hash (params):

  • 'channel' (channel)

    Channel to set the topic of

  • 'topic' (Object)

    The new topic

Raises:

  • (ArgumentError)

    if 'channel' or 'topic' are not present

See Also:



212
213
214
215
216
217
# 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 = {}) ⇒ Object

Unarchives a channel.

Parameters:

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

    API call arguments

Options Hash (params):

  • 'channel' (channel)

    Channel to unarchive

Raises:

  • (ArgumentError)

    if 'channel' is not present

See Also:



227
228
229
230
231
# 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