slacks 0.3.1 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6c24545abd2bab75c557ad4699e423a2a8bd504e
4
- data.tar.gz: 3e5c5fe08361695315dff88a9c72f304453801f5
3
+ metadata.gz: 13b663a4b93ab60afdd6b5477986cdfb19a6029b
4
+ data.tar.gz: 229c1a95b05d4819b019b14e8b2d656bc6aaadfe
5
5
  SHA512:
6
- metadata.gz: 19adcd7bb6445da7e853792c835e282bae16e1967636b589dee43a3eb72825ce419168ec353891deac42367b68d003a516ab6b8b8d008a0b1331897a92a6e001
7
- data.tar.gz: 5ea7f3cc21d0aac9d7378c092e13de7632722eb0382fedf333cfcdaae1a59b20b8792c04b08521d81a9911772be29df038bb3c2f120be8a130d9c9ba41f68d52
6
+ metadata.gz: cf36d8430ad6dcd355287d09e3e0aef2854705b3c1cf1c03a31df6855ef71011104dd077eef02d42582761fccf5989dc72580ab94d4c124c988c50746bcbe6c5
7
+ data.tar.gz: 43250245831f93f211835d01b2b931bf740c08f065eede6b900b87300d5cf0107cdc8b7a14cccb168dd7c5da0629c2ec927cd900e54eb325500f65e5839080b0
@@ -109,6 +109,13 @@ module Slacks
109
109
 
110
110
  websocket.on(:message) do |data|
111
111
  case data["type"]
112
+ when NilClass
113
+ # Every event has a `type` property:
114
+ # https://api.slack.com/rtm#events
115
+ # If an event comes across without
116
+ # one, we'll skill it.
117
+ next
118
+
112
119
  when EVENT_GROUP_JOINED
113
120
  group = data["channel"]
114
121
  @groups_by_id[group["id"]] = group
@@ -11,6 +11,7 @@ module Slacks
11
11
  protected
12
12
 
13
13
  def trigger(event, *args)
14
+ raise ArgumentError, "Must specify an event to trigger" unless event
14
15
  observers_of(event).each do |block|
15
16
  block.call(*args)
16
17
  end
@@ -1,3 +1,3 @@
1
1
  module Slacks
2
- VERSION = "0.3.1"
2
+ VERSION = "0.3.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: slacks
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bob Lail
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-06-04 00:00:00.000000000 Z
11
+ date: 2016-06-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: websocket-driver
@@ -183,7 +183,6 @@ files:
183
183
  - lib/slacks/bot_user.rb
184
184
  - lib/slacks/channel.rb
185
185
  - lib/slacks/connection.rb
186
- - lib/slacks/conversation.rb
187
186
  - lib/slacks/core_ext/exception.rb
188
187
  - lib/slacks/driver.rb
189
188
  - lib/slacks/errors.rb
@@ -1,48 +0,0 @@
1
- require "thread_safe"
2
-
3
- module Slacks
4
- class Conversation
5
-
6
- def initialize(session, channel, sender)
7
- @session = session
8
- raise NotInChannelError, channel if channel.guest?
9
-
10
- @channel = channel
11
- @sender = sender
12
- @listeners = ThreadSafe::Array.new
13
- end
14
-
15
- def listen_for(*args, &block)
16
- session.listen_for(*args, &block).tap do |listener|
17
- listener.conversation = self
18
- listeners.push listener
19
- end
20
- end
21
-
22
- def includes?(e)
23
- e.channel.id == channel.id && e.sender.id == sender.id
24
- end
25
-
26
- def reply(*messages)
27
- channel.reply(*messages)
28
- end
29
- alias :say :reply
30
-
31
- def ask(question, expect: nil)
32
- listen_for(*Array(expect)) do |e|
33
- e.stop_listening!
34
- yield e
35
- end
36
-
37
- reply question
38
- end
39
-
40
- def end!
41
- listeners.each(&:stop_listening!)
42
- end
43
-
44
- private
45
- attr_reader :session, :channel, :sender, :listeners
46
-
47
- end
48
- end