lita-hal-9000 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 40021e835839280a45028f33aa431a1b9b103ab5
4
+ data.tar.gz: 63263480a9ed662235994333b0deaa9f2cad5f5b
5
+ SHA512:
6
+ metadata.gz: 0f38d8984d76e083feaccc2dfa553d94168f2719be65b12efd0e9d70c8d089bbc58192c57547f98260d4d455856f1745c6e771f344c5a9a94efbb329daecb133
7
+ data.tar.gz: cda449c562da5777eeb3973c7179488908132a3804beed1db327fb5d4230fa5e028602c90435264726a2ba7e378673b8f7c524eb9f3098ece372193a7f7e71dd
data/.gitignore ADDED
@@ -0,0 +1,18 @@
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
18
+ *.swp
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 ADDED
@@ -0,0 +1,19 @@
1
+ Copyright (c) 2014 Arthur Maltson
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/README.md ADDED
@@ -0,0 +1,24 @@
1
+ # lita-hal-9000
2
+
3
+ TODO: Add a description of the plugin.
4
+
5
+ ## Installation
6
+
7
+ Add lita-hal-9000 to your Lita instance's Gemfile:
8
+
9
+ ``` ruby
10
+ gem "lita-hal-9000"
11
+ ```
12
+
13
+
14
+ ## Configuration
15
+
16
+ TODO: Describe any configuration attributes the plugin exposes.
17
+
18
+ ## Usage
19
+
20
+ TODO: Describe the plugin's features and how to use them.
21
+
22
+ ## License
23
+
24
+ [MIT](http://opensource.org/licenses/MIT)
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,7 @@
1
+ require "lita"
2
+
3
+ Lita.load_locales Dir[File.expand_path(
4
+ File.join("..", "..", "locales", "*.yml"), __FILE__
5
+ )]
6
+
7
+ require "lita/handlers/hal_9000"
@@ -0,0 +1,38 @@
1
+ module Lita
2
+ module Handlers
3
+ class Hal9000 < Handler
4
+ on(:unhandled_message) do |payload|
5
+ handle_unhandled(payload: payload)
6
+ end
7
+
8
+ def handle_unhandled(payload:)
9
+ message = payload[:message]
10
+ if should_reply?(message: message)
11
+ target = reply_target(message: message)
12
+ robot.send_message(target, format_reply(
13
+ message: message))
14
+ end
15
+ end
16
+
17
+ def should_reply?(message:)
18
+ message.command? && message.match(/^@#{robot.name}/)
19
+ end
20
+
21
+ def reply_target(message:)
22
+ if message.source.private_message
23
+ Source.new(user: message.user, private_message: true)
24
+ else
25
+ Source.new(room: message.source.room)
26
+ end
27
+ end
28
+
29
+ def format_reply(message:)
30
+ "I'm sorry, I can't do that @#{message.user.mention_name} " \
31
+ "http://bit.ly/11wwIP2"
32
+ end
33
+
34
+ end
35
+
36
+ Lita.register_handler(Hal9000)
37
+ end
38
+ end
@@ -0,0 +1,27 @@
1
+ Gem::Specification.new do |spec|
2
+ spec.name = "lita-hal-9000"
3
+ spec.version = "0.1.0"
4
+ spec.authors = ["Arthur Maltson"]
5
+ spec.email = ["arthur@maltson.com"]
6
+ spec.description = "Lita handler to make your bot more like HAL-9000"
7
+ spec.summary = %q{This is a Lita handler that listens for the
8
+ :unhandled_message event. If the unhandled message is a command to
9
+ the bot, the bot will output a HAL-9000 like message.}
10
+ spec.homepage = "https://github.com/amaltson/lita-hal-9000"
11
+ spec.license = "MIT"
12
+ spec.metadata = { "lita_plugin_type" => "handler" }
13
+
14
+ spec.files = `git ls-files`.split($/)
15
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
16
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
17
+ spec.require_paths = ["lib"]
18
+
19
+ spec.add_runtime_dependency "lita", ">= 4.0"
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.3"
22
+ spec.add_development_dependency "rake"
23
+ spec.add_development_dependency "rack-test"
24
+ spec.add_development_dependency "rspec", ">= 3.0.0"
25
+ spec.add_development_dependency "simplecov"
26
+ spec.add_development_dependency "coveralls"
27
+ end
data/locales/en.yml ADDED
@@ -0,0 +1,4 @@
1
+ en:
2
+ lita:
3
+ handlers:
4
+ hal_9000:
@@ -0,0 +1,19 @@
1
+ require "spec_helper"
2
+
3
+ describe Lita::Handlers::Hal9000, lita_handler: true do
4
+ it { is_expected.to route_event(:unhandled_message) }
5
+
6
+ it 'does HAL message if unknown command' do
7
+ send_command('unknown-command')
8
+ expect(replies.last).to eq(
9
+ "I'm sorry, I can't do that @Test User http://bit.ly/11wwIP2")
10
+ end
11
+
12
+ it 'does HAL message using mention name' do
13
+ john = Lita::User.create(123, name: 'John Smith', mention_name: 'john')
14
+ send_command('unknown-command', as: john)
15
+ expect(replies.last).to eq(
16
+ "I'm sorry, I can't do that @john http://bit.ly/11wwIP2")
17
+ end
18
+
19
+ 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-hal-9000"
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
metadata ADDED
@@ -0,0 +1,159 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: lita-hal-9000
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Arthur Maltson
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-11-19 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.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '4.0'
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: rake
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: rack-test
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: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: 3.0.0
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: 3.0.0
83
+ - !ruby/object:Gem::Dependency
84
+ name: simplecov
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: coveralls
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
+ description: Lita handler to make your bot more like HAL-9000
112
+ email:
113
+ - arthur@maltson.com
114
+ executables: []
115
+ extensions: []
116
+ extra_rdoc_files: []
117
+ files:
118
+ - ".gitignore"
119
+ - ".travis.yml"
120
+ - Gemfile
121
+ - LICENSE
122
+ - README.md
123
+ - Rakefile
124
+ - lib/lita-hal-9000.rb
125
+ - lib/lita/handlers/hal_9000.rb
126
+ - lita-hal-9000.gemspec
127
+ - locales/en.yml
128
+ - spec/lita/handlers/hal_9000_spec.rb
129
+ - spec/spec_helper.rb
130
+ homepage: https://github.com/amaltson/lita-hal-9000
131
+ licenses:
132
+ - MIT
133
+ metadata:
134
+ lita_plugin_type: handler
135
+ post_install_message:
136
+ rdoc_options: []
137
+ require_paths:
138
+ - lib
139
+ required_ruby_version: !ruby/object:Gem::Requirement
140
+ requirements:
141
+ - - ">="
142
+ - !ruby/object:Gem::Version
143
+ version: '0'
144
+ required_rubygems_version: !ruby/object:Gem::Requirement
145
+ requirements:
146
+ - - ">="
147
+ - !ruby/object:Gem::Version
148
+ version: '0'
149
+ requirements: []
150
+ rubyforge_project:
151
+ rubygems_version: 2.2.2
152
+ signing_key:
153
+ specification_version: 4
154
+ summary: This is a Lita handler that listens for the :unhandled_message event. If
155
+ the unhandled message is a command to the bot, the bot will output a HAL-9000 like
156
+ message.
157
+ test_files:
158
+ - spec/lita/handlers/hal_9000_spec.rb
159
+ - spec/spec_helper.rb