summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2008-04-13 01:16:16 +0200
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2008-04-13 01:16:16 +0200
commitae22d3ad34c7626d52a5b0473b025d064f38c045 (patch)
tree3b0811a70cc5fe14753b13fc308911cec03e1546
parent1239f5f80ecae2353d78491dbbf873b801bdab7d (diff)
rfc2812: clean up channel mode handling
-rw-r--r--lib/rbot/rfc2812.rb25
1 files changed, 8 insertions, 17 deletions
diff --git a/lib/rbot/rfc2812.rb b/lib/rbot/rfc2812.rb
index f3dabf30..030d04df 100644
--- a/lib/rbot/rfc2812.rb
+++ b/lib/rbot/rfc2812.rb
@@ -1426,26 +1426,22 @@ module Irc
argv[1..-1].each { |arg|
setting = arg[0].chr
if "+-".include?(setting)
+ setting = setting == "+" ? :set : :reset
arg[1..-1].each_byte { |b|
- m = b.chr
- case m.to_sym
+ m = b.chr.intern
+ data[:modes] << [setting, m]
+ case m
when *@server.supports[:chanmodes][:typea]
- data[:modes] << [setting + m]
who_wants_params << data[:modes].length - 1
when *@server.supports[:chanmodes][:typeb]
- data[:modes] << [setting + m]
who_wants_params << data[:modes].length - 1
when *@server.supports[:chanmodes][:typec]
- if setting == "+"
- data[:modes] << [setting + m]
+ if setting == :set
who_wants_params << data[:modes].length - 1
- else
- data[:modes] << setting + m
end
when *@server.supports[:chanmodes][:typed]
- data[:modes] << setting + m
+ # Nothing to do
when *@server.supports[:prefix][:modes]
- data[:modes] << [setting + m]
who_wants_params << data[:modes].length - 1
else
warning "Unknown mode #{m} in #{serverstring.inspect}"
@@ -1463,15 +1459,10 @@ module Irc
end
data[:modes].each { |mode|
- case mode
- when Array
- set = mode[0][0].chr == "+" ? :set : :reset
- key = mode[0][1].chr.to_sym
- val = mode[1]
+ set, key, val = mode
+ if val
data[:channel].mode[key].send(set, val)
else
- set = mode[0].chr == "+" ? :set : :reset
- key = mode[1].chr.to_sym
data[:channel].mode[key].send(set)
end
} if data[:modes]