From 6add3f5e6bc89320bb6d72e7bf0f013ccba5dc94 Mon Sep 17 00:00:00 2001 From: Er2 Date: Wed, 16 Feb 2022 10:35:11 +0300 Subject: [PATCH] update eval, pattern escape function --- src/cmds/eval.lua | 6 ++++-- src/events/ready.lua | 4 ++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/cmds/eval.lua b/src/cmds/eval.lua index 60a9655..e2dec1b 100644 --- a/src/cmds/eval.lua +++ b/src/cmds/eval.lua @@ -39,11 +39,13 @@ return { api = owner and C.api or nil, } for k,v in pairs(env) do t[k] = v end - local e, err = load(C.api.unparseArgs(msg.args), 'eval', 't', t) + local e, err = load(C.api.unparseArgs(msg.args), 'eval', 'bt', t) xpcall(function() if err then error(err) end e = tostring(e() or '...') end, function(err) e = err end) - C.api:send(msg, s .. '\n' .. e) + s = s ..'\n'.. e + s = s:gsub(C.api.token:escp(), '') + C.api:reply(msg, s) end } diff --git a/src/events/ready.lua b/src/events/ready.lua index 56fb035..0455b87 100644 --- a/src/events/ready.lua +++ b/src/events/ready.lua @@ -21,6 +21,10 @@ function table.findV(t, w) end end +function string.escp(s) + return s:gsub('[%^%$%%%(%)%.%[%]%*%+%-%?]', '%%%0') +end + function dump(t, d) if not tonumber(d) or d < 0 then d = 0 end local c = ''