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 +4 -4
- data/lib/slack-smart-bot.rb +25 -7
- data/lib/slack-smart-bot_rules.rb +13 -0
- 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: 2fc056a8adf65b10b17f3b644ffa63117ce88287c3dfe405d5d5bda9e9c6a446
|
4
|
+
data.tar.gz: ec761cdf4a8b1ff4cd693f952349db588dee7606cc80ee51c640914da61f4b79
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 74d836ba0dd429f20eb44d3172457d1bd4c9fedbfdfda2fda2211d983260986109d8e24719cb1fd05a0a8a9b3f84ff595c00e77e3300343d812b6503c83faf46
|
7
|
+
data.tar.gz: 7b02dd37ebad852d730f942efac3af1bc585ed439dd51389a430c7a678c1ad66b54482ff6d4636d5a54e98872a2b585be582394e90a36f53d148e1ae8f077167
|
data/lib/slack-smart-bot.rb
CHANGED
@@ -283,8 +283,10 @@ class SlackSmartBot
|
|
283
283
|
begin
|
284
284
|
case text
|
285
285
|
when /^Bot has been (closed|killed) by/i
|
286
|
-
|
287
|
-
|
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
|
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
|
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
|
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
|
-
|
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.
|
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-
|
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
|