slack-smart-bot 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +41 -7
- data/lib/slack/smart-bot/process.rb +1 -1
- 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: e640de80df6bea5fc531eff1e1e08d4032018b15be712262851779f04028f642
|
4
|
+
data.tar.gz: d3e361a01f6fedd4447a7874c3b8960b24ba18b716a4e1c1c3c83ee90a77d67b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ae2e4b9e6dd3180a5b73ae91d4e6b07de9696ffc0a7502342810938414ea9680b3fd7135a9df9046fb33917405fe6f902b7cb65269f6cd47bba7c3304dd16aa4
|
7
|
+
data.tar.gz: d8bb4daf48b2788d4824ae0103edf1e6382896269e561a97d9c9076769e028bd4a6ebaa8a70d4ab13c38825149e68f492c8747de45ef96a51226b1c7509b443b
|
data/README.md
CHANGED
@@ -47,7 +47,7 @@ MASTER_USERS=["mario"]
|
|
47
47
|
require 'slack-smart-bot'
|
48
48
|
|
49
49
|
settings = {
|
50
|
-
nick: '
|
50
|
+
nick: 'smart-bot', # the smart bot name
|
51
51
|
token: 'xxxxxxxxxxxxxxxxxx' # the API Slack token
|
52
52
|
}
|
53
53
|
|
@@ -171,10 +171,27 @@ Another way to run a command/rule is by asking *on demand*. In this case it is n
|
|
171
171
|
To run a command on demand:
|
172
172
|
**_`!THE_COMMAND`_**
|
173
173
|
**_`@NAME_OF_BOT THE_COMMAND`_**
|
174
|
-
**_`NAME_OF_BOT THE_COMMAND`_**
|
174
|
+
**_`NAME_OF_BOT THE_COMMAND`_**
|
175
|
+
|
176
|
+
Examples run a command on demand:
|
177
|
+
>**_Peter>_** `!ruby puts Time.now`
|
178
|
+
>**_Smart-Bot>_** `2019-10-23 12:43:42 +0000`
|
179
|
+
|
180
|
+
>**_Peter>_** `@smart-bot echo Example`
|
181
|
+
>**_Smart-Bot>_** `Example`
|
182
|
+
|
183
|
+
>**_Peter>_** `smart-bot see shortcuts`
|
184
|
+
>**_Smart-Bot>_** `Available shortcuts for Peter:`
|
185
|
+
>`Spanish account: ruby require 'iso/iban'; 10.times {puts ISO::IBAN.random('ES')}`
|
175
186
|
|
176
187
|
Also you can always call the Smart Bot from any channel, even from channels without a running Smart Bot. You can use the External Call on Demand: **_`@NAME_OF_BOT on #CHANNEL_NAME COMMAND`_**. In this case you will call the bot on #CHANNEL_NAME.
|
177
188
|
|
189
|
+
Example:
|
190
|
+
>**_Peter>_** `@smart-bot on #the_channel ruby puts Time.now`
|
191
|
+
>**_Smart-Bot>_** `2019-10-23 12:43:42 +0000`
|
192
|
+
|
193
|
+
|
194
|
+
|
178
195
|
### Bot Help
|
179
196
|
To get a full list of all commands and rules for a specific Smart Bot: **_`bot help`_**. It will show only the specific available commands for the user requesting.
|
180
197
|
|
@@ -182,6 +199,12 @@ If you want to search just for a specific command: **_`bot help COMMAND`_**
|
|
182
199
|
|
183
200
|
To show only the specific rules of the Smart Bot defined on the rules file: **_`bot rules`_** or **_`bot rules COMMAND`_**
|
184
201
|
|
202
|
+
Example:
|
203
|
+
>**_Peter>_** `bot help echo`
|
204
|
+
>**_Smart-Bot>_** `echo SOMETHING`
|
205
|
+
`repeats SOMETHING`
|
206
|
+
|
207
|
+
|
185
208
|
### Bot Management
|
186
209
|
To create a new bot on a channel, run on MASTER CHANNEL: **_`create bot on CHANNEL`_**. The admins of this new bot on that channel will be the MASTER ADMINS, the creator of the bot and the creator of that channel. It will create a new rules file linked to this new bot.
|
187
210
|
|
@@ -206,14 +229,18 @@ From that moment everybody part of that channel will be able to run the specific
|
|
206
229
|
To stop allowing it: **_`stop using rules on CHANNEL`_**
|
207
230
|
|
208
231
|
### Using rules from other channels
|
209
|
-
To be able to access the rules from other channel, first of all you need to be a member of that channel. Then on a
|
232
|
+
To be able to access the rules from other channel or from a direct conversation with the bot, first of all you need to be a member of that channel. Then on a direct conversation with the Smart Bot or from another bot channel: **_`use rules from CHANNEL`_**
|
210
233
|
|
211
234
|
When you want to stop using those rules with the bot: **_`stop using rules from CHANNEL`_**
|
212
235
|
|
213
236
|
Also you can always call the Smart Bot from any channel, even from channels without a running Smart Bot. You can use the External Call on Demand: **_`@NAME_OF_BOT on #CHANNEL_NAME COMMAND`_**. In this case you will call the bot on #CHANNEL_NAME.
|
214
237
|
|
215
238
|
### Running Ruby code on a conversation
|
216
|
-
You can run Ruby code by using the command: **_`ruby THE_CODE`_**.
|
239
|
+
You can run Ruby code by using the command: **_`ruby THE_CODE`_**.
|
240
|
+
|
241
|
+
Example:
|
242
|
+
>**_Peter>_** `!ruby require 'json'; res=[]; 20.times {res.push rand(100)}; my_json={result: res}; puts my_json.to_json`
|
243
|
+
>**_Smart-Bot>_** `{"result":[63,66,35,83,44,40,72,25,59,73,75,54,56,91,19,6,68,1,25,3]}`
|
217
244
|
|
218
245
|
Also it is possible to attach a Ruby file and the Smart Bot will run and post the output. You need to select Ruby as file format.
|
219
246
|
|
@@ -231,7 +258,14 @@ If you have for example a rule like this: **_`run tests on customers android app
|
|
231
258
|
|
232
259
|
From that moment you will be able to run the command: **_`run tca`_**
|
233
260
|
|
234
|
-
That shortcut will be available for you, in case you want to make it available for everybody on the channel:
|
261
|
+
That shortcut will be available for you, in case you want to make it available for everybody on the channel:
|
262
|
+
Example:
|
263
|
+
>**_Peter>_** `!add shortcut for all spanish bank account: ruby require 'iso/iban'; 3.times {puts ISO::IBAN.random('ES')}`
|
264
|
+
>**_Smart-Bot>_** `shortcut added`
|
265
|
+
>**_Peter>_** `!spanish bank account`
|
266
|
+
>**_Smart-Bot>_** `ES4664553191352006861448`
|
267
|
+
`ES4799209592433480943244`
|
268
|
+
`ES8888795057132445752702`
|
235
269
|
|
236
270
|
To see available shortcuts: **_`see shortcuts`_** and to delete a particular shortcut: **_`delete shortcut NAME`_**
|
237
271
|
|
@@ -239,8 +273,8 @@ To see available shortcuts: **_`see shortcuts`_** and to delete a particular sho
|
|
239
273
|
To add specific commands to be run automatically every certain amount of time or a specific time: **_`add routine NAME every NUMBER PERIOD COMMAND`_** or **_`add routine NAME at TIME COMMAND`_**
|
240
274
|
|
241
275
|
Examples:
|
242
|
-
|
243
|
-
|
276
|
+
>**_`add routine run_tests every 3h run tests on customers`_**
|
277
|
+
>**_`add routine clean_db at 17:05 clean customers temp db`_**
|
244
278
|
|
245
279
|
Also instead of adding a Command to be executed, you can attach a file, then the routine will be created and the attached file will be executed on the criteria specified. Only Master Admins are allowed to use it this way.
|
246
280
|
|
@@ -129,7 +129,7 @@ class SlackSmartBot
|
|
129
129
|
when /^bot\s+rules\s*(.+)?$/i
|
130
130
|
help_command = $1
|
131
131
|
bot_rules(dest, help_command, typem, rules_file, from)
|
132
|
-
when /^\s*(add\s)?shortcut\s(for\sall)?\s*(
|
132
|
+
when /^\s*(add\s)?shortcut\s(for\sall)?\s*([^:]+)\s*:\s*(.+)/i, /^(add\s)sc\s(for\sall)?\s*([^:]+)\s*:\s*(.+)/i
|
133
133
|
for_all = $2
|
134
134
|
shortcut_name = $3.to_s.downcase
|
135
135
|
command_to_run = $4
|