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.



67
68
69
70
71
# File 'lib/rbot/core/unicode.rb', line 67

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

Class Method Details

.reconfigure_filter(bot) ⇒ Object



80
81
82
83
84
85
86
87
88
89
90
91
92
# File 'lib/rbot/core/unicode.rb', line 80

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



73
74
75
76
77
78
# File 'lib/rbot/core/unicode.rb', line 73

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