xkcd.lua: Working again, but no more queries (for now).

fortune.lua: The bad spacing annoyed me to no end. Monospaced now.
patterns.lua: Error message upon malformed patterns.
readme.md: outdated, notice
This commit is contained in:
topkecleon
2016-05-07 19:30:48 -04:00
parent d00403eb2e
commit c8e8be144f
4 changed files with 29 additions and 21 deletions

View File

@ -15,6 +15,16 @@ function patterns:action(msg)
local output = msg.reply_to_message.text or ''
local m1, m2 = msg.text:match('^/?s/(.-)/(.-)/?$')
if not m2 then return true end
local res, output = pcall(
function()
return output:gsub(m1, m2)
end
)
if res == false then
output = 'Malformed pattern!'
bindings.sendReply(self, msg, output)
return
end
output = output:gsub(m1, m2)
output = 'Did you mean:\n"' .. output:sub(1, 4000) .. '"'
bindings.sendReply(self, msg.reply_to_message, output)