slack-smart-bot 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5ad8c9b6d08d27ac0fa0f03b054b39032a2228f25082433b2d58d400dfabbc99
4
- data.tar.gz: 7a37e23992b269849aa522a5f25865f8e143a22ced0777b6fb08fc1cec05bc3f
3
+ metadata.gz: 982f9adf5d2a1c795a9d6846565fe81531678c321a80dadfc0ef800ca12beacd
4
+ data.tar.gz: 11fc66ba9cddc967dd62b57f5cccc12189afd40358826147fa28a15cc4512aa6
5
5
  SHA512:
6
- metadata.gz: 1388d4e8eff5990665fcf8da616eec0164d242b9b87fdb667c018894e465c76bd00cd709aebaf5bf26a0421f29692d81e1d3f80c46388f559c46023176762890
7
- data.tar.gz: 00e0ba16a2b50d6bf64582bc3e8443694a473732a6c02175097be935c1ee252984ecbc151fe225aab0ceaa9aaf0b7d3ab286d0c7992cfe4794fcfdaa95267dc9
6
+ metadata.gz: 437a90a0344764d1cee245a9572dcb4f942996723c6ef8b256e631e9ae989f0db7886d2930e477aae7f0c2dbb24b9a8789e7e8d6f67e0896da5b4d7c7566e62b
7
+ data.tar.gz: 3123a0005e8fb4aaa4f30568dc64c4f101b3cf3c9a2848db5d453516ac9b95e6c91865d8f6db3470bf728b71a79a1ef5e20de4465fbfd38a3d3c85519ffdb067
@@ -8,7 +8,7 @@ require "open3"
8
8
 
9
9
  if ARGV.size == 0
10
10
  CHANNEL = MASTER_CHANNEL
11
- ON_MASTER_CHANNEL = true
11
+ ON_MASTER_BOT = true
12
12
  ADMIN_USERS = MASTER_USERS
13
13
  RULES_FILE = "#{$0.gsub(".rb", "_rules.rb")}" unless defined?(RULES_FILE)
14
14
  unless File.exist?(RULES_FILE)
@@ -17,7 +17,7 @@ if ARGV.size == 0
17
17
  end
18
18
  STATUS_INIT = :on
19
19
  else
20
- ON_MASTER_CHANNEL = false
20
+ ON_MASTER_BOT = false
21
21
  CHANNEL = ARGV[0]
22
22
  ADMIN_USERS = ARGV[1].split(",")
23
23
  RULES_FILE = ARGV[2]
@@ -60,7 +60,7 @@ class SlackSmartBot
60
60
  end
61
61
  end
62
62
 
63
- if ON_MASTER_CHANNEL and File.exist?($0.gsub(".rb", "_bots.rb"))
63
+ if ON_MASTER_BOT and File.exist?($0.gsub(".rb", "_bots.rb"))
64
64
  file_conf = IO.readlines($0.gsub(".rb", "_bots.rb")).join
65
65
  unless file_conf.to_s() == ""
66
66
  @bots_created = eval(file_conf)
@@ -135,10 +135,13 @@ class SlackSmartBot
135
135
  else
136
136
  id_user = nil
137
137
  end
138
- user_info = wclient.users_info(user: data.user)
139
- if !id_user.nil? or @channels_id[CHANNEL] == data.channel or user_info.user.name == config[:nick]
140
- res = process_first(user_info.user.name, data.text, id_user)
141
- next if res.to_s == "next"
138
+ # Direct messages are treated only on the master bot
139
+ if id_user.nil? or (!id_user.nil? and ON_MASTER_BOT)
140
+ user_info = wclient.users_info(user: data.user)
141
+ if !id_user.nil? or @channels_id[CHANNEL] == data.channel or user_info.user.name == config[:nick]
142
+ res = process_first(user_info.user.name, data.text, id_user)
143
+ next if res.to_s == "next"
144
+ end
142
145
  end
143
146
  end
144
147
 
@@ -157,6 +160,7 @@ class SlackSmartBot
157
160
  when /^Changed status on (.+) to :(.+)/i
158
161
  channel = $1
159
162
  status = $2
163
+ #todo: channel should be channel_id
160
164
  @bots_created[channel][:status] = status.to_sym
161
165
  update_bots_file()
162
166
  end
@@ -204,18 +208,23 @@ class SlackSmartBot
204
208
  command.match?(/^<@#{@salutations.join("|")}>\s+(.+)$/i) or
205
209
  command.match?(/^!(.+)$/)))
206
210
  @logger.info "command: #{nick}> #{command}" unless processed
207
- begin
208
- eval(File.new(RULES_FILE).read) if File.exist?(RULES_FILE)
209
- rescue Exception => stack
210
- @logger.fatal "ERROR ON RULES FILE: #{RULES_FILE}"
211
- @logger.fatal stack
212
- end
213
- if defined?(rules)
214
- command[0] = "" if command[0] == "!"
215
- command.gsub!(/^@\w+:*\s*/, "")
216
- rules(nick, command, processed, id_user)
211
+ #todo: verify this
212
+ if id_user.nil? #only for channels, not for DM
213
+ begin
214
+ eval(File.new(RULES_FILE).read) if File.exist?(RULES_FILE)
215
+ rescue Exception => stack
216
+ @logger.fatal "ERROR ON RULES FILE: #{RULES_FILE}"
217
+ @logger.fatal stack
218
+ end
219
+ if defined?(rules)
220
+ command[0] = "" if command[0] == "!"
221
+ command.gsub!(/^@\w+:*\s*/, "")
222
+ rules(nick, command, processed, id_user)
223
+ else
224
+ @logger.warn "It seems like rules method is not defined"
225
+ end
217
226
  else
218
- @logger.warn "It seems like rules method is not defined"
227
+ @logger.info "it is a direct message so no rules file executed."
219
228
  end
220
229
  end
221
230
  rescue Exception => stack
@@ -227,7 +236,8 @@ class SlackSmartBot
227
236
  end
228
237
  end
229
238
 
230
- #help: *Commands you can use*:
239
+ #help:
240
+ #help: *General commands:*:
231
241
  #help:
232
242
  def process(from, command, id_user)
233
243
  firstname = from.split(/ /).first
@@ -261,14 +271,14 @@ class SlackSmartBot
261
271
  @listening.delete(from)
262
272
  end
263
273
 
264
- #help: `exit bot`
265
- #help: `quit bot`
266
- #help: `close bot`
267
- #help: The bot stops running and also stops all the bots created from this master channel
268
- #help: You can use this command only if you are an admin user and you are on the master channel
269
- #help:
274
+ #helpadmin: `exit bot`
275
+ #helpadmin: `quit bot`
276
+ #helpadmin: `close bot`
277
+ #helpadmin: The bot stops running and also stops all the bots created from this master channel
278
+ #helpadmin: You can use this command only if you are an admin user and you are on the master channel
279
+ #helpadmin:
270
280
  when /^exit\sbot/i, /^quit\sbot/i, /^close\sbot/i
271
- if ON_MASTER_CHANNEL
281
+ if ON_MASTER_BOT
272
282
  if ADMIN_USERS.include?(from) #admin user
273
283
  unless @questions.keys.include?(from)
274
284
  ask("are you sure?", command, from, id_user)
@@ -300,16 +310,16 @@ class SlackSmartBot
300
310
  respond "To do this you need to be an admin user in the master channel", id_user
301
311
  end
302
312
 
303
- #help: `start bot`
304
- #help: `start this bot`
305
- #help: the bot will start to listen
306
- #help: You can use this command only if you are an admin user
307
- #help:
313
+ #helpadmin: `start bot`
314
+ #helpadmin: `start this bot`
315
+ #helpadmin: the bot will start to listen
316
+ #helpadmin: You can use this command only if you are an admin user
317
+ #helpadmin:
308
318
  when /^start\s(this\s)?bot$/i
309
319
  if ADMIN_USERS.include?(from) #admin user
310
320
  respond "This bot is running and listening from now on. You can pause again: pause this bot", id_user
311
321
  @status = :on
312
- unless ON_MASTER_CHANNEL
322
+ unless ON_MASTER_BOT
313
323
  get_channels_name_and_id() unless @channels_name.keys.include?(MASTER_CHANNEL) and @channels_name.keys.include?(CHANNEL)
314
324
  send_msg_channel @channels_name[MASTER_CHANNEL], "Changed status on #{@channels_name[CHANNEL]} to :on"
315
325
  end
@@ -317,17 +327,17 @@ class SlackSmartBot
317
327
  respond "Only admin users can change my status", id_user
318
328
  end
319
329
 
320
- #help: `pause bot`
321
- #help: `pause this bot`
322
- #help: the bot will pause so it will listen only to admin commands
323
- #help: You can use this command only if you are an admin user
324
- #help:
330
+ #helpadmin: `pause bot`
331
+ #helpadmin: `pause this bot`
332
+ #helpadmin: the bot will pause so it will listen only to admin commands
333
+ #helpadmin: You can use this command only if you are an admin user
334
+ #helpadmin:
325
335
  when /^pause\s(this\s)?bot$/i
326
336
  if ADMIN_USERS.include?(from) #admin user
327
337
  respond "This bot is paused from now on. You can start it again: start this bot", id_user
328
338
  respond "zZzzzzZzzzzZZZZZZzzzzzzzz", id_user
329
339
  @status = :paused
330
- unless ON_MASTER_CHANNEL
340
+ unless ON_MASTER_BOT
331
341
  get_channels_name_and_id() unless @channels_name.keys.include?(MASTER_CHANNEL) and @channels_name.keys.include?(CHANNEL)
332
342
  send_msg_channel @channels_name[MASTER_CHANNEL], "Changed status on #{@channels_name[CHANNEL]} to :paused"
333
343
  end
@@ -335,102 +345,115 @@ class SlackSmartBot
335
345
  respond "Only admin users can put me on pause", id_user
336
346
  end
337
347
 
338
- #help: `bot status`
339
- #help: Displays the status of the bot
340
- #help: If on master channel and admin user also it will display info about bots created
341
- #help:
348
+ #helpadmin: `bot status`
349
+ #helpadmin: Displays the status of the bot
350
+ #helpadmin: If on master channel and admin user also it will display info about bots created
351
+ #helpadmin:
342
352
  when /^bot\sstatus/i
343
353
  respond "Status: #{@status}. Rules file: #{File.basename RULES_FILE} ", id_user
344
354
  if @status == :on
345
355
  respond "I'm listening to [#{@listening.join(", ")}]", id_user
346
- if ON_MASTER_CHANNEL and ADMIN_USERS.include?(from)
356
+ if ON_MASTER_BOT and ADMIN_USERS.include?(from)
347
357
  @bots_created.each { |key, value|
348
358
  respond "#{key}: #{value}", id_user
349
359
  }
350
360
  end
351
361
  end
352
362
 
353
- #help: `create bot on CHANNEL_NAME`
354
- #help: creates a new bot on the channel specified
355
- #help: it will work only if you are on Master channel
356
- #help:
357
- when /^create\sbot\son\s(.+)\s*/i
358
- if ON_MASTER_CHANNEL
363
+ #helpmaster: `create bot on CHANNEL_NAME`
364
+ #helpmaster: creates a new bot on the channel specified
365
+ #helpmaster: it will work only if you are on Master channel
366
+ #helpmaster:
367
+ when /^create\sbot\son\s<#C\w+\|(.+)>\s*/i, /^create\sbot\son\s(.+)\s*/i#jal9
368
+ if ON_MASTER_BOT
359
369
  channel = $1
360
- if @bots_created.keys.include?(channel)
370
+
371
+ get_channels_name_and_id() unless @channels_name.keys.include?(channel) or @channels_id.keys.include?(channel)
372
+ channel_id = nil
373
+ if @channels_name.key?(channel) #it is an id
374
+ channel_id = channel
375
+ channel = @channels_name[channel_id]
376
+ elsif @channels_id.key?(channel) #it is a channel name
377
+ channel_id = @channels_id[channel]
378
+ end
379
+ if channel_id.nil?
380
+ respond "There is no channel with that name: #{channel}, please be sure is written exactly the same", id_user
381
+ elsif channel == MASTER_CHANNEL
382
+ respond "There is already a bot in this channel: #{channel}", id_user
383
+ elsif @bots_created.keys.include?(channel_id) #jal9
361
384
  respond "There is already a bot in this channel: #{channel}, kill it before", id_user
362
385
  else
363
- get_channels_name_and_id() unless @channels_name.keys.include?(channel) or @channels_id.keys.include?(channel)
364
- channel_id = nil
365
- if @channels_name.key?(channel) #it is an id
366
- channel_id = channel
367
- elsif @channels_id.key?(channel) #it is a channel name
368
- channel_id = @channels_id[channel]
369
- end
370
-
371
- if !channel_id.nil?
372
- if channel_id != config[:channel]
373
- begin
374
- rules_file = "slack-smart-bot_rules_#{channel_id}_#{from.gsub(" ", "_")}.rb"
375
- if defined?(RULES_FOLDER)
376
- rules_file = RULES_FOLDER + rules_file
377
- else
378
- Dir.mkdir("rules") unless Dir.exist?("rules")
379
- Dir.mkdir("rules/#{channel_id}") unless Dir.exist?("rules/#{channel_id}")
380
- rules_file = "./rules/#{channel_id}/" + rules_file
381
- end
382
- default_rules = (__FILE__).gsub(/\.rb$/, "_rules.rb")
383
- File.delete(rules_file) if File.exist?(rules_file)
384
- FileUtils.copy_file(default_rules, rules_file) unless File.exist?(rules_file)
385
- admin_users = Array.new()
386
- admin_users = [from] + MASTER_USERS
387
- admin_users.uniq!
388
- @logger.info "ruby #{$0} \"#{channel}\" \"#{admin_users.join(",")}\" \"#{rules_file}\" on"
389
- t = Thread.new do
390
- `ruby #{$0} \"#{channel}\" \"#{admin_users.join(",")}\" \"#{rules_file}\" on`
391
- end
392
- @bots_created[channel] = {
393
- creator_name: from,
394
- channel_id: channel_id,
395
- channel_name: @channels_name[channel_id],
396
- status: :on,
397
- created: Time.now.strftime("%Y-%m-%dT%H:%M:%S.000Z")[0..18],
398
- rules_file: rules_file,
399
- admins: admin_users.join(","),
400
- thread: t,
401
- }
402
- respond "The bot has been created on channel: #{channel}. Rules file: #{File.basename rules_file}", id_user
403
- update_bots_file()
404
- rescue Exception => stack
405
- @logger.fatal stack
406
- message = "Problem creating the bot on channel #{channel}. Error: <#{stack}>."
407
- @logger.error message
408
- respond message, id_user
386
+ if channel_id != config[:channel]
387
+ begin
388
+ rules_file = "slack-smart-bot_rules_#{channel_id}_#{from.gsub(" ", "_")}.rb"
389
+ if defined?(RULES_FOLDER)
390
+ rules_file = RULES_FOLDER + rules_file
391
+ else
392
+ Dir.mkdir("rules") unless Dir.exist?("rules")
393
+ Dir.mkdir("rules/#{channel_id}") unless Dir.exist?("rules/#{channel_id}")
394
+ rules_file = "./rules/#{channel_id}/" + rules_file
409
395
  end
410
- else
411
- respond "There is already a bot in this channel: #{channel}, and it is the Master Channel!", id_user
396
+ default_rules = (__FILE__).gsub(/\.rb$/, "_rules.rb")
397
+ File.delete(rules_file) if File.exist?(rules_file)
398
+ FileUtils.copy_file(default_rules, rules_file) unless File.exist?(rules_file)
399
+ admin_users = Array.new()
400
+ admin_users = [from] + MASTER_USERS
401
+ admin_users.uniq!
402
+ @logger.info "ruby #{$0} \"#{channel}\" \"#{admin_users.join(",")}\" \"#{rules_file}\" on"
403
+ t = Thread.new do
404
+ `ruby #{$0} \"#{channel}\" \"#{admin_users.join(",")}\" \"#{rules_file}\" on`
405
+ end
406
+ @bots_created[channel_id] = {
407
+ creator_name: from,
408
+ channel_id: channel_id,
409
+ channel_name: @channels_name[channel_id],
410
+ status: :on,
411
+ created: Time.now.strftime("%Y-%m-%dT%H:%M:%S.000Z")[0..18],
412
+ rules_file: rules_file,
413
+ admins: admin_users.join(","),
414
+ thread: t,
415
+ }
416
+ respond "The bot has been created on channel: #{channel}. Rules file: #{File.basename rules_file}", id_user
417
+ update_bots_file()
418
+ rescue Exception => stack
419
+ @logger.fatal stack
420
+ message = "Problem creating the bot on channel #{channel}. Error: <#{stack}>."
421
+ @logger.error message
422
+ respond message, id_user
412
423
  end
413
424
  else
414
- respond "There is no channel with that name: #{channel}, please be sure is written exactly the same", id_user
425
+ respond "There is already a bot in this channel: #{channel}, and it is the Master Channel!", id_user
415
426
  end
427
+
416
428
  end
417
429
  else
418
430
  respond "Sorry I cannot create bots from this channel, please visit the master channel", id_user
419
431
  end
420
432
 
421
- #help: `kill bot on CHANNEL_NAME`
422
- #help: kills the bot on the specified channel
423
- #help: Only works if you are on Master channel and you created that bot or you are an admin user
424
- #help:
425
- when /^kill\sbot\son\s(.+)\s*/i
426
- if ON_MASTER_CHANNEL
433
+ #helpmaster: `kill bot on CHANNEL_NAME`
434
+ #helpmaster: kills the bot on the specified channel
435
+ #helpmaster: Only works if you are on Master channel and you created that bot or you are an admin user
436
+ #helpmaster:
437
+ when /^kill\sbot\son\s<#C\w+\|(.+)>\s*/i,/^kill\sbot\son\s(.+)\s*/i
438
+ if ON_MASTER_BOT
427
439
  channel = $1
428
- if @bots_created.keys.include?(channel)
429
- if @bots_created[channel][:admins].split(",").include?(from)
430
- if @bots_created[channel][:thread].kind_of?(Thread) and @bots_created[channel][:thread].alive?
431
- @bots_created[channel][:thread].kill
440
+
441
+ get_channels_name_and_id() unless @channels_name.keys.include?(channel) or @channels_id.keys.include?(channel)
442
+ channel_id = nil
443
+ if @channels_name.key?(channel) #it is an id
444
+ channel_id = channel
445
+ channel = @channels_name[channel_id]
446
+ elsif @channels_id.key?(channel) #it is a channel name
447
+ channel_id = @channels_id[channel]
448
+ end
449
+ if channel_id.nil?
450
+ respond "There is no channel with that name: #{channel}, please be sure is written exactly the same", id_user
451
+ elsif @bots_created.keys.include?(channel_id)
452
+ if @bots_created[channel_id][:admins].split(",").include?(from)
453
+ if @bots_created[channel_id][:thread].kind_of?(Thread) and @bots_created[channel_id][:thread].alive?
454
+ @bots_created[channel_id][:thread].kill
432
455
  end
433
- @bots_created.delete(channel)
456
+ @bots_created.delete(channel_id)
434
457
  update_bots_file()
435
458
  respond "Bot on channel: #{channel}, has been killed and deleted.", id_user
436
459
  send_msg_channel(channel, "Bot has been killed by #{from}")
@@ -450,9 +473,19 @@ class SlackSmartBot
450
473
  #help:
451
474
  when /^bot help/i, /^bot,? what can I do/i
452
475
  help_message = IO.readlines(__FILE__).join
453
- help_message_rules = IO.readlines(RULES_FILE).join
476
+ if ADMIN_USERS.include?(from) #admin user
477
+ respond "*Commands for administrators:*\n#{help_message.scan(/#\s*help\s*admin:(.*)/).join("\n")}", id_user
478
+ end
479
+ if ON_MASTER_BOT and id_user.nil?
480
+ respond "*Commands only on Master Channel:*\n#{help_message.scan(/#\s*help\s*master:(.*)/).join("\n")}", id_user
481
+ end
482
+ #jal9
454
483
  respond help_message.scan(/#\s*help\s*:(.*)/).join("\n"), id_user
455
- respond help_message_rules.scan(/#\s*help\s*:(.*)/).join("\n"), id_user
484
+ if id_user.nil? # on a channel
485
+ help_message_rules = IO.readlines(RULES_FILE).join
486
+ respond help_message_rules.scan(/#\s*help\s*:(.*)/).join("\n"), id_user
487
+ end
488
+ respond "Github project: https://github.com/MarioRuiz/slack-smart-bot", id_user
456
489
  else
457
490
  processed = false
458
491
  end
@@ -467,7 +500,7 @@ class SlackSmartBot
467
500
  processed2 = true
468
501
 
469
502
  # help:
470
- # help: *These commands will run only when the smart bot is listening to you or on demand*, for example:
503
+ # help: *These commands will run only when the smart bot is listening to you or on demand*. On demand examples:
471
504
  # help: `!THE_COMMAND`
472
505
  # help: `@bot THE_COMMAND`
473
506
  # help: `@NAME_OF_BOT THE_COMMAND`
@@ -476,7 +509,9 @@ class SlackSmartBot
476
509
  case command
477
510
 
478
511
  #help: `add shortcut NAME: COMMAND`
512
+ #help: `add sc NAME: COMMAND`
479
513
  #help: `add shortcut for all NAME: COMMAND`
514
+ #help: `add sc for all NAME: COMMAND`
480
515
  #help: `shortchut NAME: COMMAND`
481
516
  #help: `shortchut for all NAME: COMMAND`
482
517
  #help: It will add a shortcut that will execute the command we supply.
@@ -487,7 +522,7 @@ class SlackSmartBot
487
522
  #help: `sc spanish account`
488
523
  #help: `shortcut Spanish Account`
489
524
  #help:
490
- when /(add\s)?shortcut\s(for\sall)?\s*(.+):\s(.+)/i
525
+ when /^(add\s)?shortcut\s(for\sall)?\s*(.+):\s(.+)/i, /^(add\s)sc\s(for\sall)?\s*(.+):\s(.+)/i
491
526
  for_all = $2
492
527
  shortcut_name = $3.to_s.downcase
493
528
  command_to_run = $4
@@ -524,9 +559,10 @@ class SlackSmartBot
524
559
  end
525
560
 
526
561
  #help: `delete shortcut NAME`
562
+ #help: `delete sc NAME`
527
563
  #help: It will delete the shortcut with the supplied name
528
564
  #help:
529
- when /delete\sshortcut\s(.+)/i
565
+ when /^delete\sshortcut\s(.+)/i, /^delete\ssc\s(.+)/i
530
566
  shortcut = $1.to_s.downcase
531
567
  deleted = false
532
568
 
@@ -558,9 +594,10 @@ class SlackSmartBot
558
594
  end
559
595
 
560
596
  #help: `see shortcuts`
597
+ #help: `see sc`
561
598
  #help: It will display the shortcuts stored for the user and for :all
562
599
  #help:
563
- when /see\sshortcuts/i
600
+ when /^see\sshortcuts/i, /^see\ssc/i
564
601
  msg = ""
565
602
  if @shortcuts[:all].keys.size > 0
566
603
  msg = "*Available shortcuts for all:*\n"
@@ -586,7 +623,7 @@ class SlackSmartBot
586
623
  #help: `id channel CHANNEL_NAME`
587
624
  #help: shows the id of a channel name
588
625
  #help:
589
- when /id channel (.+)/
626
+ when /^id\schannel\s<#C\w+\|(.+)>\s*/i, /^id channel (.+)/
590
627
  channel_name = $1
591
628
  get_channels_name_and_id()
592
629
  if @channels_id.keys.include?(channel_name)
@@ -601,7 +638,7 @@ class SlackSmartBot
601
638
  # help: `code puts (34344/99)*(34+14)`
602
639
  # help: `ruby require 'json'; res=[]; 20.times {res<<rand(100)}; my_json={result: res}; puts my_json.to_json`
603
640
  # help:
604
- when /ruby\s(.+)/im, /code\s(.+)/im
641
+ when /^ruby\s(.+)/im, /code\s(.+)/im
605
642
  code = $1
606
643
  code.gsub!("\\n", "\n")
607
644
  unless code.match?(/System/i) or code.match?(/Kernel/i) or code.include?("File") or
@@ -21,7 +21,7 @@ end
21
21
  # command: command to run
22
22
  # processed: in case the command has been already processed on Bot class, by default false
23
23
  # help:
24
- # help: *These are specific commands on this bot.*
24
+ # help: *These are specific commands for this bot on this Channel.*
25
25
  # help: They will be accessible only when the bot is listening to you just writing the command
26
26
  # help: or the bot is not listening to you but requested on demand, for example:
27
27
  # help: `!THE_COMMAND`
@@ -44,13 +44,13 @@ def rules(from, command, processed, id_user)
44
44
  # help: `echo SOMETHING`
45
45
  # help: repeats SOMETHING
46
46
  # help:
47
- when /echo\s(.+)/i
47
+ when /^echo\s(.+)/i
48
48
  respond $1, id_user
49
49
 
50
50
  # help: `go to sleep`
51
51
  # help: it will sleep the bot for 10 seconds
52
52
  # help:
53
- when /go\sto\ssleep/i
53
+ when /^go\sto\ssleep/i
54
54
  unless @questions.keys.include?(from)
55
55
  ask("do you want me to take a siesta?", command, from, id_user)
56
56
  else
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.1.0
4
+ version: 0.2.0
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-05-14 00:00:00.000000000 Z
11
+ date: 2019-05-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: slack-ruby-client