# This method returns the Irc::Casemap whose name is the receiver
#
def to_irc_casemap
- Irc::Casemap.get(self) rescue raise TypeError, "Unkown Irc::Casemap #{self.inspect}"
+ begin
+ Irc::Casemap.get(self)
+ rescue
+ # raise TypeError, "Unkown Irc::Casemap #{self.inspect}"
+ error "Unkown Irc::Casemap #{self.inspect} requested, defaulting to rfc1459"
+ Irc::Casemap.get('rfc1459')
+ end
end
# This method returns a string which is the downcased version of the
def parse_isupport(line)
debug "Parsing ISUPPORT #{line.inspect}"
ar = line.split(' ')
- reparse = ""
+ reparse = []
ar.each { |en|
prekey, val = en.split('=', 2)
if prekey =~ /^-(.*)/
case key
when :casemapping
noval_warn(key, val) {
- @supports[key] = val.to_irc_casemap
+ if val == 'charset'
+ reparse << "CASEMAPPING=(charset)"
+ else
+ # TODO some servers offer non-standard CASEMAPPINGs in the form
+ # locale.charset[-options], which indicate an extended set of
+ # allowed characters (mostly for nicks). This might be supported
+ # with hooks for the unicode core module
+ @supports[key] = val.to_irc_casemap
+ end
}
when :chanlimit, :idchan, :maxlist, :targmax
noval_warn(key, val) {
@supports[key] = val
when :maxchannels
noval_warn(key, val) {
- reparse += "CHANLIMIT=(chantypes):#{val} "
+ reparse << "CHANLIMIT=(chantypes):#{val} "
}
when :maxtargets
noval_warn(key, val) {
@supports[key] = val.nil? ? true : val
end
}
- reparse.gsub!("(chantypes)",@supports[:chantypes])
- parse_isupport(reparse) unless reparse.empty?
+ unless reparse.empty?
+ reparse_str = reparse.join(" ")
+ reparse_str.gsub!("(chantypes)",@supports[:chantypes])
+ reparse_str.gsub!("(charset)",@supports[:charset] || 'rfc1459')
+ parse_isupport(reparse_str)
+ end
end
# Returns the casemap of the server.