Class: IRC::Server::Modules::Roulette
- Inherits:
-
IRC::Server::Module
- Object
- IRC::Server::Module
- IRC::Server::Modules::Roulette
- Defined in:
- lib/failirc/server/modules/Roulette.rb
Instance Attribute Summary
Attributes inherited from IRC::Server::Module
Instance Method Summary collapse
-
#initialize(server) ⇒ Roulette
constructor
A new instance of Roulette.
- #rehash ⇒ Object
- #roulette(thing, string) ⇒ Object
Methods inherited from IRC::Server::Module
Constructor Details
#initialize(server) ⇒ Roulette
Returns a new instance of Roulette.
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/failirc/server/modules/Roulette.rb', line 29 def initialize (server) @aliases = { :input => { :ROULETTE => /^ROULETTE( |$)/i, }, } @events = { :input => { :ROULETTE => self.method(:roulette), }, } super(server) end |
Instance Method Details
#rehash ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/failirc/server/modules/Roulette.rb', line 45 def rehash if tmp = @server.config.elements['config/modules/module[@name="Roulette"]/death'] @death = tmp.text else @death = 'BOOM, dickshot' end if tmp = @server.config.elements['config/modules/module[@name="Roulette"]/life'] @life = tmp.text else @life = '#{user.nick} shot but survived :(' end end |
#roulette(thing, string) ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/failirc/server/modules/Roulette.rb', line 59 def roulette (thing, string) user = thing if rand(3) == 1 @server.kill thing, eval(@death.inspect.gsub(/\\#/, '#')) else @server.clients.each_value {|client| if client.modes[:registered] @server.dispatcher.execute :notice, @server, client, eval(@life.inspect.gsub(/\\#/, '#')) end } end end |