X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=data%2Frbot%2Fplugins%2Funicode.rb;h=957f5bff60c2029fbe084cba27fca31cbbe53682;hb=24bb60775741d3731400f1e430ef6bf3a2e1b933;hp=9424a91e5f7bb6e51d5d41c627b194820a739912;hpb=1b00588ccc35ec749bb01c8ded6fdd732c5d3bf6;p=user%2Fhenk%2Fcode%2Fruby%2Frbot.git diff --git a/data/rbot/plugins/unicode.rb b/data/rbot/plugins/unicode.rb index 9424a91e..957f5bff 100644 --- a/data/rbot/plugins/unicode.rb +++ b/data/rbot/plugins/unicode.rb @@ -18,13 +18,13 @@ require 'jcode' require 'iconv' class UnicodePlugin < Plugin - BotConfig.register BotConfigBooleanValue.new( + Config.register Config::BooleanValue.new( 'encoding.enable', :default => true, :desc => "Support for non-ascii charsets", :on_change => Proc.new { |bot, v| reconfigure_filter(bot) }) - BotConfig.register BotConfigArrayValue.new( - 'encoding.charsets', :default => ['utf-8', 'cp1252'], + 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", :on_change => Proc.new { |bot, v| reconfigure_filter(bot) }) @@ -33,12 +33,12 @@ class UnicodePlugin < Plugin o = oenc.dup o += '//ignore' if !o.include?('/') i = iencs[0].dup - i += '//ignore' if !i.include?('/') + # i += '//ignore' if !i.include?('/') @iencs = iencs.dup @iconvs = @iencs.map { |_| Iconv.new('utf-8', _) } debug "*** o = #{o}, i = #{i}, iencs = #{iencs.inspect}" - @default_in = Iconv.new('utf-8', i) - @default_out = Iconv.new(o, 'utf-8') + @default_in = Iconv.new('utf-8//ignore', i) + @default_out = Iconv.new(o, 'utf-8//ignore') end def in(data) @@ -53,12 +53,12 @@ class UnicodePlugin < Plugin } rv = @default_in.iconv(data) if !rv - debug ">> #{rv}" + debug ">> #{rv.inspect}" return rv end def out(data) - rv = @default_out.iconv(data) + rv = @default_out.iconv(data) rescue data # XXX: yeah, i know :/ debug "<< #{rv}" rv end @@ -75,6 +75,7 @@ class UnicodePlugin < Plugin debug "cleaning up encodings" @bot.socket.filter = nil $KCODE = @old_kcode + super end def UnicodePlugin.reconfigure_filter(bot)