slack-smart-bot 0.6.8 → 0.6.9
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/lib/slack-smart-bot.rb +29 -21
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6be5b7374264a38618fa3972485f361dc9d0a514c7c5734d62d3b8b5fd775ee7
|
4
|
+
data.tar.gz: 0de7f63e02d543f626e9ec0e06e4a017ac5a9afe0bad2efd51c46b8b53a699e8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a4cfad5cb2a8e3285c2fd2c77f5fc0111e926e97d7fa9ff2a451f737bd43f5974f84f6d0859406e6d0b06576dcb3ac4df884bc02108c1f774bb7166e9a846d2a
|
7
|
+
data.tar.gz: bbb6f59f47f16042744fd1e8c5852fcd1c09846c3b618a75f43cb1fe6fb082f201e37491f723512df483f5f753097d012db3add65d3291f41e3f095a0d81fbba
|
data/lib/slack-smart-bot.rb
CHANGED
@@ -122,7 +122,7 @@ class SlackSmartBot
|
|
122
122
|
@logger.info m
|
123
123
|
@logger.info _data
|
124
124
|
end
|
125
|
-
|
125
|
+
|
126
126
|
client.on :closed do |_data|
|
127
127
|
m = "Connection has been disconnected. #{Time.now}"
|
128
128
|
@logger.info m
|
@@ -200,10 +200,10 @@ class SlackSmartBot
|
|
200
200
|
channel_rules_name = $3
|
201
201
|
command = $4
|
202
202
|
if command.size >= 2 and
|
203
|
-
|
204
|
-
|
203
|
+
((command[0] == "`" and command[-1] == "`") or (command[0] == "*" and command[-1] == "*") or (command[0] == "_" and command[-1] == "_"))
|
204
|
+
command = command[1..-2]
|
205
205
|
end
|
206
|
-
|
206
|
+
|
207
207
|
command = "!" + command unless command[0] == "!"
|
208
208
|
if @channels_id[CHANNEL] == channel_rules #to be treated only on the bot of the requested channel
|
209
209
|
dest = data.channel
|
@@ -245,7 +245,7 @@ class SlackSmartBot
|
|
245
245
|
def process_first(user, text, dest, dchannel)
|
246
246
|
nick = user.name
|
247
247
|
#todo: verify if on slack on anytime nick == config[:nick]
|
248
|
-
if nick == config[:nick]
|
248
|
+
if nick == config[:nick] #if message is coming from the bot
|
249
249
|
begin
|
250
250
|
case text
|
251
251
|
when /^Bot has been killed by/
|
@@ -258,7 +258,7 @@ class SlackSmartBot
|
|
258
258
|
@bots_created[@channels_id[channel_name]][:status] = status.to_sym
|
259
259
|
update_bots_file()
|
260
260
|
if CHANNEL == channel_name
|
261
|
-
@logger.info "#{nick}: #{text}"
|
261
|
+
@logger.info "#{nick}: #{text}"
|
262
262
|
else #on master bot
|
263
263
|
@logger.info "Changed status on #{channel_name} to :#{status}"
|
264
264
|
end
|
@@ -271,17 +271,24 @@ class SlackSmartBot
|
|
271
271
|
end
|
272
272
|
end
|
273
273
|
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
274
|
+
#only for shortcuts
|
275
|
+
if text.match(/^@?(#{config[:nick]}):*\s+(.+)\s*$/i) or
|
276
|
+
text.match(/^()!\s*(.+)\s*$/i) or
|
277
|
+
text.match(/^()<@#{config[:nick_id]}>\s+(.+)\s*$/i)
|
278
|
+
command = $2
|
279
|
+
addexcl = true
|
280
|
+
else
|
281
|
+
addexcl = false
|
282
|
+
command = text.downcase.lstrip.rstrip
|
283
|
+
end
|
284
|
+
if command.scan(/^(shortcut|sc)\s+(.+)/i).any? or
|
285
|
+
(@shortcuts.keys.include?(:all) and @shortcuts[:all].keys.include?(command)) or
|
286
|
+
(@shortcuts.keys.include?(nick) and @shortcuts[nick].keys.include?(command))
|
287
|
+
command = $2.downcase unless $2.nil?
|
288
|
+
if @shortcuts.keys.include?(nick) and @shortcuts[nick].keys.include?(command)
|
289
|
+
text = @shortcuts[nick][command].dup
|
290
|
+
elsif @shortcuts.keys.include?(:all) and @shortcuts[:all].keys.include?(command)
|
291
|
+
text = @shortcuts[:all][command].dup
|
285
292
|
else
|
286
293
|
respond "Shortcut not found", dest
|
287
294
|
return :next
|
@@ -327,7 +334,7 @@ class SlackSmartBot
|
|
327
334
|
if @bots_created[@rules_imported[user.id][dchannel]][:status] == :on
|
328
335
|
rules_file = @bots_created[@rules_imported[user.id][dchannel]][:rules_file]
|
329
336
|
else
|
330
|
-
respond
|
337
|
+
respond "The bot on that channel is not :on", dest
|
331
338
|
done = true
|
332
339
|
end
|
333
340
|
end
|
@@ -697,7 +704,7 @@ class SlackSmartBot
|
|
697
704
|
respond "The channel you are trying to use doesn't exist", dest
|
698
705
|
elsif channel_found.name == MASTER_CHANNEL
|
699
706
|
respond "You cannot use the rules from Master Channel on any other channel.", dest
|
700
|
-
elsif !@bots_created.key?(@channels_id[channel])
|
707
|
+
elsif !@bots_created.key?(@channels_id[channel])
|
701
708
|
respond "There is no bot running on that channel.", dest
|
702
709
|
elsif @bots_created.key?(@channels_id[channel]) and @bots_created[@channels_id[channel]][:status] != :on
|
703
710
|
respond "The bot in that channel is not :on", dest
|
@@ -850,8 +857,9 @@ class SlackSmartBot
|
|
850
857
|
#help: Then to call this shortcut:
|
851
858
|
#help: _sc spanish account_
|
852
859
|
#help: _shortcut Spanish Account_
|
860
|
+
#help: _Spanish Account_
|
853
861
|
#help:
|
854
|
-
when /^(add\s)?shortcut\s(for\sall)?\s*(.+)
|
862
|
+
when /^(add\s)?shortcut\s(for\sall)?\s*(.+)\s*:\s*(.+)/i, /^(add\s)sc\s(for\sall)?\s*(.+)\s*:\s*(.+)/i
|
855
863
|
for_all = $2
|
856
864
|
shortcut_name = $3.to_s.downcase
|
857
865
|
command_to_run = $4
|
@@ -892,7 +900,7 @@ class SlackSmartBot
|
|
892
900
|
#help: `delete sc NAME`
|
893
901
|
#help: It will delete the shortcut with the supplied name
|
894
902
|
#help:
|
895
|
-
when /^delete\
|
903
|
+
when /^delete\s+shortcut\s+(.+)/i, /^delete\s+sc\s+(.+)/i
|
896
904
|
shortcut = $1.to_s.downcase
|
897
905
|
deleted = false
|
898
906
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: slack-smart-bot
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mario Ruiz
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-06-
|
11
|
+
date: 2019-06-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: slack-ruby-client
|