2021-11-26 16:38:17 +00:00
|
|
|
--string purifier library
|
|
|
|
local purify = {}
|
|
|
|
purify.purify_pings = function(msg,input)
|
2022-05-20 18:20:49 +00:00
|
|
|
local text = input
|
|
|
|
while text:match("<@(%D*)(%d*)>") do
|
|
|
|
local obj,id = text:match("<@(%D*)(%d*)>")
|
|
|
|
local substitution = ""
|
|
|
|
if obj:match("!") then
|
|
|
|
local member = msg.guild:getMember(id)
|
|
|
|
if member then
|
|
|
|
substitution = "@"..member.name
|
|
|
|
end
|
|
|
|
elseif obj:match("&") then
|
|
|
|
local role = msg.guild:getRole(id)
|
|
|
|
if role then
|
|
|
|
substitution = "@"..role.name
|
|
|
|
end
|
|
|
|
end
|
|
|
|
if substitution == "" then
|
|
|
|
substitution = "<\\@"..obj..id..">"
|
|
|
|
end
|
|
|
|
text = text:gsub("<@(%D*)"..id..">",substitution)
|
2021-11-26 16:38:17 +00:00
|
|
|
end
|
2022-05-20 21:21:23 +00:00
|
|
|
text = text:gsub("@everyone","")
|
|
|
|
text = text:gsub("@here","")
|
2022-05-20 18:20:49 +00:00
|
|
|
return text
|
2021-11-26 16:38:17 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
purify.purify_escapes = function(text)
|
2022-05-20 18:20:49 +00:00
|
|
|
local match = "([%(%)%.%%%+%-%*%?%[%]%^%$])"
|
|
|
|
return text:gsub(match,"%%%1")
|
2021-11-26 16:38:17 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
return purify
|