]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/commitdiff
New IRC Framework: don't raise on unknown casemap
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>
Tue, 15 Jun 2010 10:27:33 +0000 (12:27 +0200)
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>
Tue, 15 Jun 2010 11:00:17 +0000 (13:00 +0200)
This allows us to support servers that (ab)use the CASEMAPPING
to indicate the set of allowed characters for nicks (e.g. Inspire
IRCd).

lib/rbot/core/unicode.rb
lib/rbot/irc.rb

index 9d42ec2422fe7e913596c4671f3c4b303dd9dd85..ece8e64409c62598013a7f7493f89caf30d260f4 100644 (file)
@@ -10,6 +10,9 @@
 # encoding. The plugin takes care of translation to/from utf-8 on server IO,
 # if necessary (translation charsets are configurable).
 
+# TODO autoconfigure using server-provided allowed charset when these are
+# available, see also comment in irc.rb
+
 require 'iconv'
 
 class UnicodePlugin < CoreBotModule
index 07ec6c37ebf691b37c9d8b564758fa9bb719067b..326e25ef2f1d624884c6d181c11da4002e9700c2 100644 (file)
@@ -273,7 +273,13 @@ class String
   # 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
@@ -1683,6 +1689,10 @@ module Irc
             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
           }