lita-ambush 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/.travis.yml +8 -0
- data/Gemfile +3 -0
- data/LICENSE +19 -0
- data/README.md +45 -0
- data/Rakefile +6 -0
- data/lib/lita/handlers/ambush.rb +35 -0
- data/lib/lita-ambush.rb +12 -0
- data/lita-ambush.gemspec +26 -0
- data/locales/en.yml +4 -0
- data/spec/lita/handlers/ambush_spec.rb +63 -0
- data/spec/spec_helper.rb +14 -0
- data/templates/.gitkeep +0 -0
- metadata +177 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: a39a401d61432161c983804ae906bf6bd68a72bd
|
4
|
+
data.tar.gz: aba8aee042fec23f6074b762f97923e2434f503c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 4429a15dcfbd1ca8b7d72a1a626e21b62da3bea8ab7d1ccab6e71fa844e127ad009726e602e772af5e8eea01ae1d7bf1fcfa29a3399a15151e495f8c2f2b4935
|
7
|
+
data.tar.gz: e7ee310ae3171c394a3069bdab252a1314690e019abf650d8c1c5e5340783d21fb1edd9eb89dbfe1175b5fc46eb14618aa893b167a49fe15b737bdd61d8dbb0a
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
Copyright (c) 2015 JJ Asghar
|
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,45 @@
|
|
1
|
+
# lita-ambush
|
2
|
+
|
3
|
+
|
4
|
+
**lita-ambush** is a handler for [Lita](http://lita.io/) that stores messages for a user and displays
|
5
|
+
them the next time they say something.
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add lita-ambush to your Lita instance's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem "lita-ambush"
|
13
|
+
```
|
14
|
+
|
15
|
+
## Configuration
|
16
|
+
|
17
|
+
### Optional attributes
|
18
|
+
|
19
|
+
Still TODO
|
20
|
+
* `preview_join_messages` (Symbol) - Post a message for the user when they
|
21
|
+
just join the room. Options are `:on`, and `:off`. Default: `:off`.
|
22
|
+
|
23
|
+
### Example
|
24
|
+
|
25
|
+
Still TODO
|
26
|
+
```
|
27
|
+
Lita.configure do |config|
|
28
|
+
config.handlers.ambush.preview_join_messages = :off
|
29
|
+
end
|
30
|
+
```
|
31
|
+
|
32
|
+
## Usage
|
33
|
+
|
34
|
+
```
|
35
|
+
user1> lita ambush user2: Ohai! You forgot your card at lunch!
|
36
|
+
Lita> Ambush Prepared
|
37
|
+
User2 joined the channel
|
38
|
+
Lita> User2 you have 1 message(s) waiting (Still TODO)
|
39
|
+
user2> That was a great lunch!
|
40
|
+
Lita> user2: while you were out, user1 said: Ohai! You forgot your card at lunch!
|
41
|
+
```
|
42
|
+
|
43
|
+
## License
|
44
|
+
|
45
|
+
[MIT](http://opensource.org/licenses/MIT)
|
data/Rakefile
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
|
3
|
+
module Lita
|
4
|
+
module Handlers
|
5
|
+
class Ambush < Handler
|
6
|
+
|
7
|
+
route(/^ambush:\s+(\S+):\s(.+)/, :ambush, command: true)
|
8
|
+
route(/./, :response)
|
9
|
+
|
10
|
+
def ambush(request)
|
11
|
+
store_hash = {
|
12
|
+
time: Time.now.to_i,
|
13
|
+
msg: request.matches[0][1],
|
14
|
+
ambusher: request.user.name
|
15
|
+
}.to_yaml
|
16
|
+
redis.lpush(request.matches[0][0],store_hash)
|
17
|
+
request.reply("#{request.user.name} I've stored the ambush")
|
18
|
+
end
|
19
|
+
|
20
|
+
def response(request)
|
21
|
+
unless request.message.body.start_with? "ambush"
|
22
|
+
stored_yaml = redis.rpop(request.user.name)
|
23
|
+
while not stored_yaml.nil? do
|
24
|
+
outputted_yaml=YAML.load(stored_yaml)
|
25
|
+
request.reply("#{request.user.name}: While you were out, #{outputted_yaml[:ambusher]} said: #{outputted_yaml[:msg]}")
|
26
|
+
stored_yaml = redis.rpop(request.user.name)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
|
33
|
+
Lita.register_handler(Ambush)
|
34
|
+
end
|
35
|
+
end
|
data/lib/lita-ambush.rb
ADDED
@@ -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/ambush"
|
8
|
+
|
9
|
+
Lita::Handlers::Ambush.template_root File.expand_path(
|
10
|
+
File.join("..", "..", "templates"),
|
11
|
+
__FILE__
|
12
|
+
)
|
data/lita-ambush.gemspec
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
Gem::Specification.new do |spec|
|
2
|
+
spec.name = "lita-ambush"
|
3
|
+
spec.version = "1.0.0"
|
4
|
+
spec.authors = ["JJ Asghar","Chris Baker","Greg Kitson"]
|
5
|
+
spec.email = ["jjasghar@gmail.com","dosman711@gmail.com","greg.kitson@gmail.com"]
|
6
|
+
spec.description = %q{Allow lita to ambush your users}
|
7
|
+
spec.summary = %q{Allow lita store ambushs for your users, so you can leave messages in the chats for later}
|
8
|
+
spec.homepage = "http://github.com/jjasghar/lita-ambush"
|
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.2"
|
18
|
+
|
19
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
20
|
+
spec.add_development_dependency "rake"
|
21
|
+
spec.add_development_dependency "rack-test"
|
22
|
+
spec.add_development_dependency "rspec", ">= 3.0.0"
|
23
|
+
spec.add_development_dependency "simplecov"
|
24
|
+
spec.add_development_dependency "coveralls"
|
25
|
+
spec.add_development_dependency "pry"
|
26
|
+
end
|
data/locales/en.yml
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require 'yaml'
|
3
|
+
|
4
|
+
describe Lita::Handlers::Ambush, lita_handler: true do
|
5
|
+
|
6
|
+
it { is_expected.to route("ambush: user1: this is a taco!") }
|
7
|
+
|
8
|
+
it "testing the storage into redis" do
|
9
|
+
user1 = Lita::User.create(123, name: "user1")
|
10
|
+
send_command("ambush: user1: this is a taco!", as: user1)
|
11
|
+
expect(replies.last).to eq("#{user1.name} I've stored the ambush")
|
12
|
+
redis_rpop=Lita.redis.rpop("handlers:ambush:#{user1.name}")
|
13
|
+
outputted_yaml=YAML.load(redis_rpop)
|
14
|
+
expect(outputted_yaml[:time]).to be > 0
|
15
|
+
expect(outputted_yaml[:msg]).to eq('this is a taco!')
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should send store two messages" do
|
19
|
+
user1 = Lita::User.create(123, name: "user1")
|
20
|
+
send_command("ambush: user1: this is a taco!", as: user1)
|
21
|
+
send_command("ambush: user1: this is a burruto!", as: user1)
|
22
|
+
expect(replies.last).to eq("#{user1.name} I've stored the ambush")
|
23
|
+
expect(replies.last).to eq("#{user1.name} I've stored the ambush")
|
24
|
+
redis_rpop=Lita.redis.rpop("handlers:ambush:#{user1.name}")
|
25
|
+
outputted_yaml=YAML.load(redis_rpop)
|
26
|
+
expect(outputted_yaml[:msg]).to eq('this is a taco!')
|
27
|
+
redis_rpop=Lita.redis.rpop("handlers:ambush:#{user1.name}")
|
28
|
+
outputted_yaml=YAML.load(redis_rpop)
|
29
|
+
expect(outputted_yaml[:msg]).to eq('this is a burruto!')
|
30
|
+
end
|
31
|
+
|
32
|
+
it { is_expected.to route(".....") }
|
33
|
+
it { is_expected.to route("blah!") }
|
34
|
+
it { is_expected.to route("I like to dance!") }
|
35
|
+
it { is_expected.to route("this isn't what i signned up to do!") }
|
36
|
+
|
37
|
+
it "should respond with the message stored" do
|
38
|
+
user1 = Lita::User.create(123, name: "user1")
|
39
|
+
user2 = Lita::User.create(456, name: "user2")
|
40
|
+
send_command("ambush: #{user2.name}: this is a taco!", as: user1)
|
41
|
+
send_message("I like to watch Sulvester Stalone!", as: user2)
|
42
|
+
expect(replies.last).to eq("#{user2.name}: While you were out, #{user1.name} said: this is a taco!")
|
43
|
+
end
|
44
|
+
|
45
|
+
it "should do nothing with no messages" do
|
46
|
+
user1 = Lita::User.create(123, name: "user1")
|
47
|
+
user2 = Lita::User.create(456, name: "user2")
|
48
|
+
send_message("I like to watch Sulvester Stalone!", as: user2)
|
49
|
+
expect(replies.last).not_to eq("#{user2.name}: While you were out, #{user1.name} said: this is a taco!")
|
50
|
+
end
|
51
|
+
|
52
|
+
it "should respond with the multiple messages stored" do
|
53
|
+
user1 = Lita::User.create(123, name: "user1")
|
54
|
+
user2 = Lita::User.create(456, name: "user2")
|
55
|
+
send_command("ambush: #{user2.name}: this is a taco!", as: user1)
|
56
|
+
send_command("ambush: #{user2.name}: this is a burrito!", as: user1)
|
57
|
+
send_message("I like to watch Sulvester Stalone!", as: user2)
|
58
|
+
expect(replies[2]).to eq("#{user2.name}: While you were out, #{user1.name} said: this is a taco!")
|
59
|
+
expect(replies[3]).to eq("#{user2.name}: While you were out, #{user1.name} said: this is a burrito!")
|
60
|
+
end
|
61
|
+
|
62
|
+
|
63
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -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-ambush"
|
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
|
data/templates/.gitkeep
ADDED
File without changes
|
metadata
ADDED
@@ -0,0 +1,177 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: lita-ambush
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- JJ Asghar
|
8
|
+
- Chris Baker
|
9
|
+
- Greg Kitson
|
10
|
+
autorequire:
|
11
|
+
bindir: bin
|
12
|
+
cert_chain: []
|
13
|
+
date: 2015-02-28 00:00:00.000000000 Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: lita
|
17
|
+
requirement: !ruby/object:Gem::Requirement
|
18
|
+
requirements:
|
19
|
+
- - ">="
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '4.2'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
requirements:
|
26
|
+
- - ">="
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
version: '4.2'
|
29
|
+
- !ruby/object:Gem::Dependency
|
30
|
+
name: bundler
|
31
|
+
requirement: !ruby/object:Gem::Requirement
|
32
|
+
requirements:
|
33
|
+
- - "~>"
|
34
|
+
- !ruby/object:Gem::Version
|
35
|
+
version: '1.3'
|
36
|
+
type: :development
|
37
|
+
prerelease: false
|
38
|
+
version_requirements: !ruby/object:Gem::Requirement
|
39
|
+
requirements:
|
40
|
+
- - "~>"
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: '1.3'
|
43
|
+
- !ruby/object:Gem::Dependency
|
44
|
+
name: rake
|
45
|
+
requirement: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - ">="
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '0'
|
50
|
+
type: :development
|
51
|
+
prerelease: false
|
52
|
+
version_requirements: !ruby/object:Gem::Requirement
|
53
|
+
requirements:
|
54
|
+
- - ">="
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: '0'
|
57
|
+
- !ruby/object:Gem::Dependency
|
58
|
+
name: rack-test
|
59
|
+
requirement: !ruby/object:Gem::Requirement
|
60
|
+
requirements:
|
61
|
+
- - ">="
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: '0'
|
64
|
+
type: :development
|
65
|
+
prerelease: false
|
66
|
+
version_requirements: !ruby/object:Gem::Requirement
|
67
|
+
requirements:
|
68
|
+
- - ">="
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: '0'
|
71
|
+
- !ruby/object:Gem::Dependency
|
72
|
+
name: rspec
|
73
|
+
requirement: !ruby/object:Gem::Requirement
|
74
|
+
requirements:
|
75
|
+
- - ">="
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: 3.0.0
|
78
|
+
type: :development
|
79
|
+
prerelease: false
|
80
|
+
version_requirements: !ruby/object:Gem::Requirement
|
81
|
+
requirements:
|
82
|
+
- - ">="
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: 3.0.0
|
85
|
+
- !ruby/object:Gem::Dependency
|
86
|
+
name: simplecov
|
87
|
+
requirement: !ruby/object:Gem::Requirement
|
88
|
+
requirements:
|
89
|
+
- - ">="
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: '0'
|
92
|
+
type: :development
|
93
|
+
prerelease: false
|
94
|
+
version_requirements: !ruby/object:Gem::Requirement
|
95
|
+
requirements:
|
96
|
+
- - ">="
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
version: '0'
|
99
|
+
- !ruby/object:Gem::Dependency
|
100
|
+
name: coveralls
|
101
|
+
requirement: !ruby/object:Gem::Requirement
|
102
|
+
requirements:
|
103
|
+
- - ">="
|
104
|
+
- !ruby/object:Gem::Version
|
105
|
+
version: '0'
|
106
|
+
type: :development
|
107
|
+
prerelease: false
|
108
|
+
version_requirements: !ruby/object:Gem::Requirement
|
109
|
+
requirements:
|
110
|
+
- - ">="
|
111
|
+
- !ruby/object:Gem::Version
|
112
|
+
version: '0'
|
113
|
+
- !ruby/object:Gem::Dependency
|
114
|
+
name: pry
|
115
|
+
requirement: !ruby/object:Gem::Requirement
|
116
|
+
requirements:
|
117
|
+
- - ">="
|
118
|
+
- !ruby/object:Gem::Version
|
119
|
+
version: '0'
|
120
|
+
type: :development
|
121
|
+
prerelease: false
|
122
|
+
version_requirements: !ruby/object:Gem::Requirement
|
123
|
+
requirements:
|
124
|
+
- - ">="
|
125
|
+
- !ruby/object:Gem::Version
|
126
|
+
version: '0'
|
127
|
+
description: Allow lita to ambush your users
|
128
|
+
email:
|
129
|
+
- jjasghar@gmail.com
|
130
|
+
- dosman711@gmail.com
|
131
|
+
- greg.kitson@gmail.com
|
132
|
+
executables: []
|
133
|
+
extensions: []
|
134
|
+
extra_rdoc_files: []
|
135
|
+
files:
|
136
|
+
- ".gitignore"
|
137
|
+
- ".travis.yml"
|
138
|
+
- Gemfile
|
139
|
+
- LICENSE
|
140
|
+
- README.md
|
141
|
+
- Rakefile
|
142
|
+
- lib/lita-ambush.rb
|
143
|
+
- lib/lita/handlers/ambush.rb
|
144
|
+
- lita-ambush.gemspec
|
145
|
+
- locales/en.yml
|
146
|
+
- spec/lita/handlers/ambush_spec.rb
|
147
|
+
- spec/spec_helper.rb
|
148
|
+
- templates/.gitkeep
|
149
|
+
homepage: http://github.com/jjasghar/lita-ambush
|
150
|
+
licenses:
|
151
|
+
- MIT
|
152
|
+
metadata:
|
153
|
+
lita_plugin_type: handler
|
154
|
+
post_install_message:
|
155
|
+
rdoc_options: []
|
156
|
+
require_paths:
|
157
|
+
- lib
|
158
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
159
|
+
requirements:
|
160
|
+
- - ">="
|
161
|
+
- !ruby/object:Gem::Version
|
162
|
+
version: '0'
|
163
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
164
|
+
requirements:
|
165
|
+
- - ">="
|
166
|
+
- !ruby/object:Gem::Version
|
167
|
+
version: '0'
|
168
|
+
requirements: []
|
169
|
+
rubyforge_project:
|
170
|
+
rubygems_version: 2.2.2
|
171
|
+
signing_key:
|
172
|
+
specification_version: 4
|
173
|
+
summary: Allow lita store ambushs for your users, so you can leave messages in the
|
174
|
+
chats for later
|
175
|
+
test_files:
|
176
|
+
- spec/lita/handlers/ambush_spec.rb
|
177
|
+
- spec/spec_helper.rb
|