slack-smart-bot 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +38 -39
- data/lib/slack/smart-bot/comm.rb +49 -7
- data/lib/slack/smart-bot/commands/on_bot/admin/add_routine.rb +1 -1
- data/lib/slack/smart-bot/commands/on_bot/admin/see_routines.rb +3 -1
- data/lib/slack/smart-bot/commands/on_master/create_bot.rb +0 -2
- data/lib/slack/smart-bot/listen.rb +23 -0
- data/lib/slack/smart-bot/treat_message.rb +2 -2
- data/lib/slack/smart-bot/utils.rb +2 -2
- data/lib/slack-smart-bot.rb +3 -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: de799c58ed76d6aa417063653fd81b62fea79ff9b6abdb1bfcfe0f3b8ce2c93f
|
4
|
+
data.tar.gz: 198a2cca055c64070970f342d62714e3b02cf4258928fa62c729c81d5b1e7867
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: afb02011c7533c06ac196a69ab086186b56946a1d0bb34c4496b0902ef765681d1923169a5238ce14a08ab37fce1d077e6215e0a0716a7cb5a9e622fcedc184e
|
7
|
+
data.tar.gz: 828c7d015b06bcc8ddf601d84218407ced11fe3a7f40526f9dcc4d39dacba582fef35b02258eb9463df7a4bbd8ca17820d560642e004a52fb5a51442497d0492
|
data/README.md
CHANGED
@@ -2,7 +2,6 @@
|
|
2
2
|
|
3
3
|
[![Gem Version](https://badge.fury.io/rb/slack-smart-bot.svg)](https://rubygems.org/gems/slack-smart-bot)
|
4
4
|
[![Build Status](https://travis-ci.com/MarioRuiz/slack-smart-bot.svg?branch=master)](https://github.com/MarioRuiz/slack-smart-bot)
|
5
|
-
[![Coverage Status](https://coveralls.io/repos/github/MarioRuiz/slack-smart-bot/badge.svg?branch=master)](https://coveralls.io/github/MarioRuiz/slack-smart-bot?branch=master)
|
6
5
|
|
7
6
|
Create a Slack bot that is really smart and so easy to expand.
|
8
7
|
|
@@ -88,7 +87,7 @@ Let's guess the file you created was called my_smart_bot.rb so, just run it:
|
|
88
87
|
```
|
89
88
|
nohup ruby my_smart_bot.rb&
|
90
89
|
```
|
91
|
-
nohup will prevent the terminal to send the signal exception: SIGHUP and kill the bot. & will run the process in background. You can use instead: `ruby my_smart_bot.rb & disown`
|
90
|
+
nohup will prevent the terminal to send the signal exception: SIGHUP and kill the bot. & will run the process in background. You can use instead: **_`ruby my_smart_bot.rb & disown`_**
|
92
91
|
|
93
92
|
After the run, it will be generated a rules file with the same name but adding _rules, in this example: my_smart_bot_rules.rb
|
94
93
|
|
@@ -161,96 +160,96 @@ end
|
|
161
160
|
### How to access the Smart Bot
|
162
161
|
You can access the bot directly on the MASTER CHANNEL, on a secondary channel where the bot is running and directly by opening a private chat with the bot, in this case the conversation will be just between you and the bot.
|
163
162
|
|
164
|
-
On a Smart Bot channel you will be able to run some of the commands just by writing a command, for example: `bot help`
|
163
|
+
On a Smart Bot channel you will be able to run some of the commands just by writing a command, for example: **_`bot help`_**
|
165
164
|
|
166
|
-
Some commands will be only available when the Smart Bot is listening to you. For the Smart Bot to start listening to you just say: `hi bot
|
165
|
+
Some commands will be only available when the Smart Bot is listening to you. For the Smart Bot to start listening to you just say: **_`hi bot`_**. When the Smart Bot is listening to you, you can skip a message to be treated by the bot by starting the message with '-', for example: **_`- this message won't be treated`_**. When you want the Smart Bot Stop listening to you: **_`bye bot`_**. If you are on a direct conversation with the Smart Bot then it will be on *listening* mode all the time.
|
167
166
|
|
168
167
|
All the specific commands of the bot are specified on your rules file and can be added or changed accordingly. We usually call those commands: *rules*. Those rules are only available when the bot is listening to you.
|
169
168
|
|
170
169
|
Another way to run a command/rule is by asking *on demand*. In this case it is not necessary that the bot is listening to you.
|
171
170
|
|
172
171
|
To run a command on demand:
|
173
|
-
`!THE_COMMAND`
|
174
|
-
`@NAME_OF_BOT THE_COMMAND`
|
175
|
-
`NAME_OF_BOT THE_COMMAND`
|
172
|
+
**_`!THE_COMMAND`_**
|
173
|
+
**_`@NAME_OF_BOT THE_COMMAND`_**
|
174
|
+
**_`NAME_OF_BOT THE_COMMAND`_**
|
176
175
|
|
177
|
-
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
|
176
|
+
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.
|
178
177
|
|
179
178
|
### Bot Help
|
180
|
-
To get a full list of all commands and rules for a specific Smart Bot: `bot help
|
179
|
+
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.
|
181
180
|
|
182
|
-
If you want to search just for a specific command: `bot help COMMAND`
|
181
|
+
If you want to search just for a specific command: **_`bot help COMMAND`_**
|
183
182
|
|
184
|
-
To show only the specific rules of the Smart Bot defined on the rules file: `bot rules` or `bot rules COMMAND`
|
183
|
+
To show only the specific rules of the Smart Bot defined on the rules file: **_`bot rules`_** or **_`bot rules COMMAND`_**
|
185
184
|
|
186
185
|
### Bot Management
|
187
|
-
To create a new bot on a channel, run on MASTER CHANNEL: `create bot on CHANNEL
|
186
|
+
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.
|
188
187
|
|
189
|
-
You can kill any bot running on any channel if you are an admin of that bot: `kill bot on CHANNEL`
|
188
|
+
You can kill any bot running on any channel if you are an admin of that bot: **_`kill bot on CHANNEL`_**
|
190
189
|
|
191
|
-
If you want to pause a bot, from the channel of the bot: `pause bot
|
190
|
+
If you want to pause a bot, from the channel of the bot: **_`pause bot`_**. To start it again: **_`start bot`_**
|
192
191
|
|
193
|
-
To see the status of the bots, on the MASTER CHANNEL: `bot status`
|
192
|
+
To see the status of the bots, on the MASTER CHANNEL: **_`bot status`_**
|
194
193
|
|
195
|
-
To close the Master Bot, run on MASTER CHANNEL: `exit bot`
|
194
|
+
To close the Master Bot, run on MASTER CHANNEL: **_`exit bot`_**
|
196
195
|
|
197
196
|
#### Cloud Bots
|
198
|
-
If you want to create a bot that will be running on a different machine: `create cloud bot on CHANNEL
|
197
|
+
If you want to create a bot that will be running on a different machine: **_`create cloud bot on CHANNEL`_**. Even though the cloud bots are running on different machines, the management can be done through the MASTER CHANNEL. The new cloud bot will be managed by your Master Bot like the others, closing, pausing...
|
199
198
|
|
200
199
|
Cloud Bots are typically used to run commands on specific environments or even different OS or networks.
|
201
200
|
|
202
201
|
### Extending rules to other channels
|
203
|
-
If you want to extend the use of your specific rules on a Bot Channel to a third channel you can use the command: `extend rules to CHANNEL`
|
202
|
+
If you want to extend the use of your specific rules on a Bot Channel to a third channel you can use the command: **_`extend rules to CHANNEL`_**
|
204
203
|
|
205
|
-
From that moment everybody part of that channel will be able to run the specific rules from the other channel but just on demand, for example: `!run something`
|
204
|
+
From that moment everybody part of that channel will be able to run the specific rules from the other channel but just on demand, for example: **_`!run something`_**
|
206
205
|
|
207
|
-
To stop allowing it: `stop using rules on CHANNEL`
|
206
|
+
To stop allowing it: **_`stop using rules on CHANNEL`_**
|
208
207
|
|
209
208
|
### Using rules from other channels
|
210
|
-
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 private conversation with the Smart Bot or from another bot channel: `use rules from CHANNEL`
|
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 private conversation with the Smart Bot or from another bot channel: **_`use rules from CHANNEL`_**
|
211
210
|
|
212
|
-
When you want to stop using those rules with the bot: `stop using rules from CHANNEL`
|
211
|
+
When you want to stop using those rules with the bot: **_`stop using rules from CHANNEL`_**
|
213
212
|
|
214
|
-
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
|
213
|
+
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.
|
215
214
|
|
216
215
|
### Running Ruby code on a conversation
|
217
|
-
You can run Ruby code by using the command: `ruby THE_CODE
|
216
|
+
You can run Ruby code by using the command: **_`ruby THE_CODE`_**. For example: **_`!ruby require 'json'; res=[]; 20.times {res<<rand(100)}; my_json={result: res}; puts my_json.to_json`_**
|
218
217
|
|
219
218
|
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.
|
220
219
|
|
221
220
|
### Sending notifications
|
222
|
-
You can send notifications from MASTER CHANNEL by using `notify MESSAGE
|
221
|
+
You can send notifications from MASTER CHANNEL by using **_`notify MESSAGE`_**. All Bot Channels will be notified.
|
223
222
|
|
224
|
-
If you want to send a notification message to all channels the bot joined and direct conversations with the bot: `notify all MESSAGE`
|
223
|
+
If you want to send a notification message to all channels the bot joined and direct conversations with the bot: **_`notify all MESSAGE`_**
|
225
224
|
|
226
|
-
And if you want to send a notification message to the specified channel and to its extended channels: `notify #CHANNEL MESSAGE`
|
225
|
+
And if you want to send a notification message to the specified channel and to its extended channels: **_`notify #CHANNEL MESSAGE`_**
|
227
226
|
|
228
227
|
### Shortcuts
|
229
228
|
Sometimes your commands or rules are too long and you want to add a shortcut to be executed.
|
230
229
|
|
231
|
-
If you have for example a rule like this: `run tests on customers android app` and you want to add a shortcut: `add shortcut run tca: run tests on customers android app`
|
230
|
+
If you have for example a rule like this: **_`run tests on customers android app`_** and you want to add a shortcut: **_`add shortcut run tca: run tests on customers android app`_**
|
232
231
|
|
233
|
-
From that moment you will be able to run the command: `run tca`
|
232
|
+
From that moment you will be able to run the command: **_`run tca`_**
|
234
233
|
|
235
|
-
That shortcut will be available for you, in case you want to make it available for everybody on the channel: `add shortcut for all Spanish account: ruby require 'iso/iban'; 10.times {puts ISO::IBAN.random('ES')}`
|
234
|
+
That shortcut will be available for you, in case you want to make it available for everybody on the channel: **_`add shortcut for all Spanish account: ruby require 'iso/iban'; 10.times {puts ISO::IBAN.random('ES')}`_**
|
236
235
|
|
237
|
-
To see available shortcuts: `see shortcuts` and to delete a particular shortcut: `delete shortcut NAME`
|
236
|
+
To see available shortcuts: **_`see shortcuts`_** and to delete a particular shortcut: **_`delete shortcut NAME`_**
|
238
237
|
|
239
238
|
### Routines
|
240
|
-
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`
|
239
|
+
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`_**
|
241
240
|
|
242
241
|
Examples:
|
243
|
-
`add routine run_tests every 3h run tests on customers`
|
244
|
-
`add routine clean_db at 17:05 clean customers temp db`
|
242
|
+
**_`add routine run_tests every 3h run tests on customers`_**
|
243
|
+
**_`add routine clean_db at 17:05 clean customers temp db`_**
|
245
244
|
|
246
245
|
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.
|
247
246
|
|
248
247
|
Other routine commands:
|
249
|
-
* `pause routine NAME`
|
250
|
-
* `start routine NAME`
|
251
|
-
* `remove routine NAME`
|
252
|
-
* `run routine NAME`
|
253
|
-
* `see routines`
|
248
|
+
* **_`pause routine NAME`_**
|
249
|
+
* **_`start routine NAME`_**
|
250
|
+
* **_`remove routine NAME`_**
|
251
|
+
* **_`run routine NAME`_**
|
252
|
+
* **_`see routines`_**
|
254
253
|
|
255
254
|
### Tips
|
256
255
|
|
data/lib/slack/smart-bot/comm.rb
CHANGED
@@ -6,14 +6,26 @@ class SlackSmartBot
|
|
6
6
|
dest = @channels_id[dest] if @channels_id.key?(dest) #it is a name of channel
|
7
7
|
|
8
8
|
if dest.nil?
|
9
|
-
|
9
|
+
if config[:simulate]
|
10
|
+
open("./buffer_complete.log", "a") { |f|
|
11
|
+
f.puts "|#{@channel_id}|#{config[:nick_id]}|#{msg}$$$"
|
12
|
+
}
|
13
|
+
else
|
14
|
+
client.message(channel: @channel_id, text: msg, as_user: true)
|
15
|
+
end
|
10
16
|
if config[:testing] and ON_MASTER_BOT
|
11
17
|
open("./buffer.log", "a") { |f|
|
12
18
|
f.puts "|#{@channel_id}|#{config[:nick_id]}|#{msg}"
|
13
19
|
}
|
14
20
|
end
|
15
21
|
elsif dest[0] == "C" or dest[0] == "G" # channel
|
16
|
-
|
22
|
+
if config[:simulate]
|
23
|
+
open("./buffer_complete.log", "a") { |f|
|
24
|
+
f.puts "|#{dest}|#{config[:nick_id]}|#{msg}$$$"
|
25
|
+
}
|
26
|
+
else
|
27
|
+
client.message(channel: dest, text: msg, as_user: true)
|
28
|
+
end
|
17
29
|
if config[:testing] and ON_MASTER_BOT
|
18
30
|
open("./buffer.log", "a") { |f|
|
19
31
|
f.puts "|#{dest}|#{config[:nick_id]}|#{msg}"
|
@@ -56,14 +68,26 @@ class SlackSmartBot
|
|
56
68
|
end
|
57
69
|
message = "#{to}: #{question}"
|
58
70
|
if dest.nil?
|
59
|
-
|
71
|
+
if config[:simulate]
|
72
|
+
open("./buffer_complete.log", "a") { |f|
|
73
|
+
f.puts "|#{@channel_id}|#{config[:nick_id]}|#{message}$$$"
|
74
|
+
}
|
75
|
+
else
|
76
|
+
client.message(channel: @channel_id, text: message, as_user: true)
|
77
|
+
end
|
60
78
|
if config[:testing] and ON_MASTER_BOT
|
61
79
|
open("./buffer.log", "a") { |f|
|
62
80
|
f.puts "|#{@channel_id}|#{config[:nick_id]}|#{message}"
|
63
81
|
}
|
64
82
|
end
|
65
83
|
elsif dest[0] == "C" or dest[0] == "G" # channel
|
66
|
-
|
84
|
+
if config[:simulate]
|
85
|
+
open("./buffer_complete.log", "a") { |f|
|
86
|
+
f.puts "|#{dest}|#{config[:nick_id]}|#{message}$$$"
|
87
|
+
}
|
88
|
+
else
|
89
|
+
client.message(channel: dest, text: message, as_user: true)
|
90
|
+
end
|
67
91
|
if config[:testing] and ON_MASTER_BOT
|
68
92
|
open("./buffer.log", "a") { |f|
|
69
93
|
f.puts "|#{dest}|#{config[:nick_id]}|#{message}"
|
@@ -87,7 +111,13 @@ class SlackSmartBot
|
|
87
111
|
else
|
88
112
|
@logger.fatal "Channel: #{to} not found. Message: #{msg}"
|
89
113
|
end
|
90
|
-
|
114
|
+
if config[:simulate]
|
115
|
+
open("./buffer_complete.log", "a") { |f|
|
116
|
+
f.puts "|#{to}|#{config[:nick_id]}|#{msg}$$$"
|
117
|
+
}
|
118
|
+
else
|
119
|
+
client.message(channel: channel_id, text: msg, as_user: true)
|
120
|
+
end
|
91
121
|
if config[:testing] and ON_MASTER_BOT
|
92
122
|
open("./buffer.log", "a") { |f|
|
93
123
|
f.puts "|#{to}|#{config[:nick_id]}|#{msg}"
|
@@ -100,7 +130,13 @@ class SlackSmartBot
|
|
100
130
|
def send_msg_user(id_user, msg)
|
101
131
|
unless msg == ""
|
102
132
|
if id_user[0] == "D"
|
103
|
-
|
133
|
+
if config[:simulate]
|
134
|
+
open("./buffer_complete.log", "a") { |f|
|
135
|
+
f.puts "|#{id_user}|#{config[:nick_id]}|#{msg}$$$"
|
136
|
+
}
|
137
|
+
else
|
138
|
+
client.message(channel: id_user, as_user: true, text: msg)
|
139
|
+
end
|
104
140
|
if config[:testing] and ON_MASTER_BOT
|
105
141
|
open("./buffer.log", "a") { |f|
|
106
142
|
f.puts "|#{id_user}|#{config[:nick_id]}|#{msg}"
|
@@ -108,7 +144,13 @@ class SlackSmartBot
|
|
108
144
|
end
|
109
145
|
else
|
110
146
|
im = client.web_client.im_open(user: id_user)
|
111
|
-
|
147
|
+
if config[:simulate]
|
148
|
+
open("./buffer_complete.log", "a") { |f|
|
149
|
+
f.puts "|#{im["channel"]["id"]}|#{config[:nick_id]}|#{msg}$$$"
|
150
|
+
}
|
151
|
+
else
|
152
|
+
client.message(channel: im["channel"]["id"], as_user: true, text: msg)
|
153
|
+
end
|
112
154
|
if config[:testing] and ON_MASTER_BOT
|
113
155
|
open("./buffer.log", "a") { |f|
|
114
156
|
f.puts "|#{im["channel"]["id"]}|#{config[:nick_id]}|#{msg}"
|
@@ -61,7 +61,7 @@ class SlackSmartBot
|
|
61
61
|
Dir.mkdir("./routines/#{@channel_id}") unless Dir.exist?("./routines/#{@channel_id}")
|
62
62
|
|
63
63
|
if !files.nil? && (files.size == 1)
|
64
|
-
@logger.info files[0].inspect
|
64
|
+
@logger.info files[0].inspect if config.testing
|
65
65
|
file_path = "./routines/#{@channel_id}/#{name}#{files[0].name.scan(/[^\.]+(\.\w+$)/).join}"
|
66
66
|
http = NiceHttp.new(host: "https://files.slack.com", headers: { "Authorization" => "Bearer #{config[:token]}" }, log_headers: :partial)
|
67
67
|
http.get(files[0].url_private_download, save_data: file_path)
|
@@ -45,7 +45,9 @@ class SlackSmartBot
|
|
45
45
|
msg << "\tAt: #{v[:at]}" unless v[:at] == ""
|
46
46
|
msg << "\tNext Run: #{v[:next_run]}"
|
47
47
|
msg << "\tLast Run: #{v[:last_run]}"
|
48
|
-
msg << "\tTime consumed on last run: #{v[:last_elapsed]}"
|
48
|
+
msg << "\tTime consumed on last run: #{v[:last_elapsed]}" unless v[:command] !=''
|
49
|
+
msg << "\tCommand: #{v[:command]}" unless v[:command] == ''
|
50
|
+
msg << "\tFile: #{v[:file_path]}" unless v[:file_path] == ''
|
49
51
|
respond msg.join("\n"), dest
|
50
52
|
end
|
51
53
|
end
|
@@ -1,8 +1,31 @@
|
|
1
1
|
class SlackSmartBot
|
2
|
+
def listen_simulate
|
3
|
+
@salutations = [config[:nick], "<@#{config[:nick_id]}>", "bot", "smart"]
|
4
|
+
@pings = []
|
5
|
+
get_bots_created()
|
6
|
+
@buffer_complete = [] unless defined?(@buffer_complete)
|
7
|
+
b = File.read("./buffer_complete.log")
|
8
|
+
result = b.scan(/^\|(\w+)\|(\w+)\|([^$]+)\$\$\$/m)
|
9
|
+
result.delete(nil)
|
10
|
+
new_messages = result[@buffer_complete.size..-1]
|
11
|
+
unless new_messages.nil? or new_messages.empty?
|
12
|
+
@buffer_complete = result
|
13
|
+
new_messages.each do |message|
|
14
|
+
channel = message[0].strip
|
15
|
+
user = message[1].strip
|
16
|
+
command = message[2].to_s.strip
|
17
|
+
# take in consideration that on simulation we are treating all messages even those that are not populated on real cases like when the message is not populated to the specific bot connection when message is sent with the bot
|
18
|
+
@logger.info "treat message: #{message}" if config.testing
|
19
|
+
treat_message({channel: channel, user: user, text: command})
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
2
24
|
def listen
|
3
25
|
@salutations = [config[:nick], "<@#{config[:nick_id]}>", "bot", "smart"]
|
4
26
|
@pings = []
|
5
27
|
get_bots_created()
|
28
|
+
|
6
29
|
client.on :message do |data|
|
7
30
|
unless data.user == "USLACKBOT"
|
8
31
|
treat_message(data)
|
@@ -42,7 +42,7 @@ class SlackSmartBot
|
|
42
42
|
end
|
43
43
|
elsif dest[0] == "C" or dest[0] == "G"
|
44
44
|
#only to be treated on the channel of the bot. excluding running ruby
|
45
|
-
if !ON_MASTER_BOT and @bots_created[@channel_id][:extended].include?(@channels_name[dest]) and
|
45
|
+
if !ON_MASTER_BOT and @bots_created.key?(@channel_id) and @bots_created[@channel_id][:extended].include?(@channels_name[dest]) and
|
46
46
|
!data.text.match?(/^!?\s*(ruby|code)\s+/)
|
47
47
|
typem = :on_extended
|
48
48
|
elsif ON_MASTER_BOT and data.text.match?(/^!?\s*(ruby|code)\s+/) #or in case of running ruby, the master bot
|
@@ -130,7 +130,7 @@ class SlackSmartBot
|
|
130
130
|
@logger.fatal stack
|
131
131
|
end
|
132
132
|
else
|
133
|
-
if !ON_MASTER_BOT and (dest == @master_bot_id or dest[0] == "D") and
|
133
|
+
if !ON_MASTER_BOT and !dest.nil? and (dest == @master_bot_id or dest[0] == "D") and
|
134
134
|
data.text.match?(/^\s*bot\s+status\s*$/i) and @admin_users_id.include?(data.user)
|
135
135
|
respond "ping from #{CHANNEL}", dest
|
136
136
|
end
|
@@ -287,9 +287,9 @@ class SlackSmartBot
|
|
287
287
|
end
|
288
288
|
|
289
289
|
if help.key?(:rules_file)
|
290
|
-
@logger.info channel_type
|
290
|
+
@logger.info channel_type if config.testing
|
291
291
|
if channel_type == :extended or channel_type == :direct
|
292
|
-
@logger.info help.rules_file
|
292
|
+
@logger.info help.rules_file if config.testing
|
293
293
|
help.rules_file = help.rules_file.gsub(/^\s*\*These are specific commands.+NAME_OF_BOT THE_COMMAND`\s*$/im, "")
|
294
294
|
end
|
295
295
|
txt += help.rules_file
|
data/lib/slack-smart-bot.rb
CHANGED
@@ -60,9 +60,11 @@ class SlackSmartBot
|
|
60
60
|
config_log.delete(:token)
|
61
61
|
config[:silent] = false unless config.key?(:silent)
|
62
62
|
config[:testing] = false unless config.key?(:testing)
|
63
|
+
config[:simulate] = false unless config.key?(:simulate)
|
63
64
|
@logger.info "Initializing bot: #{config_log.inspect}"
|
64
65
|
|
65
|
-
File.new("./buffer.log", "w") if config[:testing]
|
66
|
+
File.new("./buffer.log", "w") if config[:testing] and ON_MASTER_BOT
|
67
|
+
File.new("./buffer_complete.log", "w") if config[:simulate] and ON_MASTER_BOT
|
66
68
|
|
67
69
|
config[:channel] = CHANNEL
|
68
70
|
self.config = config
|
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.0.
|
4
|
+
version: 1.0.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-10-
|
11
|
+
date: 2019-10-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: slack-ruby-client
|