slack-smart-bot 1.6.4 → 1.6.5
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/commands/on_bot/repl.rb +34 -4
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 97d3af04c6b231089bad9829779d20b650c878e4782a43d7a43435144c5b9c96
|
4
|
+
data.tar.gz: 111ae9d729118b0e596845c597a613d6f41fb28d34b0e2ce160419aac863d9de
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9a8183b5c24bcd88484932c23bbf0f2df8fd11efedf4c845c6ac39660ab9c9a1c27f2702b6c5e8d312aac083acc968e6c4119ea5f0cffd4a64330824a7f1df90
|
7
|
+
data.tar.gz: 7e5d4ac7c6d6056754d33897ece0475839ce8160be966bf5b37dc6a19f71976944459fc2423899af12de17099635b5f85c277dacd610481af372d401574c120a
|
@@ -100,7 +100,36 @@ class SlackSmartBot
|
|
100
100
|
require \"amazing_print\"
|
101
101
|
bindme' + serialt + ' = binding
|
102
102
|
eval(\"require \'nice_http\'\" , bindme' + serialt + ')
|
103
|
-
|
103
|
+
def repl_params(met)
|
104
|
+
res = []
|
105
|
+
met.parameters.each do |par|
|
106
|
+
if par[0]==:req
|
107
|
+
res << par[1].to_s
|
108
|
+
elsif par[0]==:keyreq
|
109
|
+
res << par[1].to_s + \":\"
|
110
|
+
elsif par[0]==:key
|
111
|
+
res << \"?\"+par[1].to_s + \":\"
|
112
|
+
elsif par[0]==:opt
|
113
|
+
res << \"?\"+par[1].to_s
|
114
|
+
elsif par[0]==:rest
|
115
|
+
res << \"*\"+par[1].to_s
|
116
|
+
elsif par[0]==:keyrest
|
117
|
+
res << \"**\"+par[1].to_s
|
118
|
+
else
|
119
|
+
res << par[1].to_s
|
120
|
+
end
|
121
|
+
end
|
122
|
+
\"(#{res.join(\", \")})\"
|
123
|
+
end
|
124
|
+
def ls(obj)
|
125
|
+
mets = (obj.methods - Object.methods)
|
126
|
+
res = []
|
127
|
+
mets.each do |met|
|
128
|
+
res << \"#{met}#{repl_params(obj.method(met))}\"
|
129
|
+
end
|
130
|
+
res
|
131
|
+
end
|
132
|
+
|
104
133
|
file_input_repl = File.open(\"' + Dir.pwd + '/repl/' + @channel_id + '/' + session_name + '.input\", \"r\")
|
105
134
|
if File.exist?(\"./.smart-bot-repl\")
|
106
135
|
begin
|
@@ -112,6 +141,7 @@ class SlackSmartBot
|
|
112
141
|
sleep 0.2
|
113
142
|
code_to_run_repl = file_input_repl.read
|
114
143
|
if code_to_run_repl.to_s!=''
|
144
|
+
add_to_run_repl = true
|
115
145
|
if code_to_run_repl.to_s.match?(/^quit$/i) or
|
116
146
|
code_to_run_repl.to_s.match?(/^exit$/i) or
|
117
147
|
code_to_run_repl.to_s.match?(/^bye bot$/i) or
|
@@ -119,7 +149,7 @@ class SlackSmartBot
|
|
119
149
|
exit
|
120
150
|
else
|
121
151
|
if code_to_run_repl.match?(/^\s*ls\s+(.+)/)
|
122
|
-
|
152
|
+
add_to_run_repl = false
|
123
153
|
end
|
124
154
|
error = false
|
125
155
|
begin
|
@@ -129,9 +159,9 @@ class SlackSmartBot
|
|
129
159
|
end
|
130
160
|
if resp_repl.to_s != \"\"
|
131
161
|
open(\"' + Dir.pwd + '/repl/' + @channel_id + '/' + session_name + '.output\", \"a+\") {|f|
|
132
|
-
f.puts \"
|
162
|
+
f.puts \"\`\`\`\n#{resp_repl.ai}\n\`\`\`\"
|
133
163
|
}
|
134
|
-
unless error
|
164
|
+
unless error or !add_to_run_repl
|
135
165
|
open(\"' + Dir.pwd + '/repl/' + @channel_id + '/' + session_name + '.run\", \"a+\") {|f|
|
136
166
|
f.puts code_to_run_repl
|
137
167
|
}
|