Class: UnicodePlugin

Inherits:
CoreBotModule
  • Object
show all
Defined in:
lib/rbot/core/unicode.rb

Defined Under Namespace

Classes: UnicodeFilter

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*a) ⇒ UnicodePlugin

Returns a new instance of UnicodePlugin.



63
64
65
66
67
# File 'lib/rbot/core/unicode.rb', line 63

def initialize(*a)
    super
    @@old_kcode = $KCODE
    self.class.reconfigure_filter(@bot)
end

Class Method Details

.reconfigure_filter(bot) ⇒ Object



76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/rbot/core/unicode.rb', line 76

def UnicodePlugin.reconfigure_filter(bot)
    debug "configuring encodings"
    enable = bot.config['encoding.enable']
    if not enable
        bot.socket.filter = nil
        $KCODE = @@old_kcode
        return
    end
    charsets = bot.config['encoding.charsets']
    charsets = ['utf-8'] if charsets.empty?
    bot.socket.filter = UnicodeFilter.new(charsets[0], *charsets)
    $KCODE = 'u'
end

Instance Method Details

#cleanupObject



69
70
71
72
73
74
# File 'lib/rbot/core/unicode.rb', line 69

def cleanup
    debug "cleaning up encodings"
    @bot.socket.filter = nil
    $KCODE = @@old_kcode
    super
end