slack-smart-bot 1.3.0 → 1.3.1
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 53175e003bbaf58181aecd71f350c0534f66541443bf486075197af040127e72
|
4
|
+
data.tar.gz: 7872fc51317b5501bb0ee7ec87595bafdcefbdcebbfa702159bbae282e24ee9b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f11099c6edbc90ff63ee1f5bf01154997386614d5e201a981a223ef4e73208cf2615ba1492bc0ca34f5b0c0ba318083205e2668518104e2d382d656d03cf7241
|
7
|
+
data.tar.gz: 69041e01eff53c3157702a47ee45501541bafffde9e5d2c3e082ba36ac7f4b77e1c53f2ed116ee8616b76faffade6414350ff025bbeaff212ed769144af51b2a
|
data/README.md
CHANGED
@@ -284,6 +284,17 @@ Example:
|
|
284
284
|
`ES4799209592433480943244`
|
285
285
|
`ES8888795057132445752702`
|
286
286
|
|
287
|
+
In case you want to use a shortcut as a inline shortcut inside a command you can do it by adding a $:
|
288
|
+
Example:
|
289
|
+
>**_Peter>_** `!add shortcut cust1: 3488823-1233`
|
290
|
+
>**_Smart-Bot>_** `shortcut added`
|
291
|
+
>**_Peter>_** `!add shortcut cust2: 1111555-6688`
|
292
|
+
>**_Smart-Bot>_** `shortcut added`
|
293
|
+
>**_Peter>_** `!run tests $cust1`
|
294
|
+
>**_Smart-Bot>_** `Running tests for customers 3488823-1233`
|
295
|
+
>**_Peter>_** `!run tests $cust1 $cust2`
|
296
|
+
>**_Smart-Bot>_** `Running tests for customers 3488823-1233 1111555-6688`
|
297
|
+
|
287
298
|
To see available shortcuts: **_`see shortcuts`_** and to delete a particular shortcut: **_`delete shortcut NAME`_**
|
288
299
|
|
289
300
|
### Routines
|
@@ -9,6 +9,7 @@ class SlackSmartBot
|
|
9
9
|
# help: `shortcut for all NAME: COMMAND`
|
10
10
|
# help: It will add a shortcut that will execute the command we supply.
|
11
11
|
# help: In case we supply 'for all' then the shorcut will be available for everybody
|
12
|
+
# help: If you want to use a shortcut as a inline shortcut inside a command you can do it by adding a $ fex: _!run tests $cust1_
|
12
13
|
# help: Example:
|
13
14
|
# help: _add shortcut for all Spanish account: code require 'iso/iban'; 10.times {puts ISO::IBAN.random('ES')}_
|
14
15
|
# help: Then to call this shortcut:
|
@@ -67,6 +67,9 @@ class SlackSmartBot
|
|
67
67
|
if !files.nil? && (files.size == 1)
|
68
68
|
@logger.info files[0].inspect if config.testing
|
69
69
|
file_path = "#{config.path}/routines/#{@channel_id}/#{name}#{files[0].name.scan(/[^\.]+(\.\w+$)/).join}"
|
70
|
+
if files[0].filetype == "ruby" and files[0].name.scan(/[^\.]+(\.\w+$)/).join == ''
|
71
|
+
file_path += ".rb"
|
72
|
+
end
|
70
73
|
http = NiceHttp.new(host: "https://files.slack.com", headers: { "Authorization" => "Bearer #{config[:token]}" }, log_headers: :partial)
|
71
74
|
http.get(files[0].url_private_download, save_data: file_path)
|
72
75
|
system("chmod +x #{file_path}")
|
@@ -85,6 +85,27 @@ class SlackSmartBot
|
|
85
85
|
addexcl = false
|
86
86
|
command = text.downcase.lstrip.rstrip
|
87
87
|
end
|
88
|
+
|
89
|
+
if command.include?('$') #for adding shortcuts inside commands
|
90
|
+
command.scan(/\$([^\$]+)/i).flatten.each do |sc|
|
91
|
+
sc.strip!
|
92
|
+
if @shortcuts.key?(nick) and @shortcuts[nick].keys.include?(sc)
|
93
|
+
command.gsub!("$#{sc}", @shortcuts[nick][sc])
|
94
|
+
elsif @shortcuts.key?(:all) and @shortcuts[:all].keys.include?(sc)
|
95
|
+
command.gsub!("$#{sc}", @shortcuts[:all][sc])
|
96
|
+
end
|
97
|
+
end
|
98
|
+
command.scan(/\$([^\s]+)/i).flatten.each do |sc|
|
99
|
+
sc.strip!
|
100
|
+
if @shortcuts.key?(nick) and @shortcuts[nick].keys.include?(sc)
|
101
|
+
command.gsub!("$#{sc}", @shortcuts[nick][sc])
|
102
|
+
elsif @shortcuts.key?(:all) and @shortcuts[:all].keys.include?(sc)
|
103
|
+
command.gsub!("$#{sc}", @shortcuts[:all][sc])
|
104
|
+
end
|
105
|
+
end
|
106
|
+
text = command
|
107
|
+
text = "!" + text if addexcl and text[0] != "!"
|
108
|
+
end
|
88
109
|
if command.scan(/^(shortcut|sc)\s+([^:]+)\s*$/i).any? or
|
89
110
|
(@shortcuts.keys.include?(:all) and @shortcuts[:all].keys.include?(command)) or
|
90
111
|
(@shortcuts.keys.include?(nick) and @shortcuts[nick].keys.include?(command))
|
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: 1.3.
|
4
|
+
version: 1.3.1
|
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-11-
|
11
|
+
date: 2019-11-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: slack-ruby-client
|
@@ -39,7 +39,7 @@ dependencies:
|
|
39
39
|
version: '1.7'
|
40
40
|
- - ">="
|
41
41
|
- !ruby/object:Gem::Version
|
42
|
-
version: 1.7.
|
42
|
+
version: 1.7.24
|
43
43
|
type: :runtime
|
44
44
|
prerelease: false
|
45
45
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -49,7 +49,7 @@ dependencies:
|
|
49
49
|
version: '1.7'
|
50
50
|
- - ">="
|
51
51
|
- !ruby/object:Gem::Version
|
52
|
-
version: 1.7.
|
52
|
+
version: 1.7.24
|
53
53
|
- !ruby/object:Gem::Dependency
|
54
54
|
name: nice_hash
|
55
55
|
requirement: !ruby/object:Gem::Requirement
|