slack-smart-bot 0.6.9 → 0.6.10
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 +14 -2
- data/lib/slack-smart-bot.rb +8 -1
- 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: f7687e436ba930b00bcd514331e99c3523f914643a507c32431f21eb609a356a
|
4
|
+
data.tar.gz: 940318fcaae2f3ecf2164e0733170ec60e4e9ddc158f555fc0c417ec4b787c6c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1437b5b76934fb52f2a4f3c02d0c7b10d16fc2bcc9a7ddd72795bbdb6636caeeb1b965ff89e96cfeb60bd2892bc868286d3f948ff8c89cb8c753b4bde928d8b2
|
7
|
+
data.tar.gz: af8ad60ba1199b929a22dc7728e0b5d2057f9bbd186b6fb5750946976f3ace333e4312ef4065570579b0136d382b8427b5950d1064f1b0082ee544fb4a7c2da4
|
data/README.md
CHANGED
@@ -29,7 +29,17 @@ settings = {
|
|
29
29
|
token: 'xxxxxxxxxxxxxxxxxx' # the API Slack token
|
30
30
|
}
|
31
31
|
|
32
|
-
|
32
|
+
restarts = 0
|
33
|
+
loop {
|
34
|
+
SlackSmartBot.new(settings).listen
|
35
|
+
if restarts > 300
|
36
|
+
puts "More than 300 restarts. Quitting!"
|
37
|
+
break
|
38
|
+
end
|
39
|
+
restarts+=1
|
40
|
+
puts "Restarting: #{restarts}"
|
41
|
+
sleep 20
|
42
|
+
}
|
33
43
|
```
|
34
44
|
|
35
45
|
The MASTER_CHANNEL will be the channel where you will be able to create other bots and will have special treatment.
|
@@ -208,7 +218,7 @@ Apart of the specific commands you define on the rules file of the channel, you
|
|
208
218
|
|
209
219
|
**_`code RUBY_CODE`_**
|
210
220
|
|
211
|
-
>runs the code supplied and returns the output. Examples:
|
221
|
+
>runs the code supplied and returns the output. Also you can send a Ruby file. Examples:
|
212
222
|
|
213
223
|
>code puts (34344/99)*(34+14)
|
214
224
|
|
@@ -234,6 +244,8 @@ Apart of the specific commands you define on the rules file of the channel, you
|
|
234
244
|
|
235
245
|
>sc spanish account
|
236
246
|
|
247
|
+
>spanish account
|
248
|
+
|
237
249
|
>shortcut Spanish Account
|
238
250
|
|
239
251
|
**_`delete shortcut NAME`_**
|
data/lib/slack-smart-bot.rb
CHANGED
@@ -195,6 +195,13 @@ class SlackSmartBot
|
|
195
195
|
((data.text[0] == "`" and data.text[-1] == "`") or (data.text[0] == "*" and data.text[-1] == "*") or (data.text[0] == "_" and data.text[-1] == "_"))
|
196
196
|
data.text = data.text[1..-2]
|
197
197
|
end
|
198
|
+
|
199
|
+
if !data.files.nil? and data.files.size == 1 and
|
200
|
+
(data.text.match(/^(ruby|code)\s*$/) or (data.text.match(/^\s*$/) and data.files[0].filetype=='ruby') )
|
201
|
+
res=Faraday.new('https://files.slack.com', headers: { "Authorization" => "Bearer #{config[:token]}" }).get(data.files[0].url_private)
|
202
|
+
data.text = "ruby #{res.body.to_s}"
|
203
|
+
end
|
204
|
+
|
198
205
|
if data.text.match(/^<@#{config[:nick_id]}>\s(on\s)?<#(\w+)\|(.+)>\s*:?\s*(.+)$/i)
|
199
206
|
channel_rules = $2
|
200
207
|
channel_rules_name = $3
|
@@ -975,7 +982,7 @@ class SlackSmartBot
|
|
975
982
|
#help: ----------------------------------------------
|
976
983
|
#help: `ruby RUBY_CODE`
|
977
984
|
#help: `code RUBY_CODE`
|
978
|
-
#help: runs the code supplied and returns the output. Examples:
|
985
|
+
#help: runs the code supplied and returns the output. Also you can send a Ruby file. Examples:
|
979
986
|
#help: _code puts (34344/99)*(34+14)_
|
980
987
|
#help: _ruby require 'json'; res=[]; 20.times {res<<rand(100)}; my_json={result: res}; puts my_json.to_json_
|
981
988
|
#help:
|
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.6.
|
4
|
+
version: 0.6.10
|
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-06-
|
11
|
+
date: 2019-06-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: slack-ruby-client
|