slack-smart-bot 0.7.5 → 0.7.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/slack-smart-bot_rules.rb +53 -45
- 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: 1f04209396105787c535cc023a3af0b3e63bb57f5ed62ef379f5d63c3f8b08ef
|
4
|
+
data.tar.gz: d5fb33126522405993050549bca48fae7ce731941629a5b43d770078d8d630df
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 31b67a7e6215163517f9eca2e2131763d14709d3fef207fdb305e392ad28d0f7cc5db7d044aa8dd3e6a161a4e553053d74fbf74b71c1e0e625c6635c123adcd1
|
7
|
+
data.tar.gz: 1d0fdcf1e83bc064e9ae8e0440798c5a066ca87c1383a96fda55e11cfa378bc4fdd8ef3eaddffedd9720a9bbf6fb675eddbc3d14448458aeb94e90420bcd6ec6
|
@@ -10,7 +10,6 @@ def git_project()
|
|
10
10
|
""
|
11
11
|
end
|
12
12
|
|
13
|
-
|
14
13
|
#for the case of testing, just run this file adding in the end a call to rules with the parameters you want
|
15
14
|
if defined?(respond)
|
16
15
|
@testing = false
|
@@ -54,61 +53,70 @@ def rules(user, command, processed, dest)
|
|
54
53
|
end
|
55
54
|
end
|
56
55
|
firstname = from.split(" ").first
|
57
|
-
|
58
|
-
|
59
|
-
# help: ----------------------------------------------
|
60
|
-
# help: `echo SOMETHING`
|
61
|
-
# help: repeats SOMETHING
|
62
|
-
# help:
|
63
|
-
when /^echo\s(.+)/i
|
64
|
-
respond $1, dest
|
56
|
+
begin
|
57
|
+
case command
|
65
58
|
|
66
59
|
# help: ----------------------------------------------
|
67
|
-
# help: `
|
68
|
-
# help:
|
60
|
+
# help: `echo SOMETHING`
|
61
|
+
# help: repeats SOMETHING
|
69
62
|
# help:
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
when /no/i, /nope/i, /cancel/i
|
81
|
-
@questions.delete(from)
|
82
|
-
respond "Thanks, I'm happy to be awake", dest
|
63
|
+
when /^echo\s(.+)/i
|
64
|
+
respond $1, dest
|
65
|
+
|
66
|
+
# help: ----------------------------------------------
|
67
|
+
# help: `go to sleep`
|
68
|
+
# help: it will sleep the bot for 5 seconds
|
69
|
+
# help:
|
70
|
+
when /^go\sto\ssleep/i
|
71
|
+
unless @questions.keys.include?(from)
|
72
|
+
ask("do you want me to take a siesta?", command, from, dest)
|
83
73
|
else
|
84
|
-
|
85
|
-
|
74
|
+
case @questions[from]
|
75
|
+
when /yes/i, /yep/i, /sure/i
|
76
|
+
@questions.delete(from)
|
77
|
+
respond "I'll be sleeping for 5 secs... just for you", dest
|
78
|
+
respond "zZzzzzzZZZZZZzzzzzzz!", dest
|
79
|
+
sleep 5
|
80
|
+
when /no/i, /nope/i, /cancel/i
|
81
|
+
@questions.delete(from)
|
82
|
+
respond "Thanks, I'm happy to be awake", dest
|
83
|
+
else
|
84
|
+
respond "I don't understand", dest
|
85
|
+
ask("are you sure do you want me to sleep? (yes or no)", "go to sleep", from, dest)
|
86
|
+
end
|
86
87
|
end
|
87
|
-
end
|
88
88
|
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
89
|
+
# help: ----------------------------------------------
|
90
|
+
# help: `run something`
|
91
|
+
# help: It will run the process and report the results when done
|
92
|
+
# help:
|
93
|
+
when /^run something/i
|
94
|
+
respond "Running", dest
|
95
95
|
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
96
|
+
process_to_run = "ruby -v"
|
97
|
+
process_to_run = ("cd #{project_folder} &&" + process_to_run) if defined?(project_folder)
|
98
|
+
stdout, stderr, status = Open3.capture3(process_to_run)
|
99
|
+
if stderr == ""
|
100
|
+
if stdout == ""
|
101
|
+
respond "#{user.name}: Nothing returned.", dest
|
102
|
+
else
|
103
|
+
respond "#{user.name}: #{stdout}", dest
|
104
|
+
end
|
102
105
|
else
|
103
|
-
respond "#{user.name}: #{
|
106
|
+
respond "#{user.name}: #{stderr}", dest
|
104
107
|
end
|
105
108
|
else
|
106
|
-
|
109
|
+
unless processed
|
110
|
+
resp = %w{ what huh sorry }.sample
|
111
|
+
respond "#{firstname}: #{resp}?", dest
|
112
|
+
end
|
107
113
|
end
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
respond "
|
114
|
+
rescue => exception
|
115
|
+
if defined?(@logger)
|
116
|
+
@logger.fatal exception
|
117
|
+
respond "Unexpected error!! Please contact an admin to solve it: <@#{ADMIN_USERS.join('>, <@')}>", dest
|
118
|
+
else
|
119
|
+
puts exception
|
112
120
|
end
|
113
121
|
end
|
114
122
|
end
|
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.6
|
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-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: slack-ruby-client
|