From f5abe5037242cbeb2a6747beae90d5e33295a4ef Mon Sep 17 00:00:00 2001 From: TiagoDanin Date: Mon, 13 Jun 2016 12:59:44 -0500 Subject: [PATCH 1/2] Fix and improvement in shout --- otouto/plugins/shout.lua | 34 +++++++++++++++++++--------------- otouto/utilities.lua | 3 ++- 2 files changed, 21 insertions(+), 16 deletions(-) diff --git a/otouto/plugins/shout.lua b/otouto/plugins/shout.lua index 9f68327..e8d3a88 100644 --- a/otouto/plugins/shout.lua +++ b/otouto/plugins/shout.lua @@ -24,25 +24,29 @@ function shout:action(msg) end end input = utilities.trim(input) - - if input:len() > 20 then - input = input:sub(1,20) - end - input = input:upper() + local output = '' local inc = 0 - for match in input:gmatch('([%z\1-\127\194-\244][\128-\191]*)') do - output = output .. match .. ' ' - end - output = output .. '\n' - for match in input:sub(2):gmatch('([%z\1-\127\194-\244][\128-\191]*)') do - local spacing = '' - for _ = 1, inc do - spacing = spacing .. ' ' + local ilen = 0 + for match in input:gmatch(utilities.char.utf_8) do + if ilen < 18 then + ilen = ilen + 1 + output = output .. match .. ' ' + end + end + ilen = 0 + output = output .. '\n' + for match in input:sub(2):gmatch(utilities.char.utf_8) do + if ilen < 18 then + local spacing = '' + for _ = 1, inc do + spacing = spacing .. ' ' + end + inc = inc + 1 + ilen = ilen + 1 + output = output .. match .. ' ' .. spacing .. match .. '\n' end - inc = inc + 1 - output = output .. match .. ' ' .. spacing .. match .. '\n' end output = '```\n' .. utilities.trim(output) .. '\n```' utilities.send_message(self, msg.chat.id, output, true, false, true) diff --git a/otouto/utilities.lua b/otouto/utilities.lua index c4578cd..95fd387 100755 --- a/otouto/utilities.lua +++ b/otouto/utilities.lua @@ -370,7 +370,8 @@ utilities.char = { arabic = '[\216-\219][\128-\191]', rtl_override = '‮', rtl_mark = '‏', - em_dash = '—' + em_dash = '—', + utf_8 = '([%z\1-\127\194-\244][\128-\191]*)', } return utilities From 9c8c112bb3957ce80ffae27eab3e3c1a13989ab0 Mon Sep 17 00:00:00 2001 From: TiagoDanin Date: Wed, 15 Jun 2016 14:21:12 -0500 Subject: [PATCH 2/2] Revert limit of 17 char --- otouto/plugins/shout.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/otouto/plugins/shout.lua b/otouto/plugins/shout.lua index e8d3a88..3c1af21 100644 --- a/otouto/plugins/shout.lua +++ b/otouto/plugins/shout.lua @@ -30,7 +30,7 @@ function shout:action(msg) local inc = 0 local ilen = 0 for match in input:gmatch(utilities.char.utf_8) do - if ilen < 18 then + if ilen < 20 then ilen = ilen + 1 output = output .. match .. ' ' end @@ -38,7 +38,7 @@ function shout:action(msg) ilen = 0 output = output .. '\n' for match in input:sub(2):gmatch(utilities.char.utf_8) do - if ilen < 18 then + if ilen < 19 then local spacing = '' for _ = 1, inc do spacing = spacing .. ' '