Sha256: 02a4a21bad84cd3c94e1425b5170fdcf6f7248f3daf88236dfc6a7f6bfbb4172
Contents?: true
Size: 1.21 KB
Versions: 1
Compression:
Stored size: 1.21 KB
Contents
module Lita module Handlers class NerfWar < Handler config :target_file, type: String, required: false config :custom_message_chance, type: Integer, required: false, default: 50 attr_accessor :target attr_accessor :weapon route %r{!nerf\s(\w+)\s*(.*)}i, :nerf, help: { "!nerf <user>..." => "shoots user with a virtual dart"} route %r{!nuke\s(\w+)\s*(.*)}i, :nuke, help: { "!nuke <user>..." => "for those really bad days"} def nerf(response) Lita.load_locales config.target_file unless config.target_file.nil? set_params(response) ::NerfWar.new(response, self.target, self.weapon, config.custom_message_chance).nerf() end def nuke(response) set_params(response) ::NerfWar.new(response, self.target, self.weapon, config.custom_message_chance).nuke end def set_params(response) self.target = response.matches[0][0] self.weapon = response.matches[0][1] self.weapon.slice!('with a ') if self.weapon.start_with?('with a ') self.weapon.slice!('with ') if self.weapon.start_with?('with ') end end Lita.register_handler(NerfWar) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
lita-nerf-war-0.1.7 | lib/lita/handlers/nerf_war.rb |