slack-smart-bot 0.7.3 → 0.7.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e8df140b707c4449949790ee4aec06123d702f7e504d9181d17ab28ce4907d50
4
- data.tar.gz: cb3b7b350309de0f3597f1349138f1532324377ee51b0340a5d95478a7ef10ef
3
+ metadata.gz: 2fc056a8adf65b10b17f3b644ffa63117ce88287c3dfe405d5d5bda9e9c6a446
4
+ data.tar.gz: ec761cdf4a8b1ff4cd693f952349db588dee7606cc80ee51c640914da61f4b79
5
5
  SHA512:
6
- metadata.gz: 945db84827a120c3cd07c301f15f0de822628060d65ac75d4856f97f19e2af8640a4fe9c7c6290541e2541d89fd6794e90e03170e229f16a2d0fcc6e150632e0
7
- data.tar.gz: de406836aeb262ef22fc468add1a7dc8a0bdd02f2003e94d28e5965f22333a0d6d87bf11efc1062604a83b4ba776aec2ac98616a6d04e2f1d5bffc4da2ff73d8
6
+ metadata.gz: 74d836ba0dd429f20eb44d3172457d1bd4c9fedbfdfda2fda2211d983260986109d8e24719cb1fd05a0a8a9b3f84ff595c00e77e3300343d812b6503c83faf46
7
+ data.tar.gz: 7b02dd37ebad852d730f942efac3af1bc585ed439dd51389a430c7a678c1ad66b54482ff6d4636d5a54e98872a2b585be582394e90a36f53d148e1ae8f077167
@@ -283,8 +283,10 @@ class SlackSmartBot
283
283
  begin
284
284
  case text
285
285
  when /^Bot has been (closed|killed) by/i
286
- @logger.info "#{nick}: #{text}"
287
- exit!
286
+ if CHANNEL == @channels_name[dchannel]
287
+ @logger.info "#{nick}: #{text}"
288
+ exit!
289
+ end
288
290
  when /^Changed status on (.+) to :(.+)/i
289
291
  channel_name = $1
290
292
  status = $2
@@ -472,7 +474,7 @@ class SlackSmartBot
472
474
  #helpadmin: The bot stops running and also stops all the bots created from this master channel
473
475
  #helpadmin: You can use this command only if you are an admin user and you are on the master channel
474
476
  #helpadmin:
475
- when /^exit\sbot/i, /^quit\sbot/i, /^close\sbot/i
477
+ when /^exit\sbot\s*$/i, /^quit\sbot\s*$/i, /^close\sbot\s*$/i
476
478
  if ON_MASTER_BOT
477
479
  if ADMIN_USERS.include?(from) #admin user
478
480
  unless @questions.keys.include?(from)
@@ -672,7 +674,7 @@ class SlackSmartBot
672
674
  #helpmaster: kills the bot on the specified channel
673
675
  #helpmaster: Only works if you are on Master channel and you created that bot or you are an admin user
674
676
  #helpmaster:
675
- when /^kill\sbot\son\s<#C\w+\|(.+)>\s*/i, /^kill\sbot\son\s(.+)\s*/i
677
+ when /^kill\sbot\son\s<#C\w+\|(.+)>\s*$/i, /^kill\sbot\son\s(.+)\s*$/i
676
678
  if ON_MASTER_BOT
677
679
  channel = $1
678
680
 
@@ -735,6 +737,8 @@ class SlackSmartBot
735
737
  end
736
738
  update_rules_imported() if ON_MASTER_BOT
737
739
  respond "I'm using now the rules from <##{channel_found.id}>", dest
740
+ def git_project() "" end
741
+ def project_folder() "" end
738
742
  else
739
743
  respond "You need to join the channel <##{channel_found.id}> to be able to use the rules.", dest
740
744
  end
@@ -760,6 +764,8 @@ class SlackSmartBot
760
764
  @rules_imported[user.id].delete(dchannel)
761
765
  update_rules_imported() if ON_MASTER_BOT
762
766
  respond "You won't be using those rules from now on.", dest
767
+ def git_project() "" end
768
+ def project_folder() "" end
763
769
  end
764
770
  else
765
771
  respond "You were not using those rules.", dest
@@ -772,6 +778,8 @@ class SlackSmartBot
772
778
  @rules_imported[user.id].delete(user.id)
773
779
  update_rules_imported() if ON_MASTER_BOT
774
780
  respond "You won't be using those rules from now on.", dest
781
+ def git_project() "" end
782
+ def project_folder() "" end
775
783
  end
776
784
  else
777
785
  respond "You were not using those rules.", dest
@@ -790,6 +798,7 @@ class SlackSmartBot
790
798
  else
791
799
  specific = false
792
800
  end
801
+ help_message_rules = ''
793
802
  if !specific
794
803
  help_message = IO.readlines(__FILE__).join
795
804
  if ADMIN_USERS.include?(from) #admin user
@@ -816,14 +825,18 @@ class SlackSmartBot
816
825
  end
817
826
  end
818
827
  if specific
819
- unless defined?(rules) or rules_file.empty?
828
+ unless rules_file.empty?
820
829
  begin
821
830
  eval(File.new(rules_file).read) if File.exist?(rules_file)
822
831
  end
823
832
  end
824
- if defined?(git_project)
833
+ if defined?(git_project) and git_project.to_s!='' and help_message_rules != ''
825
834
  respond "Git project: #{git_project}", dest
835
+ else
836
+ def git_project() '' end
837
+ def project_folder() '' end
826
838
  end
839
+
827
840
  else
828
841
  respond "Slack Smart Bot Github project: https://github.com/MarioRuiz/slack-smart-bot", dest
829
842
  end
@@ -1010,7 +1023,12 @@ class SlackSmartBot
1010
1023
 
1011
1024
  begin
1012
1025
  ruby = "ruby -e \"#{code.gsub('"', '\"')}\""
1013
- ruby = ("cd #{project_folder} &&" + ruby) if defined?(project_folder)
1026
+ if defined?(project_folder) and project_folder.to_s!='' and Dir.exist?(project_folder)
1027
+ ruby = ("cd #{project_folder} &&" + ruby)
1028
+ else
1029
+ def project_folder() '' end
1030
+ end
1031
+
1014
1032
  stdout, stderr, status = Open3.capture3(ruby)
1015
1033
  if stderr == ""
1016
1034
  if stdout == ""
@@ -1,3 +1,16 @@
1
+
2
+ #path to the project folder
3
+ # for example "#{`eval echo ~$USER`.chop}/projects/the_project"
4
+ def project_folder()
5
+ "#{`eval echo ~$USER`.chop}/"
6
+ end
7
+
8
+ #link to the project
9
+ def git_project()
10
+ ""
11
+ end
12
+
13
+
1
14
  #for the case of testing, just run this file adding in the end a call to rules with the parameters you want
2
15
  if defined?(respond)
3
16
  @testing = false
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.7.3
4
+ version: 0.7.4
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-08-14 00:00:00.000000000 Z
11
+ date: 2019-08-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: slack-ruby-client