lita-nerf-war 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +31 -0
- data/Gemfile +3 -0
- data/README.md +88 -0
- data/Rakefile +6 -0
- data/lib/lita-nerf-war.rb +13 -0
- data/lib/lita/handlers/nerf_war.rb +34 -0
- data/lib/nerf_war.rb +72 -0
- data/lita-nerf-war.gemspec +24 -0
- data/locales/en.yml +20 -0
- data/spec/lita/handlers/nerf_war_spec.rb +4 -0
- data/spec/spec_helper.rb +6 -0
- data/templates/.gitkeep +0 -0
- metadata +143 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 0816c43813252aa3b6c2aac9c9310ed213bae09f
|
4
|
+
data.tar.gz: 1b5f7c98ce0ddea8580b53070edda57adde343d3
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 71e33cba98d8a28086c6ea22468b9ca468b062701c7a79ba44971f9353f18ef57a029116a2724234e96ada0350db6c17c71e64fba91b212c905324ff34c05f2b
|
7
|
+
data.tar.gz: a7b529441f2183cb66fd6d02e50ab0d8b37d87c9288bcda561624af2a72e1efe570f546f03ea29d9deabe02fc4896ae658499d6cf2835b21ef5e805735a31dc3
|
data/.gitignore
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
*.rbc
|
2
|
+
capybara-*.html
|
3
|
+
.rspec
|
4
|
+
/log
|
5
|
+
/tmp
|
6
|
+
/db/*.sqlite3
|
7
|
+
/public/system
|
8
|
+
/coverage/
|
9
|
+
/spec/tmp
|
10
|
+
**.orig
|
11
|
+
rerun.txt
|
12
|
+
pickle-email-*.html
|
13
|
+
|
14
|
+
# TODO Comment out these rules if you are OK with secrets being uploaded to the repo
|
15
|
+
config/initializers/secret_token.rb
|
16
|
+
config/secrets.yml
|
17
|
+
|
18
|
+
## Environment normalisation:
|
19
|
+
/.bundle
|
20
|
+
/vendor/bundle
|
21
|
+
|
22
|
+
# these should all be checked in to normalise the environment:
|
23
|
+
# Gemfile.lock, .ruby-version, .ruby-gemset
|
24
|
+
|
25
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
26
|
+
.rvmrc
|
27
|
+
|
28
|
+
# if using bower-rails ignore default bower_components path bower.json files
|
29
|
+
/vendor/assets/bower_components
|
30
|
+
*.bowerrc
|
31
|
+
bower.json
|
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,88 @@
|
|
1
|
+
# lita-nerf-war
|
2
|
+
|
3
|
+
Nerf guns at work are great. Want to get someone's attention? Shoot them with a dart -- it works great. But eventually someone complains and the dart guns end up in a drawer somewhere. End of the fun right? Wrong!
|
4
|
+
Virtualization isn't just for servers any longer. Now you can virtualize your nerf war too!
|
5
|
+
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add lita-nerf-war to your Lita instance's Gemfile:
|
10
|
+
|
11
|
+
``` ruby
|
12
|
+
gem "lita-nerf-war"
|
13
|
+
```
|
14
|
+
|
15
|
+
## Configuration
|
16
|
+
|
17
|
+
You don't need to configure anything to have your very own nerf war but where's the fun in that? While ```lita-nerf-war``` does provide an initial set of snarky results, you can increase the fun factor by customizing the messages by specifying your own set of messages.
|
18
|
+
|
19
|
+
Create a yaml file within your bot's directory structure and set ```config.handlers.nerf_war.target_file``` to the full path to that file:
|
20
|
+
|
21
|
+
```
|
22
|
+
# lita-nerf-war
|
23
|
+
config.handlers.nerf_war.target_file = File.expand_path(File.join(File.dirname(__FILE__), "targets.yml"))
|
24
|
+
config.handlers.nerf_war.custom_message_chance = 50
|
25
|
+
|
26
|
+
```
|
27
|
+
|
28
|
+
A sample yaml file might look like this:
|
29
|
+
|
30
|
+
```
|
31
|
+
en:
|
32
|
+
lita:
|
33
|
+
handlers:
|
34
|
+
nerf_war:
|
35
|
+
targets:
|
36
|
+
- a hit in the head.
|
37
|
+
- a shot to the heart.
|
38
|
+
- ...right in the arm.
|
39
|
+
- ouch right in the eye!
|
40
|
+
```
|
41
|
+
|
42
|
+
Add your own brand of wit and wisdom to the ```targets``` key.
|
43
|
+
|
44
|
+
Want to troll your coworkers? Make one of them miss most of the time by adding a ```specific_targets``` key:
|
45
|
+
|
46
|
+
```
|
47
|
+
en:
|
48
|
+
lita:
|
49
|
+
handlers:
|
50
|
+
nerf_war:
|
51
|
+
specific_targets:
|
52
|
+
someuser:
|
53
|
+
default:
|
54
|
+
- "Never gonna give you up\nNever gonna let you down\nNever gonna run around and desert you..."
|
55
|
+
jeff:
|
56
|
+
- ... and misses!
|
57
|
+
targets:
|
58
|
+
- a hit in the head.
|
59
|
+
- a shot to the heart.
|
60
|
+
- ...right in the arm.
|
61
|
+
- ouch right in the eye!
|
62
|
+
```
|
63
|
+
|
64
|
+
Note that ```someuser``` is a person's [Slack](https://slack.com/) username, while the target's name is whatever you want to match. On our team, we tend to refer to people by their first name, so that's how the targets are set up. Also note that ```someuser``` has a special default messages -- but you can specify more than one. The likelihood of a user's default messages being used versus one of the standard messages is controlled by ```config.handlers.nerf_war.custom_message_chance```. The default is 50 (50%).
|
65
|
+
|
66
|
+
|
67
|
+
## Usage
|
68
|
+
|
69
|
+
In a channel where your Lita bot is a member, the command ```nerf <user>```, and your bot will reply with a shooting message and a snarky result:
|
70
|
+
|
71
|
+
```nerf stewart```
|
72
|
+
|
73
|
+
will produce something like:
|
74
|
+
|
75
|
+
```<your user name> shoots a dart at Stewart: gun jammed```
|
76
|
+
|
77
|
+
You can also specify your favorite shooting device:
|
78
|
+
|
79
|
+
```nerf joe with a bazooka```
|
80
|
+
|
81
|
+
will produce something like:
|
82
|
+
|
83
|
+
```<your user name> shoots a bazooka at joe: ouch right in the eye!```
|
84
|
+
|
85
|
+
For those really intense fire fights, you can throw a nuke:
|
86
|
+
|
87
|
+
```nuke everyone```
|
88
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
require "lita"
|
2
|
+
|
3
|
+
Lita.load_locales Dir[File.expand_path(
|
4
|
+
File.join("..", "..", "locales", "*.yml"), __FILE__
|
5
|
+
)]
|
6
|
+
|
7
|
+
require 'nerf_war'
|
8
|
+
require "lita/handlers/nerf_war"
|
9
|
+
|
10
|
+
Lita::Handlers::NerfWar.template_root File.expand_path(
|
11
|
+
File.join("..", "..", "templates"),
|
12
|
+
__FILE__
|
13
|
+
)
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module Lita
|
2
|
+
module Handlers
|
3
|
+
class NerfWar < Handler
|
4
|
+
|
5
|
+
config :target_file, type: String, required: false
|
6
|
+
config :custom_message_chance, type: Integer, required: false, default: 50
|
7
|
+
|
8
|
+
attr_accessor :target
|
9
|
+
attr_accessor :weapon
|
10
|
+
|
11
|
+
route %r{nerf\s(\w+)\s*(.*)}i, :nerf, help: { "nerf <user>..." => "shoots user with a virtual dart"}
|
12
|
+
route %r{nuke\s(\w+)\s*(.*)}i, :nuke, help: { "nuke <user>..." => "for those really bad days"}
|
13
|
+
|
14
|
+
def nerf(response)
|
15
|
+
Lita.load_locales config.target_file unless config.target_file.nil?
|
16
|
+
set_params(response)
|
17
|
+
::NerfWar.new(response, self.target, self.weapon, config.custom_message_chance).nerf()
|
18
|
+
end
|
19
|
+
|
20
|
+
def nuke(response)
|
21
|
+
set_params(response)
|
22
|
+
::NerfWar.new(response, self.target, self.weapon, config.custom_message_chance).nuke
|
23
|
+
end
|
24
|
+
|
25
|
+
def set_params(response)
|
26
|
+
self.target = response.matches[0][0]
|
27
|
+
self.weapon = response.matches[0][1]
|
28
|
+
self.weapon.slice!('with ') if self.weapon.start_with?('with ')
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
Lita.register_handler(NerfWar)
|
33
|
+
end
|
34
|
+
end
|
data/lib/nerf_war.rb
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
class NerfWar
|
2
|
+
|
3
|
+
BURN_UNITS = 'http://en.wikipedia.org/wiki/List_of_burn_centers_in_the_United_States'
|
4
|
+
FLAME_WEAPONS = ['flamethrower', 'flame thrower' 'napalm', 'willy pete', 'willie pete']
|
5
|
+
|
6
|
+
def initialize(response, target, weapon, custom_message_chance)
|
7
|
+
@response = response
|
8
|
+
@user = @response.user
|
9
|
+
@target = target
|
10
|
+
@weapon = weapon
|
11
|
+
@weapon = 'a dart' if weapon.nil? || weapon.empty?
|
12
|
+
|
13
|
+
@generic_targets = I18n.translate('lita.handlers.nerf_war.targets')
|
14
|
+
end
|
15
|
+
|
16
|
+
def nerf
|
17
|
+
return if you_will_put_your_eye_out?
|
18
|
+
return if we_never_forget_vlad?
|
19
|
+
|
20
|
+
@response.reply shooting_message + ': ' + snarky_result
|
21
|
+
@response.reply BURN_UNITS if is_flame_weapon?
|
22
|
+
end
|
23
|
+
|
24
|
+
def nuke
|
25
|
+
@response.reply ["#{@user.name} tosses a nuke into the room", "http://www.dudeiwantthat.com/omg/fools/nerf-nuke-12043.jpg"]
|
26
|
+
end
|
27
|
+
|
28
|
+
def snarky_result
|
29
|
+
targets = nil
|
30
|
+
snarky_user_messages = I18n.translate("lita.handlers.nerf_war.specific_targets.#{@user.name}".downcase)
|
31
|
+
|
32
|
+
targets = snarky_user_messages[@target.to_sym] if snarky_user_messages[@target.to_sym].length > 0 rescue nil
|
33
|
+
targets ||= snarky_user_messages[:default] if snarky_user_messages[:default].length > 0 && use_custom_default? rescue nil
|
34
|
+
targets ||= @generic_targets
|
35
|
+
|
36
|
+
snarky_message = targets[rand(targets.length)]
|
37
|
+
end
|
38
|
+
|
39
|
+
def shooting_message
|
40
|
+
"#{@user.name} shoots #{@weapon} at #{@target}"
|
41
|
+
end
|
42
|
+
|
43
|
+
# chance to use a per-user default message
|
44
|
+
def use_custom_default?
|
45
|
+
rand(100) < custom_message_chance
|
46
|
+
end
|
47
|
+
|
48
|
+
def we_never_forget_vlad?
|
49
|
+
if @target.downcase == 'vlad'
|
50
|
+
@response.reply [shooting_message, "http://www.quickmeme.com/img/22/221f53ddeb8084c01d4d50c966df793d30b8392c68b7cb0a5ec50a635e01cff2.jpg"]
|
51
|
+
return true
|
52
|
+
end
|
53
|
+
false
|
54
|
+
end
|
55
|
+
|
56
|
+
def you_will_put_your_eye_out?
|
57
|
+
if is_self?
|
58
|
+
@response.reply "You'll put your eye out!"
|
59
|
+
return true
|
60
|
+
end
|
61
|
+
false
|
62
|
+
end
|
63
|
+
|
64
|
+
def is_self?
|
65
|
+
@user.name.downcase == @target.downcase
|
66
|
+
end
|
67
|
+
|
68
|
+
def is_flame_weapon?
|
69
|
+
FLAME_WEAPONS.include?(@weapon.downcase)
|
70
|
+
end
|
71
|
+
|
72
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
Gem::Specification.new do |spec|
|
2
|
+
spec.name = "lita-nerf-war"
|
3
|
+
spec.version = "0.1.2"
|
4
|
+
spec.authors = ["Jeff Paquette"]
|
5
|
+
spec.email = ["jeff@snowmoonsoftware.com"]
|
6
|
+
spec.description = "Virtual dart fights for your slack rooms"
|
7
|
+
spec.summary = "Virtual dart fights for your slack rooms"
|
8
|
+
spec.homepage = "https://github.com/snowmoonsoftware/lita-nerf-war"
|
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.3"
|
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
|
+
end
|
data/locales/en.yml
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
en:
|
2
|
+
lita:
|
3
|
+
handlers:
|
4
|
+
nerf_war:
|
5
|
+
targets:
|
6
|
+
- a hit in the head.
|
7
|
+
- a shot to the heart.
|
8
|
+
- ...right in the arm.
|
9
|
+
- ouch right in the eye!
|
10
|
+
- boop! On the nose.
|
11
|
+
- OMG call an ambulance
|
12
|
+
- WTF?! Really?
|
13
|
+
- Boom. Headshot.
|
14
|
+
- right in the...oh no no tears. Please no tears!
|
15
|
+
- ...That's gonna leave a mark.
|
16
|
+
- and misses
|
17
|
+
- gun jammed
|
18
|
+
- misfire!
|
19
|
+
- Instructions unclear. Dart stuck in foot please advise
|
20
|
+
- ... oooh pew-pew guns! I love pew-pew guns!
|
data/spec/spec_helper.rb
ADDED
data/templates/.gitkeep
ADDED
File without changes
|
metadata
ADDED
@@ -0,0 +1,143 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: lita-nerf-war
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jeff Paquette
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-03-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.3'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '4.3'
|
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
|
+
description: Virtual dart fights for your slack rooms
|
98
|
+
email:
|
99
|
+
- jeff@snowmoonsoftware.com
|
100
|
+
executables: []
|
101
|
+
extensions: []
|
102
|
+
extra_rdoc_files: []
|
103
|
+
files:
|
104
|
+
- ".gitignore"
|
105
|
+
- Gemfile
|
106
|
+
- README.md
|
107
|
+
- Rakefile
|
108
|
+
- lib/lita-nerf-war.rb
|
109
|
+
- lib/lita/handlers/nerf_war.rb
|
110
|
+
- lib/nerf_war.rb
|
111
|
+
- lita-nerf-war.gemspec
|
112
|
+
- locales/en.yml
|
113
|
+
- spec/lita/handlers/nerf_war_spec.rb
|
114
|
+
- spec/spec_helper.rb
|
115
|
+
- templates/.gitkeep
|
116
|
+
homepage: https://github.com/snowmoonsoftware/lita-nerf-war
|
117
|
+
licenses:
|
118
|
+
- MIT
|
119
|
+
metadata:
|
120
|
+
lita_plugin_type: handler
|
121
|
+
post_install_message:
|
122
|
+
rdoc_options: []
|
123
|
+
require_paths:
|
124
|
+
- lib
|
125
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
126
|
+
requirements:
|
127
|
+
- - ">="
|
128
|
+
- !ruby/object:Gem::Version
|
129
|
+
version: '0'
|
130
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
131
|
+
requirements:
|
132
|
+
- - ">="
|
133
|
+
- !ruby/object:Gem::Version
|
134
|
+
version: '0'
|
135
|
+
requirements: []
|
136
|
+
rubyforge_project:
|
137
|
+
rubygems_version: 2.4.3
|
138
|
+
signing_key:
|
139
|
+
specification_version: 4
|
140
|
+
summary: Virtual dart fights for your slack rooms
|
141
|
+
test_files:
|
142
|
+
- spec/lita/handlers/nerf_war_spec.rb
|
143
|
+
- spec/spec_helper.rb
|