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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/slack-smart-bot.rb +29 -21
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 79e7f5fe180d59d53a3b04c4f5a6a71521f3153add97d4d2c7b467d0e14c7d70
4
- data.tar.gz: 4c503562cc952a1c8bc892ee862bfc2d25de84e829a216b302dc6e771a2eb2db
3
+ metadata.gz: 6be5b7374264a38618fa3972485f361dc9d0a514c7c5734d62d3b8b5fd775ee7
4
+ data.tar.gz: 0de7f63e02d543f626e9ec0e06e4a017ac5a9afe0bad2efd51c46b8b53a699e8
5
5
  SHA512:
6
- metadata.gz: f960f7c7d0fd5e6949ac4b942dac8715da5a5275d514aea9faac5febb0f58ca74dfaae0b5fd9f9f969f79284ec50d982bd17449950cb8cc297b335f12661c69e
7
- data.tar.gz: 729157c3ed6944b91aaeca4748f6a179f89df8cb953dee392d949d512800c507620e8f588d8f5b62d02bb267a1ca5b917ea763b5eaf30af999fd7e76f75f65de
6
+ metadata.gz: a4cfad5cb2a8e3285c2fd2c77f5fc0111e926e97d7fa9ff2a451f737bd43f5974f84f6d0859406e6d0b06576dcb3ac4df884bc02108c1f774bb7166e9a846d2a
7
+ data.tar.gz: bbb6f59f47f16042744fd1e8c5852fcd1c09846c3b618a75f43cb1fe6fb082f201e37491f723512df483f5f753097d012db3add65d3291f41e3f095a0d81fbba
@@ -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
- ((command[0] == "`" and command[-1] == "`") or (command[0] == "*" and command[-1] == "*") or (command[0] == "_" and command[-1] == "_"))
204
- command = command[1..-2]
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] or nick == (config[:nick] + " · Bot") #if message is coming from the bot
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
- if text.match?(/^!?(shortcut|sc)\s(.+)/i)
275
- shortcut = text.scan(/!?\w+\s*(.+)\s*/i).join.downcase
276
- if text[0] == "!"
277
- addexcl = true
278
- else
279
- addexcl = false
280
- end
281
- if @shortcuts.keys.include?(nick) and @shortcuts[nick].keys.include?(shortcut)
282
- text = @shortcuts[nick][shortcut].dup
283
- elsif @shortcuts.keys.include?(:all) and @shortcuts[:all].keys.include?(shortcut)
284
- text = @shortcuts[:all][shortcut].dup
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 'The bot on that channel is not :on', dest
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*(.+):\s(.+)/i, /^(add\s)sc\s(for\sall)?\s*(.+):\s(.+)/i
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\sshortcut\s(.+)/i, /^delete\ssc\s(.+)/i
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.8
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-24 00:00:00.000000000 Z
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