Skip to content

Commit 951f230

Browse files
committed
Fixed help, markdown too long.
1 parent dd29845 commit 951f230

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

.rubocop_todo.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# This configuration was generated by
22
# `rubocop --auto-gen-config`
3-
# on 2025-10-01 12:40:26 UTC using RuboCop version 1.81.1.
3+
# on 2025-10-01 13:11:17 UTC using RuboCop version 1.81.1.
44
# The point is for the user to remove these configuration records
55
# one by one as the offenses are removed from the code base.
66
# Note that changes in the inspected code, or installation of new

slack-api-explorer/commands/help.rb

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,25 @@ def self.help_for(expression = nil)
66
@help[expression] ||= '```' + `slack help #{expression}`.gsub(/^( )/, '') + '```'
77
end
88

9+
def self.commands
10+
@commands ||= begin
11+
commands = `slack help`.gsub(/.*?(COMMANDS)/m, '').gsub(/^( )/, '')
12+
13+
all = {}
14+
commands.split("\n").each { |command|
15+
next if command.strip.blank?
16+
17+
parts = command.split(/[\_\s]/, 2)
18+
all[parts[0]] ||= []
19+
all[parts[0]] << parts[1]
20+
}
21+
22+
all.keys.map do |group|
23+
"#{group}#{all[group].first}"
24+
end
25+
end
26+
end
27+
928
HELP = <<~EOS.freeze
1029
I am your friendly Api Explorer, here to help.
1130
@@ -17,12 +36,12 @@ def self.help_for(expression = nil)
1736
1837
Commands
1938
--------
20-
#{`slack help`.gsub(/.*?(COMMANDS)/m, '').gsub(/^( )/, '')}
39+
#{commands.join("\n")}
2140
2241
Not sure where to start? Try "auth test", then invite the bot to #general and DM it "chat postMessage --as_user=true --text='Hello World' --channel=#general".
2342
2443
Most commands contain subcommands, try "help <command>" (eg. "help api") to get a list of subcommands.
25-
```\n
44+
```
2645
EOS
2746

2847
def self.call(client, data, match)

0 commit comments

Comments
 (0)