slack-bot-server 0.4.6 → 0.4.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -0
- data/CHANGELOG.md +7 -0
- data/README.md +22 -2
- data/lib/slack-bot-server.rb +2 -0
- data/lib/slack_bot_server/server.rb +10 -4
- data/lib/slack_bot_server/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 409222fb9d1da1ef4b382ea3b500b56a0cd40b92
|
4
|
+
data.tar.gz: 07bc768fad2c7667eb492093ba428593b0e04f1c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1bf66dc577ec2da21eb1446a6c6a99d076b604e2fa6695e458f527df3a8de5671953dc315e241d32faa6a63925d55b16abedbdec88d94c4ee83c4b6592c3a220
|
7
|
+
data.tar.gz: e7577836ba2f99695b76e1a195bbcc607d986882fb8a7a52a314c0dfa2c6ea10f5a3e4d1c47d909d4f4c6b71f935bd243ba4694fba1a2ae7a4163fbb86435a85
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -22,6 +22,14 @@ Or install it yourself as:
|
|
22
22
|
|
23
23
|
$ gem install slack-bot-server
|
24
24
|
|
25
|
+
|
26
|
+
### Optional queue stores
|
27
|
+
|
28
|
+
The default queueing mechanism uses Redis as its underlying store, but you are not tied to this - any object that has the API `#push`, `#pop` and `#clear` can be used -- and so Redis is not an explicit dependency.
|
29
|
+
|
30
|
+
However, if you are happy to use Redis (as the examples below to), you shouldensure to add the `redis` gem to your `Gemfile` or your local rubygems installation.
|
31
|
+
|
32
|
+
|
25
33
|
## Usage
|
26
34
|
|
27
35
|
To use the server in your application, you'll need to create a short script that sets up your integration and then runs the server process. Here's a simple example:
|
@@ -160,6 +168,17 @@ of other hooks that you can use when writing a bot:
|
|
160
168
|
the bot was accidentally/intermittently disconnected via the `running?`
|
161
169
|
method, which will return true unless the bot was explicitly stopped.
|
162
170
|
|
171
|
+
### Slack App setup
|
172
|
+
|
173
|
+
When you create your Slack App configuration at https://api.slack.com, it is
|
174
|
+
recommended that you include _at least_ the following scopes:
|
175
|
+
|
176
|
+
* `identify`
|
177
|
+
* `bot`
|
178
|
+
* `chat:write:bot`
|
179
|
+
|
180
|
+
Depending on what your own app plans to do, of course, you may need other scopes
|
181
|
+
too.
|
163
182
|
|
164
183
|
### Managing bots
|
165
184
|
|
@@ -170,6 +189,8 @@ control to add the token to the server.
|
|
170
189
|
|
171
190
|
```ruby
|
172
191
|
# Somewhere within your application
|
192
|
+
require 'slack_bot_server/remote_control'
|
193
|
+
|
173
194
|
queue = SlackBotServer::RedisQueue.new(redis: Redis.new)
|
174
195
|
slack_remote = SlackBotServer::RemoteControl.new(queue: queue)
|
175
196
|
slack_remote.add_bot('user-accounts-slack-api-token')
|
@@ -192,7 +213,7 @@ Up to this point, your bots could only respond to mentions and IM messages, but
|
|
192
213
|
We can tell a bot to send a message into its default room fairly simply using the remote:
|
193
214
|
|
194
215
|
```ruby
|
195
|
-
slack_remote.say('bot-key', text: 'I have an important announcement to make!')
|
216
|
+
slack_remote.say('bot-key', channel: '#general', text: 'I have an important announcement to make!')
|
196
217
|
```
|
197
218
|
|
198
219
|
## Development
|
@@ -209,4 +230,3 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/exciti
|
|
209
230
|
## License
|
210
231
|
|
211
232
|
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
212
|
-
|
@@ -79,7 +79,13 @@ class SlackBotServer::Server
|
|
79
79
|
def start
|
80
80
|
EM.run do
|
81
81
|
@running = true
|
82
|
-
@bots.each
|
82
|
+
@bots.each do |key, bot|
|
83
|
+
begin
|
84
|
+
bot.start
|
85
|
+
rescue => e
|
86
|
+
log_error(e)
|
87
|
+
end
|
88
|
+
end
|
83
89
|
listen_for_instructions if queue
|
84
90
|
end
|
85
91
|
end
|
@@ -93,7 +99,7 @@ class SlackBotServer::Server
|
|
93
99
|
# @param key [String] the key of the bot we're looking for
|
94
100
|
# @return Bot
|
95
101
|
def bot(key)
|
96
|
-
@bots[key
|
102
|
+
@bots[key]
|
97
103
|
end
|
98
104
|
|
99
105
|
# Adds a bot to this server
|
@@ -104,7 +110,7 @@ class SlackBotServer::Server
|
|
104
110
|
bot = @add_proc.call(*args)
|
105
111
|
if bot.respond_to?(:start) && !bot(bot.key)
|
106
112
|
log "adding bot #{bot}"
|
107
|
-
@bots[bot.key
|
113
|
+
@bots[bot.key] = bot
|
108
114
|
bot.start if @running
|
109
115
|
end
|
110
116
|
rescue => e
|
@@ -117,7 +123,7 @@ class SlackBotServer::Server
|
|
117
123
|
def remove_bot(key)
|
118
124
|
if (bot = bot(key))
|
119
125
|
bot.stop
|
120
|
-
@bots.delete(key
|
126
|
+
@bots.delete(key)
|
121
127
|
end
|
122
128
|
rescue => e
|
123
129
|
log_error(e)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: slack-bot-server
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Adam
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-08-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: slack-ruby-client
|
@@ -153,6 +153,7 @@ files:
|
|
153
153
|
- LICENSE.txt
|
154
154
|
- README.md
|
155
155
|
- Rakefile
|
156
|
+
- lib/slack-bot-server.rb
|
156
157
|
- lib/slack_bot_server.rb
|
157
158
|
- lib/slack_bot_server/bot.rb
|
158
159
|
- lib/slack_bot_server/local_queue.rb
|
@@ -183,7 +184,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
183
184
|
version: '0'
|
184
185
|
requirements: []
|
185
186
|
rubyforge_project:
|
186
|
-
rubygems_version: 2.
|
187
|
+
rubygems_version: 2.2.2
|
187
188
|
signing_key:
|
188
189
|
specification_version: 4
|
189
190
|
summary: A server for hosting slack bots.
|