Merge pull request #68 from TiagoDanin/Fix-Shout

Fix and improvement in shout
This commit is contained in:
Drew 2016-06-17 01:42:48 -04:00 committed by GitHub
commit fc1208af03
2 changed files with 21 additions and 16 deletions

View File

@ -24,25 +24,29 @@ function shout:action(msg)
end end
end end
input = utilities.trim(input) input = utilities.trim(input)
if input:len() > 20 then
input = input:sub(1,20)
end
input = input:upper() input = input:upper()
local output = '' local output = ''
local inc = 0 local inc = 0
for match in input:gmatch('([%z\1-\127\194-\244][\128-\191]*)') do local ilen = 0
output = output .. match .. ' ' for match in input:gmatch(utilities.char.utf_8) do
end if ilen < 20 then
output = output .. '\n' ilen = ilen + 1
for match in input:sub(2):gmatch('([%z\1-\127\194-\244][\128-\191]*)') do output = output .. match .. ' '
local spacing = '' end
for _ = 1, inc do end
spacing = spacing .. ' ' ilen = 0
output = output .. '\n'
for match in input:sub(2):gmatch(utilities.char.utf_8) do
if ilen < 19 then
local spacing = ''
for _ = 1, inc do
spacing = spacing .. ' '
end
inc = inc + 1
ilen = ilen + 1
output = output .. match .. ' ' .. spacing .. match .. '\n'
end end
inc = inc + 1
output = output .. match .. ' ' .. spacing .. match .. '\n'
end end
output = '```\n' .. utilities.trim(output) .. '\n```' output = '```\n' .. utilities.trim(output) .. '\n```'
utilities.send_message(self, msg.chat.id, output, true, false, true) utilities.send_message(self, msg.chat.id, output, true, false, true)

View File

@ -370,7 +370,8 @@ utilities.char = {
arabic = '[\216-\219][\128-\191]', arabic = '[\216-\219][\128-\191]',
rtl_override = '', rtl_override = '',
rtl_mark = '', rtl_mark = '',
em_dash = '' em_dash = '',
utf_8 = '([%z\1-\127\194-\244][\128-\191]*)',
} }
return utilities return utilities