slack-ruby-client 0.13.1 → 0.14.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +3 -0
  3. data/.rubocop_todo.yml +9 -32
  4. data/.travis.yml +4 -4
  5. data/CHANGELOG.md +10 -0
  6. data/Dangerfile +1 -0
  7. data/Gemfile +1 -3
  8. data/LICENSE.md +1 -1
  9. data/README.md +100 -13
  10. data/bin/commands.rb +1 -0
  11. data/bin/commands/apps.rb +14 -0
  12. data/bin/commands/chat.rb +5 -1
  13. data/bin/commands/conversations.rb +1 -0
  14. data/bin/commands/files.rb +8 -9
  15. data/bin/commands/reactions.rb +2 -2
  16. data/bin/slack +1 -1
  17. data/lib/slack-ruby-client.rb +4 -0
  18. data/lib/slack/events/config.rb +31 -0
  19. data/lib/slack/events/request.rb +60 -0
  20. data/lib/slack/real_time/client.rb +35 -7
  21. data/lib/slack/real_time/concurrency/async.rb +34 -2
  22. data/lib/slack/real_time/concurrency/celluloid.rb +28 -9
  23. data/lib/slack/real_time/concurrency/eventmachine.rb +25 -4
  24. data/lib/slack/real_time/socket.rb +19 -0
  25. data/lib/slack/real_time/stores/store.rb +2 -0
  26. data/lib/slack/version.rb +1 -1
  27. data/lib/slack/web/api/endpoints.rb +2 -0
  28. data/lib/slack/web/api/endpoints/apps.rb +26 -0
  29. data/lib/slack/web/api/endpoints/chat.rb +30 -4
  30. data/lib/slack/web/api/endpoints/conversations.rb +2 -0
  31. data/lib/slack/web/api/endpoints/files.rb +8 -9
  32. data/lib/slack/web/api/endpoints/reactions.rb +2 -2
  33. data/lib/slack/web/api/patches/chat.6.block-kit-support.patch +69 -0
  34. data/lib/slack/web/pagination/cursor.rb +3 -0
  35. data/lib/tasks/real_time.rake +2 -0
  36. data/lib/tasks/web.rake +1 -0
  37. data/slack-ruby-client.gemspec +3 -2
  38. data/spec/integration/integration_spec.rb +64 -6
  39. data/spec/slack/events/config_spec.rb +29 -0
  40. data/spec/slack/events/request_spec.rb +121 -0
  41. data/spec/slack/real_time/client_spec.rb +36 -1
  42. data/spec/slack/real_time/concurrency/eventmachine_spec.rb +1 -0
  43. data/spec/slack/web/api/endpoints/apps_spec.rb +15 -0
  44. data/spec/slack/web/api/endpoints/custom_specs/chat_spec.rb +45 -24
  45. data/spec/spec_helper.rb +1 -0
  46. data/spec/support/queue_with_timeout.rb +4 -4
  47. metadata +29 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ab472063785c95f073bf42b275abd64d6189eb81d93187710b0be994216af4c5
4
- data.tar.gz: 3c3621f8dd346a3e6cb87510547b455493a95ba89e27fc8abf844d25a9b1bf88
3
+ metadata.gz: 41b05d465011510580551afbef311aa1df18063ca138248729182151b0338dc7
4
+ data.tar.gz: 8a38b38f90eb718d5c54cc7adf40384fa059d93deb82265b9bf29bcaf0de9ec1
5
5
  SHA512:
6
- metadata.gz: 0aafa2c9b320423d1d60e6edfb7ab5683ce574a6cb6af8a5585be988ea87864e43fe2cea32a387c25716e699a5ff7cbcc353418151f89105d6427954fa24c0fb
7
- data.tar.gz: 559cba90e5ab1906c035399b598a6279441696418c2c5d77ec2040aa6445e244a71c97d5f6d39dcd8c5ded21841e4c0bf1d3c05d2f02b066b233beb6524dc4bf
6
+ metadata.gz: a7781e6f5438b9b4684b99eec70180906b5cba1bd325ef03df3b8e4b40321b186b00ff96962ccc67c4923a3d560beea8859737fb9e18010b6c53a6e8c99b0bf0
7
+ data.tar.gz: 0dee1a1224b31a368176b7e5f7ebec109135c9b4f54ccb3827d6e4165a61d94e0a97ca06dfd1b87427494c287dd455ab598ee1b363703f3778756308ec486ccf
@@ -15,4 +15,7 @@ Style/Documentation:
15
15
  Naming/MethodName:
16
16
  Enabled: false
17
17
 
18
+ Style/ModuleFunction:
19
+ Enabled: false
20
+
18
21
  inherit_from: .rubocop_todo.yml
@@ -1,6 +1,6 @@
1
1
  # This configuration was generated by
2
2
  # `rubocop --auto-gen-config`
3
- # on 2018-08-27 13:29:57 +0200 using RuboCop version 0.58.2.
3
+ # on 2019-01-19 17:37:31 -0500 using RuboCop version 0.61.1.
4
4
  # The point is for the user to remove these configuration records
5
5
  # one by one as the offenses are removed from the code base.
6
6
  # Note that changes in the inspected code, or installation of new
@@ -13,6 +13,13 @@ Lint/HandleExceptions:
13
13
  - 'spec/slack/real_time/concurrency/celluloid_spec.rb'
14
14
  - 'spec/slack/real_time/concurrency/eventmachine_spec.rb'
15
15
 
16
+ # Offense count: 1
17
+ # Configuration parameters: ExpectMatchingDefinition, Regex, IgnoreExecutableScripts, AllowedAcronyms.
18
+ # AllowedAcronyms: CLI, DSL, ACL, API, ASCII, CPU, CSS, DNS, EOF, GUID, HTML, HTTP, HTTPS, ID, IP, JSON, LHS, QPS, RAM, RHS, RPC, SLA, SMTP, SQL, SSH, TCP, TLS, TTL, UDP, UI, UID, UUID, URI, URL, UTF8, VM, XML, XMPP, XSRF, XSS
19
+ Naming/FileName:
20
+ Exclude:
21
+ - 'lib/slack-ruby-client.rb'
22
+
16
23
  # Offense count: 1
17
24
  # Configuration parameters: EnforcedStyleForLeadingUnderscores.
18
25
  # SupportedStylesForLeadingUnderscores: disallowed, required, optional
@@ -20,13 +27,6 @@ Naming/MemoizedInstanceVariableName:
20
27
  Exclude:
21
28
  - 'lib/slack/logger.rb'
22
29
 
23
- # Offense count: 2
24
- # Configuration parameters: MinNameLength, AllowNamesEndingInNumbers, AllowedNames, ForbiddenNames.
25
- # AllowedNames: io, id, to, by, on, in, at, ip
26
- Naming/UncommunicativeMethodParamName:
27
- Exclude:
28
- - 'spec/support/queue_with_timeout.rb'
29
-
30
30
  # Offense count: 1
31
31
  Security/Open:
32
32
  Exclude:
@@ -40,14 +40,7 @@ Style/AccessModifierDeclarations:
40
40
  - 'lib/slack/real_time/concurrency/eventmachine.rb'
41
41
  - 'lib/slack/real_time/socket.rb'
42
42
 
43
- # Offense count: 2
44
- # Cop supports --auto-correct.
45
- Style/ExpandPathArguments:
46
- Exclude:
47
- - 'bin/slack'
48
- - 'slack-ruby-client.gemspec'
49
-
50
- # Offense count: 152
43
+ # Offense count: 153
51
44
  # Configuration parameters: AllowedVariables.
52
45
  Style/GlobalVars:
53
46
  Enabled: false
@@ -64,23 +57,7 @@ Style/MixinUsage:
64
57
  Exclude:
65
58
  - 'bin/slack'
66
59
 
67
- # Offense count: 3
68
- # Cop supports --auto-correct.
69
- # Configuration parameters: EnforcedStyle.
70
- # SupportedStyles: module_function, extend_self
71
- Style/ModuleFunction:
72
- Exclude:
73
- - 'lib/slack/config.rb'
74
- - 'lib/slack/real_time/config.rb'
75
- - 'lib/slack/web/config.rb'
76
-
77
60
  # Offense count: 1
78
61
  Style/MultilineTernaryOperator:
79
62
  Exclude:
80
63
  - 'spec/support/real_time/connected_client.rb'
81
-
82
- # Offense count: 1
83
- # Cop supports --auto-correct.
84
- Style/RandomWithOffset:
85
- Exclude:
86
- - 'spec/integration/integration_spec.rb'
@@ -3,9 +3,9 @@ language: ruby
3
3
  cache: bundler
4
4
 
5
5
  rvm:
6
- - 2.2
7
- - 2.3
8
- - 2.5
6
+ - 2.3.8
7
+ - 2.5.3
8
+ - 2.6.0
9
9
  - ruby-head
10
10
  - jruby-head
11
11
 
@@ -18,7 +18,7 @@ matrix:
18
18
  env: CONCURRENCY=celluloid-io
19
19
  - rvm: 2.4.1
20
20
  env: CONCURRENCY=faye-websocket
21
- - rvm: 2.5
21
+ - rvm: 2.5.3
22
22
  env: CONCURRENCY=async-websocket
23
23
  allow_failures:
24
24
  - rvm: ruby-head
@@ -1,3 +1,13 @@
1
+ ### 0.14.0 (2019/2/25)
2
+
3
+ * [#238](https://github.com/slack-ruby/slack-ruby-client/issues/238): Added `Slack::Events::Request#verify!` to check whether an event request is coming from Slack - [@dblock](https://github.com/dblock).
4
+ * [#226](https://github.com/slack-ruby/slack-ruby-client/pull/226), [#232](https://github.com/slack-ruby/slack-ruby-client/pull/232), [#236](https://github.com/slack-ruby/slack-ruby-client/pull/236), [#234](https://github.com/slack-ruby/slack-ruby-client/pull/234): Added periodic ping that reconnects on failure - [@RodneyU215](https://github.com/RodneyU215), [@dblock](https://github.com/dblock), [@ioquatix](https://github.com/ioquatix).
5
+ * [#242](https://github.com/slack-ruby/slack-ruby-client/pull/242): Added `thread_ts` option to `chat_postEphemeral` - [@dblock](https://github.com/dblock).
6
+ * [#242](https://github.com/slack-ruby/slack-ruby-client/pull/242): Added `apps_uninstall` to Web API - [@dblock](https://github.com/dblock).
7
+ * [#244](https://github.com/slack-ruby/slack-ruby-client/pull/244): Implementing #restart for the celluloid socket class - [@RodneyU215](https://github.com/RodneyU215).
8
+ * [#246](https://github.com/slack-ruby/slack-ruby-client/pull/246): Added TOC to README and danger-toc - [@dblock](https://github.com/dblock).
9
+ * [#253](https://github.com/slack-ruby/slack-ruby-client/pull/253): Support for Block Kit - [@JrmKrb](https://github.com/JrmKrb).
10
+
1
11
  ### 0.13.1 (2018/9/30)
2
12
 
3
13
  * [#228](https://github.com/slack-ruby/slack-ruby-client/pull/228): Replace `Thread` with `Actor` in Celluloid async support - [@dblock](https://github.com/dblock).
data/Dangerfile CHANGED
@@ -1 +1,2 @@
1
1
  danger.import_dangerfile(gem: 'slack-ruby-danger')
2
+ toc.check
data/Gemfile CHANGED
@@ -4,9 +4,7 @@ gemspec
4
4
 
5
5
  gem ENV['CONCURRENCY'], require: false if ENV.key?('CONCURRENCY')
6
6
 
7
- gem 'activesupport', '~> 4.0'
8
- gem 'picky' unless RUBY_PLATFORM == 'java'
9
-
10
7
  group :test do
8
+ gem 'danger-toc', '~> 0.1.3', require: false
11
9
  gem 'slack-ruby-danger', '~> 0.1.0', require: false
12
10
  end
data/LICENSE.md CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2015-2016 Daniel Doubrovkine, Artsy and Contributors
3
+ Copyright (c) 2015-2019 Daniel Doubrovkine, Artsy and Contributors
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining
6
6
  a copy of this software and associated documentation files (the
data/README.md CHANGED
@@ -5,20 +5,68 @@ Slack Ruby Client
5
5
  [![Build Status](https://travis-ci.org/slack-ruby/slack-ruby-client.svg?branch=master)](https://travis-ci.org/slack-ruby/slack-ruby-client)
6
6
  [![Code Climate](https://codeclimate.com/github/slack-ruby/slack-ruby-client/badges/gpa.svg)](https://codeclimate.com/github/slack-ruby/slack-ruby-client)
7
7
 
8
- A Ruby client for the Slack [Web](https://api.slack.com/web) and [RealTime Messaging](https://api.slack.com/rtm) APIs. Comes with a handy command-line client, too. If you are not familiar with these concepts, you might want to watch [this video](http://code.dblock.org/2016/03/11/your-first-slack-bot-service-video.html).
8
+ A Ruby client for the Slack [Web](https://api.slack.com/web), [RealTime Messaging](https://api.slack.com/rtm) and [Events](https://api.slack.com/events-api) APIs. Comes with a handy command-line client, too. If you are not familiar with these concepts, you might want to watch [this video](http://code.dblock.org/2016/03/11/your-first-slack-bot-service-video.html).
9
9
 
10
10
  ![](slack.png)
11
11
 
12
+ ## Table of Contents
13
+
14
+ - [Useful to Me?](#useful-to-me)
15
+ - [Stable Release](#stable-release)
16
+ - [Installation](#installation)
17
+ - [Usage](#usage)
18
+ - [Create a New Bot Integration](#create-a-new-bot-integration)
19
+ - [Use the API Token](#use-the-api-token)
20
+ - [Global Settings](#global-settings)
21
+ - [Web Client](#web-client)
22
+ - [Test Auth](#test-auth)
23
+ - [Send Messages](#send-messages)
24
+ - [List Channels](#list-channels)
25
+ - [Upload a File](#upload-a-file)
26
+ - [Get Channel Info](#get-channel-info)
27
+ - [Get User Info](#get-user-info)
28
+ - [Search for a User](#search-for-a-user)
29
+ - [Other](#other)
30
+ - [Web Client Options](#web-client-options)
31
+ - [Pagination Support](#pagination-support)
32
+ - [Error Handling](#error-handling)
33
+ - [RealTime Client](#realtime-client)
34
+ - [Slack::RealTime::Stores::Store](#slackrealtimestoresstore)
35
+ - [Slack::RealTime::Stores::Starter](#slackrealtimestoresstarter)
36
+ - [Configuring Slack::RealTime::Client](#configuring-slackrealtimeclient)
37
+ - [Caveats](#caveats)
38
+ - [websocket_ping](#websocket_ping)
39
+ - [Connection Methods](#connection-methods)
40
+ - [Combining RealTime and Web Clients](#combining-realtime-and-web-clients)
41
+ - [Large Team Considerations](#large-team-considerations)
42
+ - [Concurrency](#concurrency)
43
+ - [Async](#async)
44
+ - [Faye::Websocket with Eventmachine](#fayewebsocket-with-eventmachine)
45
+ - [Celluloid](#celluloid)
46
+ - [Events API](#events-api)
47
+ - [Configuring Slack::Events](#configuring-slackevents)
48
+ - [Verifying the Request Signature](#verifying-the-request-signature)
49
+ - [Message Parsing](#message-parsing)
50
+ - [Command-Line Client](#command-line-client)
51
+ - [Authenticate with Slack](#authenticate-with-slack)
52
+ - [Send a Message](#send-a-message)
53
+ - [Get Channel Id](#get-channel-id)
54
+ - [Get Channel Info](#get-channel-info-1)
55
+ - [List Users](#list-users)
56
+ - [History](#history)
57
+ - [Contributing](#contributing)
58
+ - [Copyright and License](#copyright-and-license)
59
+
12
60
  ## Useful to Me?
13
61
 
14
- * This piece of the puzzle will help you send messages to Slack via the Web API and send and receive messages via the Real Time API.
15
- * If you're trying to respond to slash commands, just write a basic web application and use this library to call the Slack Web API.
16
- * If you're trying to build a Real Time bot, use [slack-ruby-bot](https://github.com/dblock/slack-ruby-bot), which uses this library.
17
- * If you're trying to roll out a full service with Slack button integration to multiple teams, check out [slack-ruby-bot-server](https://github.com/dblock/slack-ruby-bot-server), which is built on top of slack-ruby-bot, which uses this library.
62
+ * This library will let you send messages to Slack via the Web API, send and receive messages via the Real Time Messaging API and facilitate integration with the Events API.
63
+ * To respond to slash commands, interactive components or events, implement a web application using your favorite web framework and use this library to call the Slack Web API and to verify that events are coming from Slack.
64
+ * To build a bot using the Real Time Messaging API, use [slack-ruby-bot](https://github.com/dblock/slack-ruby-bot), which uses this library.
65
+ * To roll out a complete service using the Real Time Messaging API with Slack button integration to multiple teams, check out [slack-ruby-bot-server](https://github.com/dblock/slack-ruby-bot-server), which is built on top of slack-ruby-bot, which uses this library.
18
66
 
19
67
  ## Stable Release
20
68
 
21
- You're reading the documentation for the **stable** release of slack-ruby-client, 0.13.1. See [UPGRADING](UPGRADING.md) when upgrading from an older version.
69
+ You're reading the documentation for the **stable** release of slack-ruby-client, v0.14.0. See [UPGRADING](UPGRADING.md) when upgrading from an older version.
22
70
 
23
71
  ## Installation
24
72
 
@@ -235,9 +283,9 @@ end
235
283
  client.on :message do |data|
236
284
  case data.text
237
285
  when 'bot hi' then
238
- client.message channel: data.channel, text: "Hi <@#{data.user}>!"
286
+ client.message(channel: data.channel, text: "Hi <@#{data.user}>!")
239
287
  when /^bot/ then
240
- client.message channel: data.channel, text: "Sorry <@#{data.user}>, what?"
288
+ client.message(channel: data.channel, text: "Sorry <@#{data.user}>, what?")
241
289
  end
242
290
  end
243
291
 
@@ -308,7 +356,7 @@ The following settings are supported.
308
356
  setting | description
309
357
  ----------------|-----------------------------------------------------------------------------------------------------
310
358
  token | Slack API token.
311
- websocket_ping | The number of seconds that indicates how often the WebSocket should send ping frames, default is 30.
359
+ websocket_ping | How long the socket can be idle before sending a ping message to confirm it's still connected, default is 30.
312
360
  websocket_proxy | Connect via proxy, include `:origin` and `:headers`.
313
361
  store_class | Local store class name, default is an in-memory `Slack::RealTime::Stores::Store`.
314
362
  start_method | Optional start method, either `:rtm_start` or `:rtm_connect`.
@@ -321,6 +369,15 @@ See a fully working example in [examples/hi_real_time](examples/hi_real_time/hi.
321
369
 
322
370
  ![](examples/hi_real_time/hi.gif)
323
371
 
372
+ #### Caveats
373
+
374
+ ##### `websocket_ping`
375
+ This setting determines how long the socket can be idle before sending a ping message to confirm it's still connected.
376
+
377
+ It's important to note that if a ping message was sent and no response was received within the amount of time specified in `websocket_ping`; the client will attempt to reestablish it's connection to the message server.
378
+
379
+ To disable this feature; set `websocket_ping` to 0.
380
+
324
381
  ### Connection Methods
325
382
 
326
383
  The RealTime client uses either [rtm.start](https://api.slack.com/methods/rtm.start) or [rtm.connect](https://api.slack.com/methods/rtm.connect) to open a connection. The former retrieves a lot of team information while the latter only serves connection purposes and is preferred. You should let the library choose the right method for you based on the `store_class` used and override this behavior with `start_method` when necessary.
@@ -341,9 +398,9 @@ client = Slack::RealTime::Client.new
341
398
  client.on :message do |data|
342
399
  case data.text
343
400
  when 'bot hi' then
344
- client.web_client.chat_postMessage channel: data.channel, text: "Hi <@#{data.user}>!"
401
+ client.web_client.chat_postMessage(channel: data.channel, text: "Hi <@#{data.user}>!")
345
402
  when /^bot/ then
346
- client.web_client.chat_postMessage channel: data.channel, text: "Sorry <@#{data.user}>, what?"
403
+ client.web_client.chat_postMessage(channel: data.channel, text: "Sorry <@#{data.user}>, what?")
347
404
  end
348
405
  end
349
406
 
@@ -419,7 +476,37 @@ gem 'celluloid-io', require: ['celluloid/current', 'celluloid/io']
419
476
 
420
477
  See a fully working example in [examples/hi_real_time_async_celluloid](examples/hi_real_time_async_celluloid/hi.rb).
421
478
 
422
- Require
479
+ ### Events API
480
+
481
+ This library provides limited support for the [Slack Events API](https://api.slack.com/events-api).
482
+
483
+ #### Configuring Slack::Events
484
+
485
+ You can configure Events support globally.
486
+
487
+ ```ruby
488
+ Slack::Events.configure do |config|
489
+ config.signing_secret = 'secret'
490
+ end
491
+ ```
492
+
493
+ The following settings are supported.
494
+
495
+ setting | description
496
+ ----------------------|---------------------------------------------------------------------------------------------------
497
+ signing_secret | Slack signing secret, defaults is `ENV['SLACK_SIGNING_SECRET']`.
498
+ signature_expires_in | Signature expiration window in seconds, default is `300`.
499
+
500
+ #### Verifying the Request Signature
501
+
502
+ Slack signs its requests using a secret that's unique to your app. Verify incoming HTTP requests as follows.
503
+
504
+ ```ruby
505
+ slack_request = Slack::Events::Request.new(http_request)
506
+ slack_request.verify!
507
+ ```
508
+
509
+ The `verify!` call may raise `Slack::Events::MissingSigningSecret`, `Slack::Events::InvalidSignature` or `Slack::Events::TimestampExpired` errors.
423
510
 
424
511
  ### Message Parsing
425
512
 
@@ -509,6 +596,6 @@ See [CONTRIBUTING](CONTRIBUTING.md).
509
596
 
510
597
  ## Copyright and License
511
598
 
512
- Copyright (c) 2015-2016, [Daniel Doubrovkine](https://twitter.com/dblockdotorg), [Artsy](https://www.artsy.net) and [Contributors](CHANGELOG.md).
599
+ Copyright (c) 2015-2019, [Daniel Doubrovkine](https://twitter.com/dblockdotorg), [Artsy](https://www.artsy.net) and [Contributors](CHANGELOG.md).
513
600
 
514
601
  This project is licensed under the [MIT License](LICENSE.md).
@@ -1,6 +1,7 @@
1
1
  # This file was auto-generated by lib/tasks/web.rake
2
2
 
3
3
  require 'commands/api'
4
+ require 'commands/apps'
4
5
  require 'commands/apps_permissions'
5
6
  require 'commands/apps_permissions_resources'
6
7
  require 'commands/apps_permissions_scopes'
@@ -0,0 +1,14 @@
1
+ # This file was auto-generated by lib/tasks/web.rake
2
+
3
+ desc 'Apps methods.'
4
+ command 'apps' do |g|
5
+ g.desc 'Uninstalls your app from a workspace.'
6
+ g.long_desc %( Uninstalls your app from a workspace. )
7
+ g.command 'uninstall' do |c|
8
+ c.flag 'client_id', desc: 'Issued when you created your application.'
9
+ c.flag 'client_secret', desc: 'Issued when you created your application.'
10
+ c.action do |_global_options, options, _args|
11
+ puts JSON.dump($client.apps_uninstall(options))
12
+ end
13
+ end
14
+ end
@@ -50,10 +50,12 @@ command 'chat' do |g|
50
50
  c.flag 'channel', desc: 'Channel, private group, or IM channel to send message to. Can be an encoded ID, or a name.'
51
51
  c.flag 'text', desc: "Text of the message to send. See below for an explanation of formatting. This field is usually required, unless you're providing only attachments instead."
52
52
  c.flag 'user', desc: 'id of the user who will receive the ephemeral message. The user should be in the channel specified by the channel argument.'
53
- c.flag 'as_user', desc: 'Pass true to post the message as the authed bot. Defaults to false.'
53
+ c.flag 'as_user', desc: 'Pass true to post the message as the authed user. Defaults to true if the chat:write:bot scope is not included. Otherwise, defaults to false.'
54
54
  c.flag 'attachments', desc: 'A JSON-based array of structured attachments, presented as a URL-encoded string.'
55
+ c.flag 'blocks', desc: 'A JSON-based array of structured blocks, presented as a URL-encoded string.'
55
56
  c.flag 'link_names', desc: 'Find and link channel names and usernames.'
56
57
  c.flag 'parse', desc: 'Change how messages are treated. Defaults to none. See below.'
58
+ c.flag 'thread_ts', desc: "Provide another message's ts value to make this message a reply. Avoid using a reply's ts value; use its parent instead."
57
59
  c.action do |_global_options, options, _args|
58
60
  puts JSON.dump($client.chat_postEphemeral(options))
59
61
  end
@@ -66,6 +68,7 @@ command 'chat' do |g|
66
68
  c.flag 'text', desc: "Text of the message to send. See below for an explanation of formatting. This field is usually required, unless you're providing only attachments instead. Provide no more than 40,000 characters or risk truncation."
67
69
  c.flag 'as_user', desc: 'Pass true to post the message as the authed user, instead of as a bot. Defaults to false. See authorship below.'
68
70
  c.flag 'attachments', desc: 'A JSON-based array of structured attachments, presented as a URL-encoded string.'
71
+ c.flag 'blocks', desc: 'A JSON-based array of structured blocks, presented as a URL-encoded string.'
69
72
  c.flag 'icon_emoji', desc: 'Emoji to use as the icon for this message. Overrides icon_url. Must be used in conjunction with as_user set to false, otherwise ignored. See authorship below.'
70
73
  c.flag 'icon_url', desc: 'URL to an image to use as the icon for this message. Must be used in conjunction with as_user set to false, otherwise ignored. See authorship below.'
71
74
  c.flag 'link_names', desc: 'Find and link channel names and usernames.'
@@ -103,6 +106,7 @@ command 'chat' do |g|
103
106
  c.flag 'ts', desc: 'Timestamp of the message to be updated.'
104
107
  c.flag 'as_user', desc: 'Pass true to update the message as the authed user. Bot users in this context are considered authed users.'
105
108
  c.flag 'attachments', desc: 'A JSON-based array of structured attachments, presented as a URL-encoded string. This field is required when not presenting text.'
109
+ c.flag 'blocks', desc: 'A JSON-based array of structured blocks, presented as a URL-encoded string.'
106
110
  c.flag 'link_names', desc: 'Find and link channel names and usernames. Defaults to none. See below.'
107
111
  c.flag 'parse', desc: 'Change how messages are treated. Defaults to client, unlike chat.postMessage. See below.'
108
112
  c.action do |_global_options, options, _args|
@@ -50,6 +50,7 @@ command 'conversations' do |g|
50
50
  g.command 'info' do |c|
51
51
  c.flag 'channel', desc: 'Conversation ID to learn more about.'
52
52
  c.flag 'include_locale', desc: 'Set this to true to receive the locale for this conversation. Defaults to false.'
53
+ c.flag 'include_num_members', desc: 'Set to true to include the member count for the specified conversation. Defaults to false.'
53
54
  c.action do |_global_options, options, _args|
54
55
  puts JSON.dump($client.conversations_info(options))
55
56
  end
@@ -40,17 +40,16 @@ command 'files' do |g|
40
40
  c.flag 'ts_from', desc: 'Filter files created after this timestamp (inclusive).'
41
41
  c.flag 'ts_to', desc: 'Filter files created before this timestamp (inclusive).'
42
42
  c.flag 'types', desc: 'Filter files by type:
43
+ * `all` - All files
44
+ * `spaces` - Posts
45
+ * `snippets` - Snippets
46
+ * `images` - Image files
47
+ * `gdocs` - Google docs
48
+ * `zips` - Zip files
49
+ * `pdfs` - PDF files
43
50
 
44
- all - All files
45
- spaces - Posts
46
- snippets - Snippets
47
- images - Image files
48
- gdocs - Google docs
49
- zips - Zip files
50
- pdfs - PDF files
51
+ You can pass multiple values in the types argument, like `types=spaces,snippets`.The default value is `all`, which does not filter the list.
51
52
 
52
-
53
- You can pass multiple values in the types argument, like types=spaces,snippets.The default value is all, which does not filter the list.
54
53
  .'
55
54
  c.flag 'user', desc: 'Filter files created by a single user.'
56
55
  c.action do |_global_options, options, _args|
@@ -7,8 +7,8 @@ command 'reactions' do |g|
7
7
  g.command 'add' do |c|
8
8
  c.flag 'name', desc: 'Reaction (emoji) name.'
9
9
  c.flag 'channel', desc: 'Channel where the message to add reaction to was posted.'
10
- c.flag 'file', desc: 'File to add reaction to.'
11
- c.flag 'file_comment', desc: 'File comment to add reaction to.'
10
+ c.flag 'file', desc: "File to add reaction to. Now that file threads work the way you'd expect, this argument is deprecated. Specify the timestamp and channel of the message associated with a file instead."
11
+ c.flag 'file_comment', desc: "File comment to add reaction to. Now that file threads work the way you'd expect, this argument is deprecated. Specify the timestamp and channel of the message associated with a file instead."
12
12
  c.flag 'timestamp', desc: 'Timestamp of the message to add reaction to.'
13
13
  c.action do |_global_options, options, _args|
14
14
  puts JSON.dump($client.reactions_add(options))
data/bin/slack CHANGED
@@ -46,7 +46,7 @@ pre do |global_options, _command, options, _args|
46
46
  true
47
47
  end
48
48
 
49
- $LOAD_PATH.push File.expand_path('..', __FILE__)
49
+ $LOAD_PATH.push File.expand_path(__dir__)
50
50
  require 'commands'
51
51
 
52
52
  exit run(ARGV)
@@ -47,3 +47,7 @@ require_relative 'slack/real_time/models'
47
47
  require_relative 'slack/real_time/stores'
48
48
  require_relative 'slack/real_time/config'
49
49
  require_relative 'slack/real_time/client'
50
+
51
+ # Events API
52
+ require_relative 'slack/events/config'
53
+ require_relative 'slack/events/request'
@@ -0,0 +1,31 @@
1
+ module Slack
2
+ module Events
3
+ module Config
4
+ extend self
5
+
6
+ ATTRIBUTES = %i[
7
+ signing_secret
8
+ signature_expires_in
9
+ ].freeze
10
+
11
+ attr_accessor(*Config::ATTRIBUTES)
12
+
13
+ def reset
14
+ self.signing_secret = ENV['SLACK_SIGNING_SECRET']
15
+ self.signature_expires_in = 5 * 60
16
+ end
17
+ end
18
+
19
+ class << self
20
+ def configure
21
+ block_given? ? yield(Config) : Config
22
+ end
23
+
24
+ def config
25
+ Config
26
+ end
27
+ end
28
+ end
29
+ end
30
+
31
+ Slack::Events::Config.reset