From c3ddf1df70b225652e4e0b48157ee1e7170a010b Mon Sep 17 00:00:00 2001 From: kaeza Date: Sun, 27 Oct 2013 08:57:42 -0200 Subject: [PATCH] Quick hack to prevent those ugly "" messages. --- src/hooks.lua | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/hooks.lua b/src/hooks.lua index c142c10..362417a 100644 --- a/src/hooks.lua +++ b/src/hooks.lua @@ -6,6 +6,18 @@ mt_irc.hooks = {} mt_irc.registered_hooks = {} +-- TODO: Add proper conversion from CP1252 to UTF-8. +local stripped_chars = { } +for c = 127, 255 do + table.insert(stripped_chars, string.char(c)) +end +stripped_chars = "["..table.concat(stripped_chars, "").."]" + +local function normalize(text) + return text:gsub(stripped_chars, "") +end + + function mt_irc:doHook(conn) for name, hook in pairs(self.registered_hooks) do for _, func in pairs(hook) do @@ -36,6 +48,9 @@ end function mt_irc.hooks.chat(user, channel, message) + + message = normalize(message) + -- Strip bold, underline, and colors message = message:gsub('\2', '') message = message:gsub('\31', '')