slack-smart-bot 0.9.1 → 0.9.2
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/README.md +2 -6
- data/lib/slack-smart-bot.rb +29 -5
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0fb10a8fe5df1e452fe4c7b5f7e6d6d19b1d29ee099be6355f00d8187e89b4b5
|
4
|
+
data.tar.gz: d8ef2dfd73a0e88d33ab9e6e1b91bddce71652f932548e173db8e22ebced8c40
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5cace61782d44a6433c0977715f72bcf465eaaf108b806716386105f0398ace5c3bf9777883beebd1b4a1386a690406255219ed5366d054f48c1de43e77bca76
|
7
|
+
data.tar.gz: 72b4f83907854cafc513ddfae26cd1f7ad81a4e47f3c602979d3326ac7128d32e3a3b974dc008ec9d6f8de63605a6bc809df6c1111af68f9a3913389a326de8d
|
data/README.md
CHANGED
@@ -29,12 +29,8 @@ settings = {
|
|
29
29
|
token: 'xxxxxxxxxxxxxxxxxx' # the API Slack token
|
30
30
|
}
|
31
31
|
|
32
|
-
|
33
|
-
|
34
|
-
SlackSmartBot.new(settings).listen
|
35
|
-
rescue Exception => e
|
36
|
-
puts "Rescued: #{e.inspect}"
|
37
|
-
end
|
32
|
+
puts "Connecting #{settings.inspect}"
|
33
|
+
SlackSmartBot.new(settings).listen
|
38
34
|
|
39
35
|
```
|
40
36
|
|
data/lib/slack-smart-bot.rb
CHANGED
@@ -171,7 +171,12 @@ class SlackSmartBot
|
|
171
171
|
end
|
172
172
|
|
173
173
|
def get_channels_name_and_id
|
174
|
-
channels
|
174
|
+
#todo: add pagination for case more than 1000 channels on the workspace
|
175
|
+
channels = client.web_client.conversations_list(
|
176
|
+
types: 'private_channel,public_channel',
|
177
|
+
limit: '1000',
|
178
|
+
exclude_archived: 'true').channels
|
179
|
+
|
175
180
|
@channels_id = Hash.new()
|
176
181
|
@channels_name = Hash.new()
|
177
182
|
channels.each do |ch|
|
@@ -272,7 +277,11 @@ class SlackSmartBot
|
|
272
277
|
if typem == :on_call
|
273
278
|
command = "!" + command unless command[0] == "!" or command.match?(/^\s*$/)
|
274
279
|
|
275
|
-
channels
|
280
|
+
#todo: add pagination for case more than 1000 channels on the workspace
|
281
|
+
channels = client.web_client.conversations_list(
|
282
|
+
types: 'private_channel,public_channel',
|
283
|
+
limit: '1000',
|
284
|
+
exclude_archived: 'true').channels
|
276
285
|
channel_found = channels.detect { |c| c.name == channel_rules_name }
|
277
286
|
members = client.web_client.conversations_members(channel: @channels_id[channel_rules_name]).members unless channel_found.nil?
|
278
287
|
if channel_found.nil?
|
@@ -598,7 +607,12 @@ class SlackSmartBot
|
|
598
607
|
#help:
|
599
608
|
when /^use rules (from\s+)<#C\w+\|(.+)>/i, /^use rules (from\s+)(.+)/i
|
600
609
|
channel = $2
|
601
|
-
channels
|
610
|
+
#todo: add pagination for case more than 1000 channels on the workspace
|
611
|
+
channels = client.web_client.conversations_list(
|
612
|
+
types: 'private_channel,public_channel',
|
613
|
+
limit: '1000',
|
614
|
+
exclude_archived: 'true').channels
|
615
|
+
|
602
616
|
channel_found = channels.detect { |c| c.name == channel }
|
603
617
|
members = client.web_client.conversations_members(channel: @channels_id[channel]).members unless channel_found.nil?
|
604
618
|
|
@@ -826,7 +840,12 @@ class SlackSmartBot
|
|
826
840
|
elsif @channels_id.key?(channel) #it is a channel name
|
827
841
|
channel_id = @channels_id[channel]
|
828
842
|
end
|
829
|
-
channels
|
843
|
+
#todo: add pagination for case more than 1000 channels on the workspace
|
844
|
+
channels = client.web_client.conversations_list(
|
845
|
+
types: 'private_channel,public_channel',
|
846
|
+
limit: '1000',
|
847
|
+
exclude_archived: 'true').channels
|
848
|
+
@logger.info channels.inspect
|
830
849
|
channel_found = channels.detect { |c| c.name == channel }
|
831
850
|
members = client.web_client.conversations_members(channel: @channels_id[channel]).members unless channel_found.nil?
|
832
851
|
|
@@ -1004,7 +1023,12 @@ class SlackSmartBot
|
|
1004
1023
|
respond "Only admins can extend the rules. Admins on this channel: #{ADMIN_USERS}", dest
|
1005
1024
|
else
|
1006
1025
|
channel = $2
|
1007
|
-
channels
|
1026
|
+
#todo: add pagination for case more than 1000 channels on the workspace
|
1027
|
+
channels = client.web_client.conversations_list(
|
1028
|
+
types: 'private_channel,public_channel',
|
1029
|
+
limit: '1000',
|
1030
|
+
exclude_archived: 'true').channels
|
1031
|
+
|
1008
1032
|
channel_found = channels.detect { |c| c.name == channel }
|
1009
1033
|
members = client.web_client.conversations_members(channel: @channels_id[channel]).members unless channel_found.nil?
|
1010
1034
|
get_bots_created()
|