lita 2.1.1 → 2.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE +19 -0
- data/lib/lita/handler.rb +5 -2
- data/lib/lita/version.rb +1 -1
- data/spec/lita/handler_spec.rb +9 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0b293324db64514ccb9e45a84342fbf522363478
|
4
|
+
data.tar.gz: 50625efaedf4a1b1aeb8c7f0cde496ceee80fd88
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 44946d4c859be7be8bbcaf0aca603c26ff7532cff12451eb20f13931eaad7b67812f5604c810e0a4e38c0986dbf2be298260dff2239a9a89b87a28db7e2914b9
|
7
|
+
data.tar.gz: 44bace7dfae78672b8dcee24cdf3ed952e2dffa5982a442f79503255871bfbff37f8bf3235d8eb4640a624c9710dbf8633d7abeacd701651829cf974111ef3fa
|
data/LICENSE
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
Copyright (c) 2013 Jimmy Cuadra
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
5
|
+
in the Software without restriction, including without limitation the rights
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
8
|
+
furnished to do so, subject to the following conditions:
|
9
|
+
|
10
|
+
The above copyright notice and this permission notice shall be included in
|
11
|
+
all copies or substantial portions of the Software.
|
12
|
+
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
+
THE SOFTWARE.
|
data/lib/lita/handler.rb
CHANGED
@@ -52,7 +52,7 @@ module Lita
|
|
52
52
|
# @return [void]
|
53
53
|
def dispatch(robot, message)
|
54
54
|
routes.each do |route|
|
55
|
-
if route_applies?(route, message)
|
55
|
+
if route_applies?(route, message, robot)
|
56
56
|
Lita.logger.debug <<-LOG.chomp
|
57
57
|
Dispatching message to #{self}##{route.method_name}.
|
58
58
|
LOG
|
@@ -103,13 +103,16 @@ ERROR
|
|
103
103
|
private
|
104
104
|
|
105
105
|
# Determines whether or not an incoming messages should trigger a route.
|
106
|
-
def route_applies?(route, message)
|
106
|
+
def route_applies?(route, message, robot)
|
107
107
|
# Message must match the pattern
|
108
108
|
return unless route.pattern === message.body
|
109
109
|
|
110
110
|
# Message must be a command if the route requires a command
|
111
111
|
return if route.command? && !message.command?
|
112
112
|
|
113
|
+
# Messages from self should be ignored to prevent infinite loops
|
114
|
+
return if message.user.name == robot.name
|
115
|
+
|
113
116
|
# User must be in auth group if route is restricted
|
114
117
|
return if route.required_groups && route.required_groups.none? do |group|
|
115
118
|
Authorization.user_in_group?(message.user, group)
|
data/lib/lita/version.rb
CHANGED
data/spec/lita/handler_spec.rb
CHANGED
@@ -2,7 +2,7 @@ require "spec_helper"
|
|
2
2
|
|
3
3
|
describe Lita::Handler, lita: true do
|
4
4
|
let(:robot) { double("Lita::Robot", name: "Lita") }
|
5
|
-
let(:user) { double("Lita::User") }
|
5
|
+
let(:user) { double("Lita::User", name: "Test User") }
|
6
6
|
|
7
7
|
let(:message) do
|
8
8
|
message = double("Lita::Message", user: user, command?: false)
|
@@ -91,6 +91,14 @@ describe Lita::Handler, lita: true do
|
|
91
91
|
handler_class.dispatch(robot, message)
|
92
92
|
end
|
93
93
|
|
94
|
+
it "doesn't route messages from the bot back to the bot" do
|
95
|
+
allow(message).to receive(:body).and_return("#{robot.name}: bar")
|
96
|
+
allow(message).to receive(:command?).and_return(true)
|
97
|
+
allow(message).to receive(:user).and_return(robot)
|
98
|
+
expect_any_instance_of(handler_class).not_to receive(:blah)
|
99
|
+
handler_class.dispatch(robot, message)
|
100
|
+
end
|
101
|
+
|
94
102
|
it "logs exceptions but doesn't crash the bot" do
|
95
103
|
allow(message).to receive(:body).and_return("#{robot.name}: danger")
|
96
104
|
allow(handler_class).to receive(:rspec_loaded?).and_return(false)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lita
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.1.
|
4
|
+
version: 2.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jimmy Cuadra
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-07-
|
11
|
+
date: 2013-07-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -189,6 +189,7 @@ files:
|
|
189
189
|
- .gitignore
|
190
190
|
- .travis.yml
|
191
191
|
- Gemfile
|
192
|
+
- LICENSE
|
192
193
|
- README.md
|
193
194
|
- Rakefile
|
194
195
|
- bin/lita
|