slackbotsy 0.2.1 → 0.2.2
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 +25 -9
- data/lib/slackbotsy/bot.rb +4 -2
- data/lib/slackbotsy/version.rb +1 -1
- metadata +2 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d5e6b3bf32c2daa8ecfc28fb616156d44cd94700
|
4
|
+
data.tar.gz: 2cb3c9397e8c4519737a7a81761932f0977eee7b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d8ac391c4d8da142cd65d22c3e350f9b18296f6fe6ce95b909dcc8b7c687f38042040599460186ff2cacef3e0865419904a0d2dd2cd79c9a84f89b034a9a7845
|
7
|
+
data.tar.gz: 6a88337c439e1ee8f4424a2c91fac52cf44bfa0a37268595103e3198d0a7a3494b9269ef5b6789e0c016ac7d7d0d1f9411d40f4fa480e3bb636eb9d132b1d90a
|
data/README.md
CHANGED
@@ -6,28 +6,44 @@ Ruby bot for Slack chat, inspired by http://github.com/seejohnrun/botsy.
|
|
6
6
|
|
7
7
|
Add this line to your application's Gemfile:
|
8
8
|
|
9
|
-
|
9
|
+
```ruby
|
10
|
+
gem 'slackbotsy'
|
11
|
+
```
|
10
12
|
|
11
|
-
And then
|
13
|
+
And then bundle:
|
12
14
|
|
13
|
-
|
15
|
+
```sh
|
16
|
+
bundle install
|
17
|
+
```
|
14
18
|
|
15
19
|
Or install it yourself as:
|
16
20
|
|
17
|
-
|
21
|
+
```sh
|
22
|
+
gem install slackbotsy
|
23
|
+
```
|
24
|
+
|
25
|
+
## Setup
|
26
|
+
|
27
|
+
botsy requires (at least) two webhooks setup in slack:
|
28
|
+
|
29
|
+
* outgoing webhook: for slack to send messages out to botsy
|
30
|
+
* incoming webhook: for botsy `say` and `attach` methods to respond
|
31
|
+
|
32
|
+
Set these up at https://your_team.slack.com/services/new and copy
|
33
|
+
the webhook urls/tokens to botsy's config as below.
|
18
34
|
|
19
35
|
## Example usage
|
20
36
|
|
21
37
|
```ruby
|
22
38
|
require 'slackbotsy'
|
23
39
|
require 'sinatra'
|
40
|
+
require 'open-uri'
|
24
41
|
|
25
42
|
config = {
|
26
|
-
'
|
27
|
-
'
|
28
|
-
'
|
29
|
-
'
|
30
|
-
'outgoing_token' => 'secret'
|
43
|
+
'channel' => '#default',
|
44
|
+
'name' => 'botsy',
|
45
|
+
'incoming_webhook' => 'https://hooks.slack.com/services/XXXXXXXXX/XXXXXXXXX/XXXXXXXXXXXXXXXXXXXXXXXX',
|
46
|
+
'outgoing_token' => 'secret'
|
31
47
|
}
|
32
48
|
|
33
49
|
bot = Slackbotsy::Bot.new(config) do
|
data/lib/slackbotsy/bot.rb
CHANGED
@@ -2,7 +2,7 @@ require 'net/http'
|
|
2
2
|
require 'net/https'
|
3
3
|
require 'uri'
|
4
4
|
require 'json'
|
5
|
-
|
5
|
+
require 'set'
|
6
6
|
|
7
7
|
module Slackbotsy
|
8
8
|
|
@@ -22,7 +22,9 @@ module Slackbotsy
|
|
22
22
|
|
23
23
|
## setup http connection for sending async incoming webhook messages to slack
|
24
24
|
def setup_incoming_webhook
|
25
|
-
|
25
|
+
## incoming_webhook will be used if provided, otherwise fallback to old-style url with team and token
|
26
|
+
url = @options.fetch('incoming_webhook', false) || "https://#{@options['team']}.slack.com/services/hooks/incoming-webhook?token=#{@options['incoming_token']}"
|
27
|
+
@uri = URI.parse(url)
|
26
28
|
@http = Net::HTTP.new(@uri.host, @uri.port)
|
27
29
|
@http.use_ssl = true
|
28
30
|
@http.verify_mode = OpenSSL::SSL::VERIFY_PEER
|
data/lib/slackbotsy/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: slackbotsy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Richard Lister
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-12-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -109,4 +109,3 @@ signing_key:
|
|
109
109
|
specification_version: 4
|
110
110
|
summary: Ruby bot for Slack chat.
|
111
111
|
test_files: []
|
112
|
-
has_rdoc:
|