Class: ModSpox::Handlers::Kick
- Defined in:
- lib/mod_spox/handlers/Kick.rb
Instance Method Summary collapse
-
#initialize(handlers) ⇒ Kick
constructor
A new instance of Kick.
-
#process(string) ⇒ Object
:spax!~spox@host KICK #m spox :foo.
Methods inherited from Handler
Constructor Details
#initialize(handlers) ⇒ Kick
Returns a new instance of Kick.
5 6 7 |
# File 'lib/mod_spox/handlers/Kick.rb', line 5 def initialize(handlers) handlers[:KICK] = self end |
Instance Method Details
#process(string) ⇒ Object
:spax!~spox@host KICK #m spox :foo
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/mod_spox/handlers/Kick.rb', line 9 def process(string) orig = string.dup string = string.dup begin string.slice!(0) source = string.slice!(0..string.index(' ')-1) 2.times{string.slice!(0..string.index(' '))} channel = string.slice!(0..string.index(' ')-1) string.slice!(0) kickee = string.slice!(0..string.index(' ')-1) string.slice!(0..string.index(':')) kicker = find_model(source[0..source.index('!')-1]) channel = find_model(channel) kickee = find_model(kickee) channel.remove_nick(kickee) kickee.visible = false if kickee.channels.empty? kickee.save_changes channel.save_changes return Messages::Incoming::Kick.new(orig, channel, kicker, kickee, string) rescue Object => boom Logger.warn("Failed to parse KICK message: #{orig}") raise boom end end |