slack_line 1.2 → 1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/rspec.yml +1 -1
- data/CHANGELOG.md +12 -0
- data/LICENSE +20 -0
- data/README.md +27 -21
- data/lib/slack_line/client.rb +2 -2
- data/lib/slack_line/message.rb +6 -3
- data/lib/slack_line/thread.rb +6 -2
- data/lib/slack_line/version.rb +1 -1
- data/slack_line.gemspec +1 -0
- metadata +17 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: '091877d65cd3c6b2c21d869608359fbc6c9774f663399eb01b2fec9afc098da3'
|
|
4
|
+
data.tar.gz: 848360f12adbca1f5108764f450f448deac06a4fd61efcc8b994e3a00d166128
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b1b2ea474330ad8a53da29f5c74e271bfe17392c578dc8f7e2829767e52d4a7952dfb7929a76571236b83b336e7d254a735d9a7b49302ad9c0192f67b4fced92
|
|
7
|
+
data.tar.gz: 2ab43cc4c5c4e02236cadbcaceac55146d9fc118246224494e9210b7e1e7eb21f0cbb04ffc2e8d5af901a0cd2e563ce721ca748e574ab1ac3226add51e4ee80a
|
data/.github/workflows/rspec.yml
CHANGED
data/CHANGELOG.md
CHANGED
|
@@ -9,3 +9,15 @@ can do each of those things directly (for simpler messages).
|
|
|
9
9
|
## Version 1.1
|
|
10
10
|
|
|
11
11
|
Fixed incorrect description/summary on gemspec.
|
|
12
|
+
|
|
13
|
+
## Version 1.2
|
|
14
|
+
|
|
15
|
+
Added disk-caching for the users and groups lists, through the `cache_path` and
|
|
16
|
+
`cache_duration` config options and matching CLI flags. Added the
|
|
17
|
+
`slack_line_stateful_thread` script, and `content` and `update` on `SentThread`.
|
|
18
|
+
|
|
19
|
+
## Version 1.3
|
|
20
|
+
|
|
21
|
+
`message` and `thread` now accept `to:`, as the README showed. Declared `reline`
|
|
22
|
+
as a runtime dependency, which fixes a warning or `LoadError` under Bundler on
|
|
23
|
+
Ruby 4.0. The invalid content error now lists the classes of the bad arguments.
|
data/LICENSE
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
Copyright 2026 Eric Mueller
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
4
|
+
a copy of this software and associated documentation files (the
|
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
9
|
+
the following conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice shall be
|
|
12
|
+
included in all copies or substantial portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
CHANGED
|
@@ -82,7 +82,8 @@ be set via ENV or `SlackLine.configure`:
|
|
|
82
82
|
is posted, and after each non-thread message is posted.
|
|
83
83
|
* `cache_path` or `SLACK_LINE_CACHE_PATH` - a directory path for
|
|
84
84
|
disk-caching the users and groups lists fetched from the Slack API.
|
|
85
|
-
When set, SlackLine will use the
|
|
85
|
+
When set, SlackLine will use the
|
|
86
|
+
[lightly](https://github.com/DannyBen/lightly)
|
|
86
87
|
gem to cache results to disk, which avoids redundant API calls across
|
|
87
88
|
separate runs. Requires `lightly` to be installed as an optional
|
|
88
89
|
dependency - if it is not available, a `DiskCaching::NoLightly` error
|
|
@@ -138,11 +139,11 @@ BAR_SLACK.message("Message 3", to: "#bar-team-3").post
|
|
|
138
139
|
|
|
139
140
|
## CLI Scripts
|
|
140
141
|
|
|
141
|
-
The gem ships with three executable scripts for sending and managing Slack
|
|
142
|
-
from the command line. All three accept `-t`/`--slack-token TOKEN` and
|
|
142
|
+
The gem ships with three executable scripts for sending and managing Slack
|
|
143
|
+
messages from the command line. All three accept `-t`/`--slack-token TOKEN` and
|
|
143
144
|
`-n`/`--bot-name NAME` to override the corresponding environment variables.
|
|
144
|
-
Configuration can also come from `SLACK_LINE_SLACK_TOKEN` and friends as
|
|
145
|
-
above.
|
|
145
|
+
Configuration can also come from `SLACK_LINE_SLACK_TOKEN` and friends as
|
|
146
|
+
described above.
|
|
146
147
|
|
|
147
148
|
### `slack_line_message`
|
|
148
149
|
|
|
@@ -177,7 +178,8 @@ Options:
|
|
|
177
178
|
required with `--update` on a thread)
|
|
178
179
|
* `-s`/`--save PATH` - write the sent/updated result to PATH as JSON
|
|
179
180
|
* `-u`/`--look-up-users` - resolve `@mentions` via the Slack API
|
|
180
|
-
* `--cache-path PATH` / `--cache-duration DURATION` - disk-cache user/group
|
|
181
|
+
* `--cache-path PATH` / `--cache-duration DURATION` - disk-cache user/group
|
|
182
|
+
lookups
|
|
181
183
|
* `--no-backoff` - disable per-message sleep delays
|
|
182
184
|
|
|
183
185
|
When no content arguments are given and no DSL is piped, the script reads DSL
|
|
@@ -224,8 +226,9 @@ and appends replies along the way. The sent message is persisted to a file;
|
|
|
224
226
|
subsequent invocations load and re-persist that file to know which Slack message
|
|
225
227
|
to update.
|
|
226
228
|
|
|
227
|
-
Messages are formatted as `[STATE] body`. The `--state` and `--message` flags
|
|
228
|
-
update their respective part independently; omitting one leaves it
|
|
229
|
+
Messages are formatted as `[STATE] body`. The `--state` and `--message` flags
|
|
230
|
+
each update their respective part independently; omitting one leaves it
|
|
231
|
+
unchanged on update.
|
|
229
232
|
|
|
230
233
|
```sh
|
|
231
234
|
# Initial post - creates /tmp/deploy.json and posts "[running] Deploy started"
|
|
@@ -247,14 +250,16 @@ slack_line_stateful_thread --path /tmp/deploy.json --thread --message "Step 1 co
|
|
|
247
250
|
|
|
248
251
|
Options:
|
|
249
252
|
|
|
250
|
-
* `--path PATH` - (required) file path used to persist the sent message between
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
* `-
|
|
255
|
-
|
|
256
|
-
*
|
|
257
|
-
|
|
253
|
+
* `--path PATH` - (required) file path used to persist the sent message between
|
|
254
|
+
invocations
|
|
255
|
+
* `-p`/`--post-to TARGET` - channel or user; required on the first call,
|
|
256
|
+
forbidden thereafter
|
|
257
|
+
* `-s`/`--state STATE` - the state label shown in brackets; required on first
|
|
258
|
+
call
|
|
259
|
+
* `-m`/`--message MESSAGE` - the message body; required on first call and when
|
|
260
|
+
using `--thread`
|
|
261
|
+
* `--thread` - append a reply instead of updating the main message (mutually
|
|
262
|
+
exclusive with `--state`)
|
|
258
263
|
|
|
259
264
|
## Slack App Permissions
|
|
260
265
|
|
|
@@ -262,9 +267,10 @@ In order to post/update messages, the app behind your `SLACK_LINE_TOKEN` can use
|
|
|
262
267
|
these permissions:
|
|
263
268
|
|
|
264
269
|
* `chat:write` - send messages at all.
|
|
265
|
-
* `chat:write.public` - send messages to public channels your app _isn't a
|
|
266
|
-
of_ (so you don't need to invite them to the relevant channels to make
|
|
270
|
+
* `chat:write.public` - send messages to public channels your app _isn't a
|
|
271
|
+
member of_ (so you don't need to invite them to the relevant channels to make
|
|
272
|
+
them work).
|
|
267
273
|
* `im:write` - start direct messages with individuals.
|
|
268
|
-
* `users:read` and `usergroups:read` - look up users/groups for (a) messaging
|
|
269
|
-
directly or (b) supporting the `look_up_users` config option (for those
|
|
270
|
-
restrictive workspaces)
|
|
274
|
+
* `users:read` and `usergroups:read` - look up users/groups for (a) messaging
|
|
275
|
+
them directly or (b) supporting the `look_up_users` config option (for those
|
|
276
|
+
more restrictive workspaces)
|
data/lib/slack_line/client.rb
CHANGED
|
@@ -12,9 +12,9 @@ module SlackLine
|
|
|
12
12
|
|
|
13
13
|
memoize def slack_client = Slack::Web::Client.new(token: configuration.slack_token)
|
|
14
14
|
|
|
15
|
-
def message(*text_or_blocks, &dsl_block) = Message.new(*text_or_blocks, client: self, &dsl_block)
|
|
15
|
+
def message(*text_or_blocks, to: nil, &dsl_block) = Message.new(*text_or_blocks, client: self, to:, &dsl_block)
|
|
16
16
|
|
|
17
|
-
def thread(*messages, &dsl_block) = Thread.new(*messages, client: self, &dsl_block)
|
|
17
|
+
def thread(*messages, to: nil, &dsl_block) = Thread.new(*messages, client: self, to:, &dsl_block)
|
|
18
18
|
|
|
19
19
|
memoize def users = Users.new(client: self)
|
|
20
20
|
|
data/lib/slack_line/message.rb
CHANGED
|
@@ -3,14 +3,17 @@ module SlackLine
|
|
|
3
3
|
extend Forwardable
|
|
4
4
|
include Memoization
|
|
5
5
|
|
|
6
|
-
def initialize(*text_or_blocks, client:, &dsl_block)
|
|
6
|
+
def initialize(*text_or_blocks, client:, to: nil, &dsl_block)
|
|
7
7
|
@text_or_blocks = text_or_blocks
|
|
8
8
|
@dsl_block = dsl_block
|
|
9
9
|
@client = client
|
|
10
|
+
@to = to
|
|
10
11
|
|
|
11
12
|
validate!
|
|
12
13
|
end
|
|
13
14
|
|
|
15
|
+
attr_reader :to
|
|
16
|
+
|
|
14
17
|
memoize def content
|
|
15
18
|
if @dsl_block
|
|
16
19
|
MessageContext.new(&@dsl_block).content
|
|
@@ -30,7 +33,7 @@ module SlackLine
|
|
|
30
33
|
"https://app.slack.com/block-kit-builder##{escaped_json}"
|
|
31
34
|
end
|
|
32
35
|
|
|
33
|
-
def post(to: nil, thread_ts: nil) = MessageSender.new(message: self, client:, to
|
|
36
|
+
def post(to: nil, thread_ts: nil) = MessageSender.new(message: self, client:, to: to || self.to, thread_ts:).post
|
|
34
37
|
|
|
35
38
|
private
|
|
36
39
|
|
|
@@ -49,7 +52,7 @@ module SlackLine
|
|
|
49
52
|
|
|
50
53
|
def validate_type!
|
|
51
54
|
unless @text_or_blocks.empty? || blocks?(@text_or_blocks) || strings?(@text_or_blocks)
|
|
52
|
-
raise(ArgumentError, "Invalid content type: #{@text_or_blocks.class}")
|
|
55
|
+
raise(ArgumentError, "Invalid content type: #{@text_or_blocks.map(&:class).uniq.join(", ")}")
|
|
53
56
|
end
|
|
54
57
|
end
|
|
55
58
|
|
data/lib/slack_line/thread.rb
CHANGED
|
@@ -4,14 +4,17 @@ module SlackLine
|
|
|
4
4
|
include Enumerable
|
|
5
5
|
include Memoization
|
|
6
6
|
|
|
7
|
-
def initialize(*supplied_messages, client:, &dsl_block)
|
|
7
|
+
def initialize(*supplied_messages, client:, to: nil, &dsl_block)
|
|
8
8
|
@supplied_messages = supplied_messages
|
|
9
9
|
@dsl_block = dsl_block
|
|
10
10
|
@client = client
|
|
11
|
+
@to = to
|
|
11
12
|
|
|
12
13
|
validate!
|
|
13
14
|
end
|
|
14
15
|
|
|
16
|
+
attr_reader :to
|
|
17
|
+
|
|
15
18
|
# an Array of SlackLine::Messages
|
|
16
19
|
memoize def messages = message_contents.map { |mc| convert_supplied_message(mc) }
|
|
17
20
|
|
|
@@ -20,11 +23,12 @@ module SlackLine
|
|
|
20
23
|
memoize def builder_urls = messages.map(&:builder_url)
|
|
21
24
|
|
|
22
25
|
def post(to: nil)
|
|
26
|
+
target = to || self.to || messages.filter_map(&:to).first
|
|
23
27
|
sent_messages = []
|
|
24
28
|
thread_ts = nil
|
|
25
29
|
|
|
26
30
|
messages.each do |message|
|
|
27
|
-
sent = message.post(to
|
|
31
|
+
sent = message.post(to: target, thread_ts:)
|
|
28
32
|
thread_ts ||= sent.ts
|
|
29
33
|
sent_messages << sent
|
|
30
34
|
end
|
data/lib/slack_line/version.rb
CHANGED
data/slack_line.gemspec
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: slack_line
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: '1.
|
|
4
|
+
version: '1.3'
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Eric Mueller
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-
|
|
11
|
+
date: 2026-11-04 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rspec
|
|
@@ -164,6 +164,20 @@ dependencies:
|
|
|
164
164
|
- - "~>"
|
|
165
165
|
- !ruby/object:Gem::Version
|
|
166
166
|
version: 3.1.0
|
|
167
|
+
- !ruby/object:Gem::Dependency
|
|
168
|
+
name: reline
|
|
169
|
+
requirement: !ruby/object:Gem::Requirement
|
|
170
|
+
requirements:
|
|
171
|
+
- - ">="
|
|
172
|
+
- !ruby/object:Gem::Version
|
|
173
|
+
version: '0.6'
|
|
174
|
+
type: :runtime
|
|
175
|
+
prerelease: false
|
|
176
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
177
|
+
requirements:
|
|
178
|
+
- - ">="
|
|
179
|
+
- !ruby/object:Gem::Version
|
|
180
|
+
version: '0.6'
|
|
167
181
|
description: |
|
|
168
182
|
Sending messages with the Slack API is not that difficult, but I've had
|
|
169
183
|
to solve the same problems a lot of times at different companies. This
|
|
@@ -189,6 +203,7 @@ files:
|
|
|
189
203
|
- ".standard.yml"
|
|
190
204
|
- CHANGELOG.md
|
|
191
205
|
- Gemfile
|
|
206
|
+
- LICENSE
|
|
192
207
|
- README.md
|
|
193
208
|
- bin/slack_line_message
|
|
194
209
|
- bin/slack_line_stateful_thread
|