Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion plugin/cleaner.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,14 @@ end)

beerchat.register_callback('on_http_receive', function(msg_data)
-- Trim spaces and newlines, add ">" to mark newlines in incoming message
msg_data.message = msg_data.message:gsub('%s+$',''):gsub('(%s)%s+','%1'):gsub('[\r\n]','\n > ')
local msg = msg_data.message
:gsub('%s+$','') -- Remove trailing space
:gsub('<:[%w_]+:%d+>','') -- Remove long emoji codes
:gsub('(%s)%s+','%1') -- Trim all whitespace
:gsub('[\r\n]','\n > ') -- Add line continuation markers
if not msg:find("[^%c%p%s]") then
-- Throw away messages that do not contain any words after cleanup
return false
end
msg_data.message = msg
end)