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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 062cd0cf380f316730fdc5ae366b47cd9e35cfda
4
- data.tar.gz: 2374192ee2136ddf0d7f0387a7a56b3d23820716
3
+ metadata.gz: d5e6b3bf32c2daa8ecfc28fb616156d44cd94700
4
+ data.tar.gz: 2cb3c9397e8c4519737a7a81761932f0977eee7b
5
5
  SHA512:
6
- metadata.gz: fbf40e41c8953d45fae2d29d088b3b379aa0dd3007026692405f913ac777a539355bec3367acb25db0329dd072e9bd683088fd3bf9574b213bfc6bc66966b101
7
- data.tar.gz: 4f55803b9465f2299d144617f83791fc4296bdf043d230479115386377ce8b0e4f5d212641c8811c2ca7002362733b6cabcd9debe11ecf893a63d0e9b4efedc3
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
- gem 'slackbotsy'
9
+ ```ruby
10
+ gem 'slackbotsy'
11
+ ```
10
12
 
11
- And then execute:
13
+ And then bundle:
12
14
 
13
- $ bundle
15
+ ```sh
16
+ bundle install
17
+ ```
14
18
 
15
19
  Or install it yourself as:
16
20
 
17
- $ gem install slackbotsy
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
- 'team' => 'your_team',
27
- 'channel' => '#default',
28
- 'name' => 'botsy',
29
- 'incoming_token' => 'secret',
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
@@ -2,7 +2,7 @@ require 'net/http'
2
2
  require 'net/https'
3
3
  require 'uri'
4
4
  require 'json'
5
- # require 'set'
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
- @uri = URI.parse "https://#{@options['team']}.slack.com/services/hooks/incoming-webhook?token=#{@options['incoming_token']}"
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
@@ -1,3 +1,3 @@
1
1
  module Slackbotsy
2
- VERSION = "0.2.1"
2
+ VERSION = "0.2.2"
3
3
  end
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.1
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-10-04 00:00:00.000000000 Z
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: