lita 2.6.0 → 2.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +2 -0
- data/README.md +4 -2
- data/lib/lita/daemon.rb +1 -1
- data/lib/lita/message.rb +7 -1
- data/lib/lita/robot.rb +6 -0
- data/lib/lita/version.rb +1 -1
- data/spec/lita/adapters/shell_spec.rb +3 -1
- data/spec/lita/message_spec.rb +12 -1
- data/templates/plugin/travis.yml +2 -0
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bee2a741d49b87172b517ce6f499112eff3ee14d
|
4
|
+
data.tar.gz: ae078494be2d7787bc92851abecc9b9aa1c96881
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9a0c5e3efa4af7a3e38f8edf9a10b8c48ceaebdf9cc9227953bb833652abe3c2347375472e5d19e32ff8779c793d4279a887a7d3190c15892b644fbffbea5e8e
|
7
|
+
data.tar.gz: 5f517756b1ffc8ae36e6435db1a1b10a8c8ce2336ec06b2c38f88ca1a10b81dd6363668657b390d45659165ba69314839ec2b30acab1b8d1c71740ea515d5483
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -82,6 +82,7 @@ To configure Lita, edit the file `lita_config.rb` generated by the `lita new` co
|
|
82
82
|
Lita.configure do |config|
|
83
83
|
config.robot.name = "Sir Bottington"
|
84
84
|
config.robot.mention_name = "bottington"
|
85
|
+
config.robot.alias = "/"
|
85
86
|
config.robot.adapter = :example_chat_service
|
86
87
|
config.adapter.username = "bottington"
|
87
88
|
config.adapter.password = "secret"
|
@@ -96,6 +97,7 @@ The main config objects are:
|
|
96
97
|
* `robot` - General settings for Lita.
|
97
98
|
* `name` (String) - The display name the bot will use on the chat service. Default: `"Lita"`.
|
98
99
|
* `mention_name` (String) - The name the bot will look for in messages to determine if the message is being addressed to it. Usually this is the same as the display name, but in some cases it may not be. For example, in HipChat, display names are required to be a first and last name, such as "Lita Bot", whereas the mention system would use a name like "LitaBot". Default: `Lita.config.robot.name`.
|
100
|
+
* `alias` (String) - The alias the bot will look for in messages to determine if the message is being addressed to it. Useful if you want to use something shorter than the robot's name or mention name, such as a slash, to send it a command. No default.
|
99
101
|
* `adapter` (Symbol, String) - The adapter to load. Default: `:shell`.
|
100
102
|
* `log_level` (Symbol, String) - The severity level of log messages to output. Valid options are, in order of severity: `:debug`, `:info`, `:warn`, `:error`, and `:fatal`. For whichever level you choose, log messages of that severity and greater will be output. Default: `:info`.
|
101
103
|
* `admins` (Array<String>) - An array of string user IDs which tell Lita which users are considered administrators. Only these users will have access to Lita's `auth` command. Default: `nil`.
|
@@ -145,7 +147,7 @@ To generate a starting template for a new adapter gem, run `lita adapter NAME`,
|
|
145
147
|
|
146
148
|
### Example
|
147
149
|
|
148
|
-
Here is a bare bones example of an adapter for the
|
150
|
+
Here is a bare bones example of an adapter for the fictitious chat service, FancyChat.
|
149
151
|
|
150
152
|
``` ruby
|
151
153
|
module Lita
|
@@ -205,7 +207,7 @@ route /^echo\s+(.+)/, :echo
|
|
205
207
|
Here is an example of a route declaration with all the options:
|
206
208
|
|
207
209
|
``` ruby
|
208
|
-
route /^echo\s+(.+)/,
|
210
|
+
route /^echo\s+(.+)/, :echo, command: true, restrict_to: [:testers, :committers], help => {
|
209
211
|
"echo FOO" => "Replies back with FOO."
|
210
212
|
}
|
211
213
|
```
|
data/lib/lita/daemon.rb
CHANGED
data/lib/lita/message.rb
CHANGED
@@ -25,7 +25,13 @@ module Lita
|
|
25
25
|
@body = body
|
26
26
|
@source = source
|
27
27
|
|
28
|
-
|
28
|
+
name_pattern = Regexp.escape(@robot.mention_name)
|
29
|
+
|
30
|
+
if @robot.alias
|
31
|
+
name_pattern = "#{name_pattern}|#{Regexp.escape(@robot.alias)}"
|
32
|
+
end
|
33
|
+
|
34
|
+
@command = !!@body.sub!(/^\s*@?(?:#{name_pattern})[:,]?\s*/i, "")
|
29
35
|
end
|
30
36
|
|
31
37
|
# An array of arguments created by shellsplitting the message body, as if
|
data/lib/lita/robot.rb
CHANGED
@@ -13,6 +13,11 @@ module Lita
|
|
13
13
|
# @return [String] The mention name.
|
14
14
|
attr_accessor :mention_name
|
15
15
|
|
16
|
+
# An alias the robot will look for in incoming messages to determine if it's
|
17
|
+
# being addressed.
|
18
|
+
# @return [String, Nil] The alias, if one was set.
|
19
|
+
attr_accessor :alias
|
20
|
+
|
16
21
|
# The name of the robot as it will appear in the chat.
|
17
22
|
# @return [String] The robot's name.
|
18
23
|
attr_reader :name
|
@@ -20,6 +25,7 @@ module Lita
|
|
20
25
|
def initialize
|
21
26
|
@name = Lita.config.robot.name
|
22
27
|
@mention_name = Lita.config.robot.mention_name || @name
|
28
|
+
@alias = Lita.config.robot.alias
|
23
29
|
@app = RackApp.new(self).to_app
|
24
30
|
load_adapter
|
25
31
|
trigger(:loaded)
|
data/lib/lita/version.rb
CHANGED
data/spec/lita/message_spec.rb
CHANGED
@@ -1,7 +1,9 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
3
|
describe Lita::Message do
|
4
|
-
let(:robot)
|
4
|
+
let(:robot) do
|
5
|
+
double("Lita::Robot", name: "Lita", mention_name: "LitaBot", alias: ".")
|
6
|
+
end
|
5
7
|
|
6
8
|
subject do
|
7
9
|
described_class.new(robot, "Hello", "Carl")
|
@@ -53,6 +55,15 @@ describe Lita::Message do
|
|
53
55
|
expect(subject).to be_a_command
|
54
56
|
end
|
55
57
|
|
58
|
+
it "is true when the Robot's alias is used" do
|
59
|
+
subject = described_class.new(
|
60
|
+
robot,
|
61
|
+
"#{robot.alias}hello",
|
62
|
+
"Carl"
|
63
|
+
)
|
64
|
+
expect(subject).to be_a_command
|
65
|
+
end
|
66
|
+
|
56
67
|
it "is false when the message is not addressed to the Robot" do
|
57
68
|
expect(subject).not_to be_a_command
|
58
69
|
end
|
data/templates/plugin/travis.yml
CHANGED
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.
|
4
|
+
version: 2.7.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: 2013-
|
11
|
+
date: 2013-12-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -283,7 +283,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
283
283
|
version: '0'
|
284
284
|
requirements: []
|
285
285
|
rubyforge_project:
|
286
|
-
rubygems_version: 2.1.
|
286
|
+
rubygems_version: 2.1.11
|
287
287
|
signing_key:
|
288
288
|
specification_version: 4
|
289
289
|
summary: A multi-service chat bot with extendable behavior.
|
@@ -306,4 +306,3 @@ test_files:
|
|
306
306
|
- spec/lita/util_spec.rb
|
307
307
|
- spec/lita_spec.rb
|
308
308
|
- spec/spec_helper.rb
|
309
|
-
has_rdoc:
|