lita-manners 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: e186ba9e2768f2f88c3be46b7f6176492138a44e
4
+ data.tar.gz: 6c99d6352b176406fdeb0e5d1128e7b556736d6f
5
+ SHA512:
6
+ metadata.gz: 2db175c4b4884d708d92907c4db1a3a284e82d7356c2fe72ebccd543c97c2067e9fd88e3d6318b7943d0ef42356fcefe5ae7163b0f8a2f8886fda3ca5ad7b4d2
7
+ data.tar.gz: d8219b4c9b5e72712cbe63ece026eb9b2d2d68c1f24d398bcf5c62ea31e92ef1470c21e9480df4a610dbbde0768866b7fa67905cd3f45264191cfe9133235509
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/.travis.yml ADDED
@@ -0,0 +1,8 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.0.0
4
+ script: bundle exec rake
5
+ before_install:
6
+ - gem update --system
7
+ services:
8
+ - redis-server
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec
data/LICENSE.md ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Neil Ang
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,70 @@
1
+ # lita-manners
2
+
3
+ [![Build Status](https://travis-ci.org/neilang/lita-manners.png?branch=master)](https://travis-ci.org/neilang/lita-manners)
4
+ [![Coverage Status](https://coveralls.io/repos/neilang/lita-manners/badge.png)](https://coveralls.io/r/neilang/lita-manners)
5
+
6
+ Makes Lita politely respond to simple hello/goodbye/thank you/sorry commands and mentions.
7
+
8
+ ## Installation
9
+
10
+ Add lita-manners to your Lita instance's Gemfile:
11
+
12
+ ``` ruby
13
+ gem "lita-manners"
14
+ ```
15
+
16
+ ## Configuration
17
+
18
+ There is no configuration.
19
+
20
+ ## Usage
21
+
22
+ Give Lita basic manners to answer questions.
23
+
24
+ Saying hello...
25
+
26
+ ```
27
+ # Mentions
28
+ You: Hello Lita
29
+ Lita: Hello You
30
+
31
+ # Commands
32
+ You: @lita hi!
33
+ Lita: hi You
34
+ ```
35
+
36
+ Saying goodbye...
37
+
38
+ ```
39
+ # Mentions
40
+ You: Goodbye Lita
41
+ Lita: Goodbye You
42
+
43
+ # Commands
44
+ You: @lita bye!
45
+ Lita: bye You
46
+ ```
47
+
48
+ Saying you're welcome...
49
+
50
+ ```
51
+ # Mentions
52
+ You: Thank you Lita
53
+ Lita: You're welcome You
54
+
55
+ # Commands
56
+ You: @lita thanks
57
+ Lita: You're welcome You
58
+ ```
59
+
60
+ Accepting an apology...
61
+
62
+ ```
63
+ # Mentions
64
+ You: Sorry Lita
65
+ Lita: Apology accepted You
66
+
67
+ # Commands
68
+ You: @lita I'm sorry
69
+ Lita: Apology accepted You
70
+ ```
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task default: :spec
@@ -0,0 +1,12 @@
1
+ require "lita"
2
+
3
+ Lita.load_locales Dir[File.expand_path(
4
+ File.join("..", "..", "locales", "*.yml"), __FILE__
5
+ )]
6
+
7
+ require "lita/handlers/manners"
8
+
9
+ Lita::Handlers::Manners.template_root File.expand_path(
10
+ File.join("..", "..", "templates"),
11
+ __FILE__
12
+ )
@@ -0,0 +1,48 @@
1
+ module Lita
2
+ module Handlers
3
+ class Manners < Handler
4
+ route(/^(hi|hello|hey|howdy|bye|goodbye)!*$/i, :echo_command, command: true)
5
+ route(/^(hi|hello|hey|howdy|bye|goodbye)\s+@?(.+)$/i, :echo_message, command: false)
6
+ route(/^(thanks|thank\s?you|cheers)!*$/i, :thank_you_command, command: true)
7
+ route(/^(thanks|thank\s?you|cheers)\s+@?(.+)$/i, :thank_you_message, command: false)
8
+ route(/^(i'm |i am )?sorry!*$/i, :sorry_command, command: true)
9
+ route(/^(i'm |i am )?sorry\s+@?(.+)$/i, :sorry_message, command: false)
10
+
11
+ def echo_command(response, message = nil)
12
+ echo = message || response.matches[0][0]
13
+ response.reply "#{echo} #{response.user.name}"
14
+ end
15
+
16
+ def echo_message(response)
17
+ message = response.matches[0][0]
18
+ echo_command(response, message) if addressed_to_robot?(response)
19
+ end
20
+
21
+ def thank_you_command(response)
22
+ response.reply "You're welcome #{response.user.name}"
23
+ end
24
+
25
+ def thank_you_message(response)
26
+ thank_you_command(response) if addressed_to_robot?(response)
27
+ end
28
+
29
+ def sorry_command(response)
30
+ response.reply "Apology accepted #{response.user.name}"
31
+ end
32
+
33
+ def sorry_message(response)
34
+ sorry_command(response) if addressed_to_robot?(response)
35
+ end
36
+
37
+ private
38
+
39
+ def addressed_to_robot?(response)
40
+ address = response.matches[0][1].downcase
41
+ bot_name = robot.mention_name.downcase
42
+ address.downcase == bot_name
43
+ end
44
+ end
45
+
46
+ Lita.register_handler(Manners)
47
+ end
48
+ end
@@ -0,0 +1,26 @@
1
+ Gem::Specification.new do |spec|
2
+ spec.name = "lita-manners"
3
+ spec.version = "0.1.0"
4
+ spec.authors = ["neilang"]
5
+ spec.email = ["neilang@gmail.com"]
6
+ spec.description = "Makes Lita politely respond to simple hello/goodbye/thank you commands and mentions"
7
+ spec.summary = "Makes Lita politely respond to simple hello/goodbye/thank you commands and mentions"
8
+ spec.homepage = "https://github.com/neilang/lita-manners"
9
+ spec.license = "MIT"
10
+ spec.metadata = { "lita_plugin_type" => "handler" }
11
+
12
+ spec.files = `git ls-files`.split($/)
13
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
14
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
15
+ spec.require_paths = ["lib"]
16
+
17
+ spec.add_runtime_dependency "lita", ">= 4.4"
18
+
19
+ spec.add_development_dependency "bundler", "~> 1.3"
20
+ spec.add_development_dependency "pry-byebug"
21
+ spec.add_development_dependency "rake"
22
+ spec.add_development_dependency "rack-test"
23
+ spec.add_development_dependency "rspec", ">= 3.0.0"
24
+ spec.add_development_dependency "simplecov"
25
+ spec.add_development_dependency "coveralls"
26
+ end
data/locales/en.yml ADDED
@@ -0,0 +1,4 @@
1
+ en:
2
+ lita:
3
+ handlers:
4
+ manners:
@@ -0,0 +1,161 @@
1
+ require "spec_helper"
2
+
3
+ describe Lita::Handlers::Manners, lita_handler: true do
4
+ let(:user) { Lita::User.create(1, name: 'You') }
5
+
6
+ describe 'echo commands' do
7
+ it { is_expected.to route_command('hello').to(:echo_command) }
8
+ it { is_expected.to route_command('hi').to(:echo_command) }
9
+ it { is_expected.to route_command('hey').to(:echo_command) }
10
+ it { is_expected.to route_command('howdy').to(:echo_command) }
11
+ it { is_expected.to route_command('goodbye').to(:echo_command) }
12
+ it { is_expected.to route_command('bye').to(:echo_command) }
13
+
14
+ it { is_expected.to route_command('hello!').to(:echo_command) }
15
+ it { is_expected.to route_command('hi!').to(:echo_command) }
16
+ it { is_expected.to route_command('hey!').to(:echo_command) }
17
+ it { is_expected.to route_command('howdy!').to(:echo_command) }
18
+ it { is_expected.to route_command('goodbye!').to(:echo_command) }
19
+ it { is_expected.to route_command('bye!').to(:echo_command) }
20
+
21
+ it 'replies with the user name' do
22
+ send_command('Hello', as: user)
23
+ expect(replies.last).to eq 'Hello You'
24
+ end
25
+
26
+ it 'replies without punctuation' do
27
+ send_command('Hello!', as: user)
28
+ expect(replies.last).to eq 'Hello You'
29
+ end
30
+ end
31
+
32
+ describe 'echo messages' do
33
+ it { is_expected.to route('hello lita').to(:echo_message) }
34
+ it { is_expected.to route('hi lita').to(:echo_message) }
35
+ it { is_expected.to route('hey lita').to(:echo_message) }
36
+ it { is_expected.to route('howdy lita').to(:echo_message) }
37
+ it { is_expected.to route('goodbye lita').to(:echo_message) }
38
+ it { is_expected.to route('bye lita').to(:echo_message) }
39
+
40
+ it { is_expected.to route('hello @lita').to(:echo_message) }
41
+ it { is_expected.to route('hi @lita').to(:echo_message) }
42
+ it { is_expected.to route('hey @lita').to(:echo_message) }
43
+ it { is_expected.to route('howdy @lita').to(:echo_message) }
44
+ it { is_expected.to route('goodbye @lita').to(:echo_message) }
45
+ it { is_expected.to route('bye @lita').to(:echo_message) }
46
+
47
+ it 'replies to Hello lita' do
48
+ send_message('Hello lita', as: user)
49
+ expect(replies.last).to eq 'Hello You'
50
+ end
51
+
52
+ it 'replies to Hello @lita' do
53
+ send_message('Hello @lita', as: user)
54
+ expect(replies.last).to eq 'Hello You'
55
+ end
56
+
57
+ it 'replies to Hello LITA' do
58
+ send_message('Hello LITA', as: user)
59
+ expect(replies.last).to eq 'Hello You'
60
+ end
61
+
62
+ it 'replies only to mentions' do
63
+ send_message('Hello @someone', as: user)
64
+ expect(replies.last).to eq nil
65
+ end
66
+ end
67
+
68
+ describe 'thank you command' do
69
+ it { is_expected.to route_command('thank you').to(:thank_you_command) }
70
+ it { is_expected.to route_command('thankyou').to(:thank_you_command) }
71
+ it { is_expected.to route_command('thanks').to(:thank_you_command) }
72
+ it { is_expected.to route_command('cheers').to(:thank_you_command) }
73
+
74
+ it { is_expected.to route_command('thank you!').to(:thank_you_command) }
75
+ it { is_expected.to route_command('thankyou!').to(:thank_you_command) }
76
+ it { is_expected.to route_command('thanks!').to(:thank_you_command) }
77
+ it { is_expected.to route_command('cheers!').to(:thank_you_command) }
78
+
79
+ it 'replies with the user name' do
80
+ send_command('thank you', as: user)
81
+ expect(replies.last).to eq 'You\'re welcome You'
82
+ end
83
+ end
84
+
85
+ describe 'thank you message' do
86
+ it { is_expected.to route('thank you lita').to(:thank_you_message) }
87
+ it { is_expected.to route('thankyou lita').to(:thank_you_message) }
88
+ it { is_expected.to route('thanks lita').to(:thank_you_message) }
89
+ it { is_expected.to route('cheers lita').to(:thank_you_message) }
90
+
91
+ it { is_expected.to route('thank you @lita').to(:thank_you_message) }
92
+ it { is_expected.to route('thankyou @lita').to(:thank_you_message) }
93
+ it { is_expected.to route('thanks @lita').to(:thank_you_message) }
94
+ it { is_expected.to route('cheers @lita').to(:thank_you_message) }
95
+
96
+ it 'replies to thank you lita' do
97
+ send_message('thank you lita', as: user)
98
+ expect(replies.last).to eq 'You\'re welcome You'
99
+ end
100
+
101
+ it 'replies to thank you @lita' do
102
+ send_message('thank you @lita', as: user)
103
+ expect(replies.last).to eq 'You\'re welcome You'
104
+ end
105
+
106
+ it 'replies to thank you LITA' do
107
+ send_message('thank you LITA', as: user)
108
+ expect(replies.last).to eq 'You\'re welcome You'
109
+ end
110
+
111
+ it 'replies only to mentions' do
112
+ send_message('thank you @someone', as: user)
113
+ expect(replies.last).to eq nil
114
+ end
115
+ end
116
+
117
+ describe "sorry command" do
118
+ it { is_expected.to route_command('sorry').to(:sorry_command) }
119
+ it { is_expected.to route_command('I am sorry').to(:sorry_command) }
120
+ it { is_expected.to route_command('I\'m sorry').to(:sorry_command) }
121
+
122
+ it { is_expected.to route_command('sorry!').to(:sorry_command) }
123
+ it { is_expected.to route_command('I am sorry!').to(:sorry_command) }
124
+ it { is_expected.to route_command('I\'m sorry!').to(:sorry_command) }
125
+
126
+ it 'replies with the user name' do
127
+ send_command('sorry', as: user)
128
+ expect(replies.last).to eq 'Apology accepted You'
129
+ end
130
+ end
131
+
132
+ describe "sorry message" do
133
+ it { is_expected.to route('sorry lita').to(:sorry_message) }
134
+ it { is_expected.to route('I am sorry lita').to(:sorry_message) }
135
+ it { is_expected.to route('I\'m sorry lita').to(:sorry_message) }
136
+
137
+ it { is_expected.to route('sorry @lita').to(:sorry_message) }
138
+ it { is_expected.to route('I am sorry @lita').to(:sorry_message) }
139
+ it { is_expected.to route('I\'m sorry @lita').to(:sorry_message) }
140
+
141
+ it 'replies to sorry lita' do
142
+ send_message('sorry lita', as: user)
143
+ expect(replies.last).to eq 'Apology accepted You'
144
+ end
145
+
146
+ it 'replies to sorry @lita' do
147
+ send_message('sorry @lita', as: user)
148
+ expect(replies.last).to eq 'Apology accepted You'
149
+ end
150
+
151
+ it 'replies to sorry LITA' do
152
+ send_message('sorry LITA', as: user)
153
+ expect(replies.last).to eq 'Apology accepted You'
154
+ end
155
+
156
+ it 'replies only to mentions' do
157
+ send_message('sorry @someone', as: user)
158
+ expect(replies.last).to eq nil
159
+ end
160
+ end
161
+ end
@@ -0,0 +1,14 @@
1
+ require "simplecov"
2
+ require "coveralls"
3
+ SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
4
+ SimpleCov::Formatter::HTMLFormatter,
5
+ Coveralls::SimpleCov::Formatter
6
+ ]
7
+ SimpleCov.start { add_filter "/spec/" }
8
+
9
+ require "lita-manners"
10
+ require "lita/rspec"
11
+
12
+ # A compatibility mode is provided for older plugins upgrading from Lita 3. Since this plugin
13
+ # was generated with Lita 4, the compatibility mode should be left disabled.
14
+ Lita.version_3_compatibility_mode = false
File without changes
metadata ADDED
@@ -0,0 +1,174 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: lita-manners
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - neilang
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-07-24 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: lita
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '4.4'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '4.4'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.3'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.3'
41
+ - !ruby/object:Gem::Dependency
42
+ name: pry-byebug
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rack-test
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rspec
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: 3.0.0
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: 3.0.0
97
+ - !ruby/object:Gem::Dependency
98
+ name: simplecov
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: coveralls
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ description: Makes Lita politely respond to simple hello/goodbye/thank you commands
126
+ and mentions
127
+ email:
128
+ - neilang@gmail.com
129
+ executables: []
130
+ extensions: []
131
+ extra_rdoc_files: []
132
+ files:
133
+ - ".gitignore"
134
+ - ".travis.yml"
135
+ - Gemfile
136
+ - LICENSE.md
137
+ - README.md
138
+ - Rakefile
139
+ - lib/lita-manners.rb
140
+ - lib/lita/handlers/manners.rb
141
+ - lita-manners.gemspec
142
+ - locales/en.yml
143
+ - spec/lita/handlers/manners_spec.rb
144
+ - spec/spec_helper.rb
145
+ - templates/.gitkeep
146
+ homepage: https://github.com/neilang/lita-manners
147
+ licenses:
148
+ - MIT
149
+ metadata:
150
+ lita_plugin_type: handler
151
+ post_install_message:
152
+ rdoc_options: []
153
+ require_paths:
154
+ - lib
155
+ required_ruby_version: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - ">="
158
+ - !ruby/object:Gem::Version
159
+ version: '0'
160
+ required_rubygems_version: !ruby/object:Gem::Requirement
161
+ requirements:
162
+ - - ">="
163
+ - !ruby/object:Gem::Version
164
+ version: '0'
165
+ requirements: []
166
+ rubyforge_project:
167
+ rubygems_version: 2.4.5
168
+ signing_key:
169
+ specification_version: 4
170
+ summary: Makes Lita politely respond to simple hello/goodbye/thank you commands and
171
+ mentions
172
+ test_files:
173
+ - spec/lita/handlers/manners_spec.rb
174
+ - spec/spec_helper.rb