def new_channel(name, topic=nil, users=[], fails=true)
if name.nil_or_empty?
raise "Tried to look for empty or nil channel name #{name.inspect}" if fails
return nil
end
ex = get_chan(name)
if ex
raise "Channel #{name} already exists on server #{self}" if fails
return ex
else
prefix = name[0].chr
warn "#{self} doesn't support channel prefix #{prefix}" unless @supports[:chantypes].include?(prefix)
warn "#{self} doesn't support channel names this long (#{name.length} > #{@supports[:channellen]})" unless name.length <= @supports[:channellen]
@supports[:chanlimit].keys.each { |k|
next unless k.include?(prefix)
count = 0
channel_names.each { |n|
count += 1 if k.include?(n[0])
}
warn "Already joined #{count}/#{@supports[:chanlimit][k]} channels with prefix #{k}, we may be going over server limits" if count >= @supports[:chanlimit][k]
}
chan = Channel.new(name, topic, users, :server => self)
@supports[:prefix][:modes].each { |mode|
chan.create_mode(mode, Channel::UserMode)
} if @supports[:prefix][:modes]
@supports[:chanmodes].each { |k, val|
if val
case k
when :typea
val.each { |mode|
chan.create_mode(mode, Channel::ModeTypeA)
}
when :typeb
val.each { |mode|
chan.create_mode(mode, Channel::ModeTypeB)
}
when :typec
val.each { |mode|
chan.create_mode(mode, Channel::ModeTypeC)
}
when :typed
val.each { |mode|
chan.create_mode(mode, Channel::ModeTypeD)
}
end
end
}
@channels << chan
return chan
end
end