As the title above, so basically whenever i say something like discord it will get tagged right? ######, but i want to switch it to the old [Content Deleted] by what i mean is
Do you have ######? ==> Do you have [Content Deleted]?
the problem is i have no idea on where to start, here is my current modulescript placed in chat modules.
local function run(chatService)
local function tagToContentDeleted(speakerObj, messageObj, channelName)
--what now
end
chatService:SetChatFilterMessage("tag_to_content_deleted", tagToContentDeleted)
end
return run
I wanted to use gsub with string patterns but I just couldn’t get it to work right. I had (#([^$]+)) as the pattern, but it just wasn’t working as expected.
But here’s another option that works:
function tagsToContentDeleted(text)
if string.find(text,'#') then
local new = ''
for i,v in pairs(string.split(text,' ')) do
local s = v
if string.find(v,'#') then
s = '[Content Deleted]'
end
if i > 1 then
s = ' '..s
end
new = new..s
end
return new
else
return text
end
end
Input:
'2 #a# aaa ##'
Output:
2 [Content Deleted] aaa [Content Deleted]
However, I will note that this will probably easily spam the chat, so I wouldn’t really recommend doing this in the first place.
local String = nil --This would be a reference to a string value.
String = string.gsub(String, "#+", "[ Content Deleted ]") --'String' is the input string.
Doesn’t need to be a function and you don’t need a character set (’[]’).
I made it a function so it’d be simple (imo) to implement in his script where/however needed. Thanks for letting me know I didn’t need a character set, my gsub patterns are one of those things I just throw at the wall and if it works I leave it at that.