lita-irc 2.0.3 → 2.1.0

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: c2ff47b7530a6d41c0d1ccc4b17a00b04d67364e
4
- data.tar.gz: c1fc9eed52ad5f3d92d10edfcf6c47f7507bcad0
3
+ metadata.gz: a1dda3d72d7f84dbdca6634ffe3c0a7f81f921b7
4
+ data.tar.gz: 19412c2a25b7f5ad4e2425deba288befe116aed5
5
5
  SHA512:
6
- metadata.gz: 800f9824912a8a6eae0418df0dae6e7b85c6b9839d424b72591c341b0d580d7e430e8afc16322278d820d06a237e06ff55c2afa441674eb96bf8ac7f48d3e9f1
7
- data.tar.gz: b5f8222e19269fb8126c7d927c6a54fa2798b33826afccd083e25dccd5434c4883d1d615c3961454443ec996f3db22d17dc68b4cd247d8724c2f044844e86912
6
+ metadata.gz: 5d762ba6efad744c31edbd794cb754e3d428169e7f2819cce642fc6832d7c6c6d85e8d2a62c34d123050e621d31d5d22a67da1d6acf9dd2dd3245e08f7249768
7
+ data.tar.gz: 41add8b7a2cfd4c0f8ee4a90fdbd196c54d9c4fd64da644053ff6de4f59608fd5337838c648f0aee1e9ef5e9377455f08f8bc0d5c7e3cef80183431fc8854573
data/README.md CHANGED
@@ -58,7 +58,13 @@ end
58
58
 
59
59
  ## Events
60
60
 
61
- The IRC adapter will trigger the `:connected` and `:disconnected` events when the robot has connected and disconnected from IRC, respectively. There is no payload data for either event.
61
+ The IRC adapter will trigger these events:
62
+
63
+ | Event | When | Payload |
64
+ |------------------------|---------------------------|----------------------------------------|
65
+ | `:connected` | connected to IRC | None |
66
+ | `:disconnected` | disconnected from IRC | None |
67
+ | `:user_joined_room` | a user joins a room | `user: Lita::User`, `room: Lita::Room` |
62
68
 
63
69
  ## License
64
70
 
@@ -9,6 +9,7 @@ module Lita
9
9
  match /.*/
10
10
  listen_to :connect, method: :on_connect
11
11
  listen_to :invite, method: :on_invite
12
+ listen_to :join, method: :on_room_join
12
13
 
13
14
  def execute(m)
14
15
  body = get_body(m)
@@ -27,6 +28,14 @@ module Lita
27
28
  m.channel.join if robot.auth.user_is_admin?(user)
28
29
  end
29
30
 
31
+ def on_room_join(m)
32
+ robot.trigger(
33
+ :user_joined_room,
34
+ user: user_by_nick(m.user.nick),
35
+ room: Lita::Room.create_or_update(m.channel.name, name: m.channel.name),
36
+ )
37
+ end
38
+
30
39
  private
31
40
 
32
41
  def dispatch(message)
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = "lita-irc"
3
- spec.version = "2.0.3"
3
+ spec.version = "2.1.0"
4
4
  spec.authors = ["Jimmy Cuadra"]
5
5
  spec.email = ["jimmy@jimmycuadra.com"]
6
6
  spec.description = %q{An IRC adapter for Lita.}
@@ -9,6 +9,7 @@ describe Lita::Adapters::IRC::CinchPlugin do
9
9
  let(:user) { double("Lita::User", name: "Carl") }
10
10
  let(:message) { double("Lita::Message", command!: nil, source: source) }
11
11
  let(:source) { double("Lita::Source", room: "#channel", user: user) }
12
+ let(:room) { double("Lita::Room", name: "#channel") }
12
13
  let(:m) do
13
14
  instance_double(
14
15
  "Cinch::Message",
@@ -81,4 +82,20 @@ describe Lita::Adapters::IRC::CinchPlugin do
81
82
  subject.on_invite(invite_m)
82
83
  end
83
84
  end
85
+
86
+ describe "#on_room_join" do
87
+ before do
88
+ allow(Lita::Room).to receive(:create_or_update).and_return(room)
89
+ allow(Lita::User).to receive(:find_by_name).and_return(user)
90
+ end
91
+
92
+ it "triggers a join event when someone joins a channel" do
93
+ expect(robot).to receive(:trigger).with(
94
+ :user_joined_room,
95
+ user: user,
96
+ room: room,
97
+ )
98
+ subject.on_room_join(m)
99
+ end
100
+ end
84
101
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lita-irc
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.3
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jimmy Cuadra
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-19 00:00:00.000000000 Z
11
+ date: 2017-02-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: lita
@@ -149,7 +149,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
149
149
  version: '0'
150
150
  requirements: []
151
151
  rubyforge_project:
152
- rubygems_version: 2.4.5
152
+ rubygems_version: 2.5.2
153
153
  signing_key:
154
154
  specification_version: 4
155
155
  summary: An IRC adapter for the Lita chat robot.