Mirror of the 512mb.org bot on github (https://github.com/512mb-org/512mb.org-bot)
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
981 B
34 lines
981 B
--string purifier library
|
|
local purify = {}
|
|
purify.purify_pings = function(msg,input)
|
|
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)
|
|
end
|
|
text = text:gsub("@everyone","")
|
|
text = text:gsub("@here","")
|
|
return text
|
|
end
|
|
|
|
purify.purify_escapes = function(text)
|
|
local match = "([%(%)%.%%%+%-%*%?%[%]%^%$])"
|
|
return text:gsub(match,"%%%1")
|
|
end
|
|
|
|
return purify
|