slack-smart-bot 0.3.5 → 0.4.0
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 +16 -6
- data/lib/slack-smart-bot.rb +74 -52
- data/lib/slack-smart-bot_rules.rb +8 -5
- 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: a68ce42a0fde00d5da622e6731e4cf9cd8f6fc7ac64934b4d8b7f8ed06aa16c0
|
4
|
+
data.tar.gz: f611053795351965048bbcdcd23e91a2b0a8c5bba8ddb87f952eb9c33e4d6814
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 607b8375344954a3a01e51c23008bd859d9e1991c67736809c533053f85736e2ca531e0e229782a83d2d75272ba69d508ef0c1e980b171ffcedeca2461a62f1b
|
7
|
+
data.tar.gz: 6f5280c9f8f91b348564955798723a6aa3375f2829bd367a558bb5a1483805caf2aae661a46e9876b1d6970b30ec67c593aff1b611202540eb6e4e70c6d683fc
|
data/README.md
CHANGED
@@ -174,9 +174,9 @@ As soon as you save the file after editing it will become available on your chan
|
|
174
174
|
|
175
175
|
>Only works if you are on Master channel and you created that bot or you are an admin user
|
176
176
|
|
177
|
-
### Available commands only when listening to you or on demand
|
177
|
+
### Available commands only when listening to you or on demand or in a private conversation with the Smart Bot
|
178
178
|
|
179
|
-
All the commands described on here or on your specific Rules file can be used when the bot is listening to you or on demand.
|
179
|
+
All the commands described on here or on your specific Rules file can be used when the bot is listening to you or on demand or in a private conversation with the Smart Bot.
|
180
180
|
|
181
181
|
For the bot to start listening to you you need to use the "Hi bot" command or one of the aliases
|
182
182
|
|
@@ -184,10 +184,6 @@ Also you can call any of these commands on demand by using:
|
|
184
184
|
|
185
185
|
**_`!THE_COMMAND`_**
|
186
186
|
|
187
|
-
**_`@bot THE_COMMAND`_**
|
188
|
-
|
189
|
-
**_`@smart THE_COMMAND`_**
|
190
|
-
|
191
187
|
**_`@BOT_NAME THE_COMMAND`_**
|
192
188
|
|
193
189
|
**_`BOT_NAME THE_COMMAND`_**
|
@@ -237,6 +233,20 @@ Apart of the specific commands you define on the rules file of the channel, you
|
|
237
233
|
**_`id channel CHANNEL_NAME`_**
|
238
234
|
>shows the id of a channel name
|
239
235
|
|
236
|
+
**_`use rules from CHANNEL`_**
|
237
|
+
|
238
|
+
**_`use rules CHANNEL`_**
|
239
|
+
|
240
|
+
>it will use the rules from the specified channel.
|
241
|
+
|
242
|
+
>you need to be part of that channel to be able to use the rules.
|
243
|
+
|
244
|
+
**_`stop using rules from CHANNEL`_**
|
245
|
+
|
246
|
+
**_`stop using rules CHANNEL`_**
|
247
|
+
|
248
|
+
>it will stop using the rules from the specified channel.
|
249
|
+
|
240
250
|
|
241
251
|
## Contributing
|
242
252
|
|
data/lib/slack-smart-bot.rb
CHANGED
@@ -78,8 +78,8 @@ class SlackSmartBot
|
|
78
78
|
end
|
79
79
|
|
80
80
|
# rules imported only for private channels
|
81
|
-
if ON_MASTER_BOT and File.exist?(
|
82
|
-
file_conf = IO.readlines(
|
81
|
+
if ON_MASTER_BOT and File.exist?("./rules/rules_imported.rb")
|
82
|
+
file_conf = IO.readlines("./rules/rules_imported.rb").join
|
83
83
|
unless file_conf.to_s() == ""
|
84
84
|
@rules_imported = eval(file_conf)
|
85
85
|
end
|
@@ -98,7 +98,7 @@ class SlackSmartBot
|
|
98
98
|
m = "Successfully connected, welcome '#{client.self.name}' to the '#{client.team.name}' team at https://#{client.team.domain}.slack.com."
|
99
99
|
puts m
|
100
100
|
@logger.info m
|
101
|
-
respond "Smart Bot started\nIf you want to know what I can do for you: `bot help`
|
101
|
+
respond "Smart Bot started\nIf you want to know what I can do for you: `bot help`.\n`bot rules` if you want to display just the specific rules of this channel.\nYou can talk to me privately if you prefer it."
|
102
102
|
end
|
103
103
|
|
104
104
|
@status = STATUS_INIT
|
@@ -129,7 +129,6 @@ class SlackSmartBot
|
|
129
129
|
file.close
|
130
130
|
end
|
131
131
|
|
132
|
-
|
133
132
|
def get_channels_name_and_id
|
134
133
|
channels = wclient.channels_list.channels
|
135
134
|
@channels_id = Hash.new()
|
@@ -221,13 +220,17 @@ class SlackSmartBot
|
|
221
220
|
begin
|
222
221
|
processed = process(user, command, id_user, dchannel)
|
223
222
|
@logger.info "command: #{nick}> #{command}" if processed
|
223
|
+
on_demand = false
|
224
|
+
if command.match(/^@?(#{config[:nick]}):*\s+(.+)$/i) or
|
225
|
+
command.match(/^()!(.+)$/i) or
|
226
|
+
command.match(/^()<@#{config[:nick_id]}>\s+(.+)$/i)
|
227
|
+
command = $2
|
228
|
+
on_demand = true
|
229
|
+
end
|
224
230
|
if @status == :on and
|
225
|
-
(
|
226
|
-
|
227
|
-
|
228
|
-
command.match?(/^@?#{@salutations.join("|")}:*\s+(.+)$/i) or
|
229
|
-
command.match?(/^<@#{@salutations.join("|")}>\s+(.+)$/i) or
|
230
|
-
command.match?(/^!(.+)$/)))
|
231
|
+
(@questions.keys.include?(nick) or
|
232
|
+
@listening.include?(nick) or
|
233
|
+
!id_user.nil? or on_demand)
|
231
234
|
@logger.info "command: #{nick}> #{command}" unless processed
|
232
235
|
#todo: verify this
|
233
236
|
if id_user.nil? #only for channels, not for DM
|
@@ -243,7 +246,6 @@ class SlackSmartBot
|
|
243
246
|
rules_file = @bots_created[@rules_imported[user.id][dchannel]][:rules_file]
|
244
247
|
end
|
245
248
|
end
|
246
|
-
@logger.info "rules file: #{rules_file}"
|
247
249
|
begin
|
248
250
|
eval(File.new(rules_file).read) if File.exist?(rules_file)
|
249
251
|
rescue Exception => stack
|
@@ -285,7 +287,7 @@ class SlackSmartBot
|
|
285
287
|
else #jal9
|
286
288
|
@logger.info "it is a direct message with no rules file selected so no rules file executed."
|
287
289
|
unless processed
|
288
|
-
resp = [
|
290
|
+
resp = ["what", "huh", "sorry", "what do you mean", "I don't understand"].sample
|
289
291
|
respond "#{resp}?", id_user
|
290
292
|
end
|
291
293
|
end
|
@@ -299,8 +301,9 @@ class SlackSmartBot
|
|
299
301
|
end
|
300
302
|
end
|
301
303
|
|
304
|
+
#help: ==============================================
|
302
305
|
#help:
|
303
|
-
#help: *General commands
|
306
|
+
#help: *General commands:*
|
304
307
|
#help:
|
305
308
|
def process(user, command, id_user, dchannel)
|
306
309
|
from = user.name
|
@@ -309,6 +312,7 @@ class SlackSmartBot
|
|
309
312
|
|
310
313
|
case command
|
311
314
|
|
315
|
+
#help: ----------------------------------------------
|
312
316
|
#help: `Hello Bot`
|
313
317
|
#help: `Hello Smart`
|
314
318
|
#help: `Hello THE_NAME_OF_THE_BOT`
|
@@ -327,6 +331,7 @@ class SlackSmartBot
|
|
327
331
|
@listening << from unless @listening.include?(from)
|
328
332
|
end
|
329
333
|
|
334
|
+
#help: ----------------------------------------------
|
330
335
|
#help: `Bye Bot`
|
331
336
|
#help: `Bye Smart`
|
332
337
|
#help: `Bye NAME_OF_THE_BOT`
|
@@ -340,6 +345,7 @@ class SlackSmartBot
|
|
340
345
|
@listening.delete(from)
|
341
346
|
end
|
342
347
|
|
348
|
+
#helpadmin: ----------------------------------------------
|
343
349
|
#helpadmin: `exit bot`
|
344
350
|
#helpadmin: `quit bot`
|
345
351
|
#helpadmin: `close bot`
|
@@ -379,6 +385,7 @@ class SlackSmartBot
|
|
379
385
|
respond "To do this you need to be an admin user in the master channel: <##{@channels_id[MASTER_CHANNEL]}>", id_user
|
380
386
|
end
|
381
387
|
|
388
|
+
#helpadmin: ----------------------------------------------
|
382
389
|
#helpadmin: `start bot`
|
383
390
|
#helpadmin: `start this bot`
|
384
391
|
#helpadmin: the bot will start to listen
|
@@ -396,6 +403,7 @@ class SlackSmartBot
|
|
396
403
|
respond "Only admin users can change my status", id_user
|
397
404
|
end
|
398
405
|
|
406
|
+
#helpadmin: ----------------------------------------------
|
399
407
|
#helpadmin: `pause bot`
|
400
408
|
#helpadmin: `pause this bot`
|
401
409
|
#helpadmin: the bot will pause so it will listen only to admin commands
|
@@ -414,6 +422,7 @@ class SlackSmartBot
|
|
414
422
|
respond "Only admin users can put me on pause", id_user
|
415
423
|
end
|
416
424
|
|
425
|
+
#helpadmin: ----------------------------------------------
|
417
426
|
#helpadmin: `bot status`
|
418
427
|
#helpadmin: Displays the status of the bot
|
419
428
|
#helpadmin: If on master channel and admin user also it will display info about bots created
|
@@ -429,6 +438,7 @@ class SlackSmartBot
|
|
429
438
|
end
|
430
439
|
end
|
431
440
|
|
441
|
+
#helpmaster: ----------------------------------------------
|
432
442
|
#helpmaster: `create bot on CHANNEL_NAME`
|
433
443
|
#helpmaster: creates a new bot on the channel specified
|
434
444
|
#helpmaster: it will work only if you are on Master channel
|
@@ -447,7 +457,7 @@ class SlackSmartBot
|
|
447
457
|
end
|
448
458
|
channels = wclient.channels_list.channels
|
449
459
|
channel_found = channels.detect { |c| c.name == channel }
|
450
|
-
|
460
|
+
|
451
461
|
if channel_id.nil?
|
452
462
|
respond "There is no channel with that name: #{channel}, please be sure is written exactly the same", id_user
|
453
463
|
elsif channel == MASTER_CHANNEL
|
@@ -505,6 +515,7 @@ class SlackSmartBot
|
|
505
515
|
respond "Sorry I cannot create bots from this channel, please visit the master channel: <##{@channels_id[MASTER_CHANNEL]}>", id_user
|
506
516
|
end
|
507
517
|
|
518
|
+
#helpmaster: ----------------------------------------------
|
508
519
|
#helpmaster: `kill bot on CHANNEL_NAME`
|
509
520
|
#helpmaster: kills the bot on the specified channel
|
510
521
|
#helpmaster: Only works if you are on Master channel and you created that bot or you are an admin user
|
@@ -533,7 +544,7 @@ class SlackSmartBot
|
|
533
544
|
respond "Bot on channel: #{channel}, has been killed and deleted.", id_user
|
534
545
|
send_msg_channel(channel, "Bot has been killed by #{from}")
|
535
546
|
else
|
536
|
-
respond "You need to be the creator or an admin of that channel", id_user
|
547
|
+
respond "You need to be the creator or an admin of that bot channel", id_user
|
537
548
|
end
|
538
549
|
else
|
539
550
|
respond "There is no bot in this channel: #{channel}", id_user
|
@@ -542,6 +553,7 @@ class SlackSmartBot
|
|
542
553
|
respond "Sorry I cannot kill bots from this channel, please visit the master channel: <##{@channels_id[MASTER_CHANNEL]}>", id_user
|
543
554
|
end
|
544
555
|
|
556
|
+
#help: ----------------------------------------------
|
545
557
|
#help: `use rules from CHANNEL`
|
546
558
|
#help: `use rules CHANNEL`
|
547
559
|
#help: it will use the rules from the specified channel.
|
@@ -570,6 +582,7 @@ class SlackSmartBot
|
|
570
582
|
end
|
571
583
|
end
|
572
584
|
|
585
|
+
#help: ----------------------------------------------
|
573
586
|
#help: `stop using rules from CHANNEL`
|
574
587
|
#help: `stop using rules CHANNEL`
|
575
588
|
#help: it will stop using the rules from the specified channel.
|
@@ -583,7 +596,7 @@ class SlackSmartBot
|
|
583
596
|
end
|
584
597
|
if id_user.nil? #channel
|
585
598
|
if @rules_imported.key?(user.id) and @rules_imported[user.id].key?(dchannel)
|
586
|
-
if @rules_imported[user.id][dchannel]!= channel_id
|
599
|
+
if @rules_imported[user.id][dchannel] != channel_id
|
587
600
|
respond "You are not using those rules.", id_user
|
588
601
|
else
|
589
602
|
@rules_imported[user.id].delete(dchannel)
|
@@ -595,7 +608,7 @@ class SlackSmartBot
|
|
595
608
|
end
|
596
609
|
else #direct message
|
597
610
|
if @rules_imported.key?(user.id) and @rules_imported[user.id].key?(user.id)
|
598
|
-
if @rules_imported[user.id][user.id]!= channel_id
|
611
|
+
if @rules_imported[user.id][user.id] != channel_id
|
599
612
|
respond "You are not using those rules.", id_user
|
600
613
|
else
|
601
614
|
@rules_imported[user.id].delete(user.id)
|
@@ -607,19 +620,19 @@ class SlackSmartBot
|
|
607
620
|
end
|
608
621
|
end
|
609
622
|
|
610
|
-
|
623
|
+
#help: ----------------------------------------------
|
611
624
|
#help: `bot help`
|
612
625
|
#help: `bot what can I do?`
|
613
|
-
#help: `bot
|
626
|
+
#help: `bot rules`
|
614
627
|
#help: it will display this help
|
615
|
-
#help: bot
|
616
|
-
when /^bot (
|
617
|
-
if $1.to_s
|
628
|
+
#help: `bot rules` will show only the specific rules for this channel.
|
629
|
+
when /^bot (rules|help)/i, /^bot,? what can I do/i
|
630
|
+
if $1.to_s.match?(/rules/i)
|
618
631
|
specific = true
|
619
632
|
else
|
620
633
|
specific = false
|
621
634
|
end
|
622
|
-
if !specific
|
635
|
+
if !specific
|
623
636
|
help_message = IO.readlines(__FILE__).join
|
624
637
|
if ADMIN_USERS.include?(from) #admin user
|
625
638
|
respond "*Commands for administrators:*\n#{help_message.scan(/#\s*help\s*admin:(.*)/).join("\n")}", id_user
|
@@ -633,7 +646,6 @@ class SlackSmartBot
|
|
633
646
|
rules_file = RULES_FILE
|
634
647
|
|
635
648
|
if @rules_imported.key?(user.id) and @rules_imported[user.id].key?(dchannel)
|
636
|
-
|
637
649
|
unless @bots_created.key?(@rules_imported[user.id][dchannel])
|
638
650
|
file_conf = IO.readlines($0.gsub(".rb", "_bots.rb")).join
|
639
651
|
unless file_conf.to_s() == ""
|
@@ -642,7 +654,7 @@ class SlackSmartBot
|
|
642
654
|
end
|
643
655
|
if @bots_created.key?(@rules_imported[user.id][dchannel])
|
644
656
|
rules_file = @bots_created[@rules_imported[user.id][dchannel]][:rules_file]
|
645
|
-
respond
|
657
|
+
respond "*You are using rules from another channel: <##{@rules_imported[user.id][dchannel]}>. These are the specific commands for that channel:*", id_user
|
646
658
|
end
|
647
659
|
end
|
648
660
|
help_message_rules = IO.readlines(rules_file).join
|
@@ -656,7 +668,7 @@ class SlackSmartBot
|
|
656
668
|
end
|
657
669
|
if @bots_created.key?(@rules_imported[user.id][user.id])
|
658
670
|
rules_file = @bots_created[@rules_imported[user.id][user.id]][:rules_file]
|
659
|
-
respond
|
671
|
+
respond "*You are using rules from channel: <##{@rules_imported[user.id][user.id]}>. These are the specific commands for that channel:*", id_user
|
660
672
|
help_message_rules = IO.readlines(rules_file).join
|
661
673
|
respond help_message_rules.scan(/#\s*help\s*:(.*)/).join("\n"), id_user
|
662
674
|
end
|
@@ -666,24 +678,31 @@ class SlackSmartBot
|
|
666
678
|
processed = false
|
667
679
|
end
|
668
680
|
|
681
|
+
on_demand = false #jal9
|
682
|
+
if command.match(/^@?(#{config[:nick]}):*\s+(.+)$/i) or
|
683
|
+
command.match(/^()!(.+)$/i) or
|
684
|
+
command.match(/^()<@#{config[:nick_id]}>\s+(.+)$/i)
|
685
|
+
command = $2
|
686
|
+
on_demand = true
|
687
|
+
end
|
688
|
+
|
669
689
|
#only when :on and (listening or on demand or direct message)
|
670
690
|
if @status == :on and
|
671
|
-
(
|
672
|
-
|
673
|
-
|
674
|
-
command.match?(/^@?#{@salutations.join("|")}:*\s+(.+)$/i) or
|
675
|
-
command.match?(/^!(.+)$/)))
|
691
|
+
(@questions.keys.include?(from) or
|
692
|
+
@listening.include?(from) or
|
693
|
+
!id_user.nil? or on_demand)
|
676
694
|
processed2 = true
|
677
695
|
|
678
|
-
#
|
679
|
-
#
|
680
|
-
#
|
681
|
-
#
|
682
|
-
#
|
683
|
-
#
|
684
|
-
#
|
696
|
+
#help: ==============================================
|
697
|
+
#help:
|
698
|
+
#help: *These commands will run only when the smart bot is listening to you or on demand or in a private conversation with the Smart Bot*. On demand examples:
|
699
|
+
#help: `!THE_COMMAND`
|
700
|
+
#help: `@NAME_OF_BOT THE_COMMAND`
|
701
|
+
#help: `NAME_OF_BOT THE_COMMAND`
|
702
|
+
#help:
|
685
703
|
case command
|
686
704
|
|
705
|
+
#help: ----------------------------------------------
|
687
706
|
#help: `add shortcut NAME: COMMAND`
|
688
707
|
#help: `add sc NAME: COMMAND`
|
689
708
|
#help: `add shortcut for all NAME: COMMAND`
|
@@ -693,10 +712,10 @@ class SlackSmartBot
|
|
693
712
|
#help: It will add a shortcut that will execute the command we supply.
|
694
713
|
#help: In case we supply 'for all' then the shorcut will be available for everybody
|
695
714
|
#help: Example:
|
696
|
-
#help:
|
715
|
+
#help: _add shortcut for all Spanish account: code require 'iso/iban'; 10.times {puts ISO::IBAN.random('ES')}_
|
697
716
|
#help: Then to call this shortcut:
|
698
|
-
#help:
|
699
|
-
#help:
|
717
|
+
#help: _sc spanish account_
|
718
|
+
#help: _shortcut Spanish Account_
|
700
719
|
#help:
|
701
720
|
when /^(add\s)?shortcut\s(for\sall)?\s*(.+):\s(.+)/i, /^(add\s)sc\s(for\sall)?\s*(.+):\s(.+)/i
|
702
721
|
for_all = $2
|
@@ -734,6 +753,7 @@ class SlackSmartBot
|
|
734
753
|
end
|
735
754
|
end
|
736
755
|
|
756
|
+
#help: ----------------------------------------------
|
737
757
|
#help: `delete shortcut NAME`
|
738
758
|
#help: `delete sc NAME`
|
739
759
|
#help: It will delete the shortcut with the supplied name
|
@@ -769,6 +789,7 @@ class SlackSmartBot
|
|
769
789
|
respond "shortcut not found", id_user
|
770
790
|
end
|
771
791
|
|
792
|
+
#help: ----------------------------------------------
|
772
793
|
#help: `see shortcuts`
|
773
794
|
#help: `see sc`
|
774
795
|
#help: It will display the shortcuts stored for the user and for :all
|
@@ -796,6 +817,7 @@ class SlackSmartBot
|
|
796
817
|
end
|
797
818
|
respond "No shortcuts found", id_user if msg == ""
|
798
819
|
|
820
|
+
#help: ----------------------------------------------
|
799
821
|
#help: `id channel CHANNEL_NAME`
|
800
822
|
#help: shows the id of a channel name
|
801
823
|
#help:
|
@@ -808,12 +830,13 @@ class SlackSmartBot
|
|
808
830
|
respond "channel: #{channel_name} not found", id_user
|
809
831
|
end
|
810
832
|
|
811
|
-
#
|
812
|
-
#
|
813
|
-
#
|
814
|
-
#
|
815
|
-
#
|
816
|
-
#
|
833
|
+
#help: ----------------------------------------------
|
834
|
+
#help: `ruby RUBY_CODE`
|
835
|
+
#help: `code RUBY_CODE`
|
836
|
+
#help: runs the code supplied and returns the output. Examples:
|
837
|
+
#help: _code puts (34344/99)*(34+14)_
|
838
|
+
#help: _ruby require 'json'; res=[]; 20.times {res<<rand(100)}; my_json={result: res}; puts my_json.to_json_
|
839
|
+
#help:
|
817
840
|
when /^ruby\s(.+)/im, /code\s(.+)/im
|
818
841
|
code = $1
|
819
842
|
code.gsub!("\\n", "\n")
|
@@ -889,25 +912,24 @@ class SlackSmartBot
|
|
889
912
|
client.message(channel: im["channel"]["id"], as_user: true, text: msg)
|
890
913
|
end
|
891
914
|
end
|
892
|
-
|
915
|
+
|
893
916
|
#to send a file to an user or channel
|
894
917
|
def send_file(to, msg, file, title, format)
|
895
|
-
if to[0]=="U" #user
|
918
|
+
if to[0] == "U" #user
|
896
919
|
im = wclient.im_open(user: to)
|
897
920
|
channel = im["channel"]["id"]
|
898
921
|
else
|
899
922
|
channel = to
|
900
923
|
end
|
901
|
-
|
924
|
+
|
902
925
|
wclient.files_upload(
|
903
926
|
channels: channel,
|
904
927
|
as_user: true,
|
905
928
|
file: Faraday::UploadIO.new(file, format),
|
906
929
|
title: title,
|
907
930
|
filename: file,
|
908
|
-
initial_comment: msg
|
931
|
+
initial_comment: msg,
|
909
932
|
)
|
910
|
-
|
911
933
|
end
|
912
934
|
|
913
935
|
private :update_bots_file, :get_channels_name_and_id, :update_shortcuts_file
|
@@ -20,12 +20,13 @@ end
|
|
20
20
|
# from: Full name of the person sending the message
|
21
21
|
# command: command to run
|
22
22
|
# processed: in case the command has been already processed on Bot class, by default false
|
23
|
+
# help: ==============================================
|
23
24
|
# help:
|
24
25
|
# help: *These are specific commands for this bot on this Channel.*
|
25
26
|
# help: They will be accessible only when the bot is listening to you just writing the command
|
26
|
-
# help: or the bot is not listening to you but requested on demand,
|
27
|
+
# help: or the bot is not listening to you but requested on demand, or in a private conversation with the Smart Bot.
|
28
|
+
# help: On demand examples: for example:
|
27
29
|
# help: `!THE_COMMAND`
|
28
|
-
# help: `@bot THE_COMMAND`
|
29
30
|
# help: `@NAME_OF_BOT THE_COMMAND`
|
30
31
|
# help: `NAME_OF_BOT THE_COMMAND`
|
31
32
|
# help:
|
@@ -42,14 +43,16 @@ def rules(user, command, processed, id_user)
|
|
42
43
|
firstname = from.split(" ").first
|
43
44
|
case command
|
44
45
|
|
46
|
+
# help: ----------------------------------------------
|
45
47
|
# help: `echo SOMETHING`
|
46
48
|
# help: repeats SOMETHING
|
47
49
|
# help:
|
48
50
|
when /^echo\s(.+)/i
|
49
51
|
respond $1, id_user
|
50
52
|
|
53
|
+
# help: ----------------------------------------------
|
51
54
|
# help: `go to sleep`
|
52
|
-
# help: it will sleep the bot for
|
55
|
+
# help: it will sleep the bot for 5 seconds
|
53
56
|
# help:
|
54
57
|
when /^go\sto\ssleep/i
|
55
58
|
unless @questions.keys.include?(from)
|
@@ -58,8 +61,8 @@ def rules(user, command, processed, id_user)
|
|
58
61
|
case @questions[from]
|
59
62
|
when /yes/i, /yep/i, /sure/i
|
60
63
|
respond "zZzzzzzZZZZZZzzzzzzz!", id_user
|
61
|
-
respond "I'll be sleeping for
|
62
|
-
sleep
|
64
|
+
respond "I'll be sleeping for 5 secs... just for you", id_user
|
65
|
+
sleep 5
|
63
66
|
when /no/i, /nope/i, /cancel/i
|
64
67
|
@questions.delete(from)
|
65
68
|
respond "Thanks, I'm happy to be awake", id_user
|
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.
|
4
|
+
version: 0.4.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-
|
11
|
+
date: 2019-05-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: slack-ruby-client
|