X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=lib%2Frbot%2Fcore%2Funicode.rb;h=9d42ec2422fe7e913596c4671f3c4b303dd9dd85;hb=a1db6671fb3819b58bcc1f0494b86d3a32df747f;hp=a24a19984206ed4d54ebe06be421d56b47c50f40;hpb=5f25e65756ff3428226559e301e9074a4b660e69;p=user%2Fhenk%2Fcode%2Fruby%2Frbot.git diff --git a/lib/rbot/core/unicode.rb b/lib/rbot/core/unicode.rb index a24a1998..9d42ec24 100644 --- a/lib/rbot/core/unicode.rb +++ b/lib/rbot/core/unicode.rb @@ -4,8 +4,6 @@ # :title: Unicode plugin # # Author:: jsn (Dmitry Kim) -# Copyright:: (C) 2007 Dmitry Kim -# License:: public domain # # This plugin adds unicode-awareness to rbot. When it's loaded, all the # character strings inside of rbot are assumed to be in proper utf-8 @@ -23,6 +21,7 @@ class UnicodePlugin < CoreBotModule Config.register Config::ArrayValue.new( 'encoding.charsets', :default => ['utf-8', 'cp1252', 'iso-8859-15'], :desc => "Ordered list of iconv(3) charsets the bot should try", + :validate_item => Proc.new { |x| !!(Iconv.new('utf-8', x) rescue nil) }, :on_change => Proc.new { |bot, v| reconfigure_filter(bot) }) class UnicodeFilter @@ -64,14 +63,14 @@ class UnicodePlugin < CoreBotModule def initialize(*a) super - @old_kcode = $KCODE + @@old_kcode = $KCODE self.class.reconfigure_filter(@bot) end def cleanup debug "cleaning up encodings" @bot.socket.filter = nil - $KCODE = @old_kcode + $KCODE = @@old_kcode super end @@ -80,7 +79,7 @@ class UnicodePlugin < CoreBotModule enable = bot.config['encoding.enable'] if not enable bot.socket.filter = nil - $KCODE = @old_kcode + $KCODE = @@old_kcode return end charsets = bot.config['encoding.charsets']