How to get filtered chat text using TextChatService?

I need to process chat messages on the server-side, and the processed message then needs to be sent to the rest of the clients once it’s ready. Because of this, I need to make sure that the messages are processed only after they are filtered.

I can’t figure out for the life of me how to do this with the new TextChatService, as almost every event and callback only works on the client. I tried using TextChannel.ShouldDeliverCallback just to grab the text and always return true, but the text doesn’t seem to be filtered at that stage. I even tried testing it on a game server outside of studio, and it was still always giving the unfiltered message. The Player.Chatted event won’t work for this either, since that also gives unfiltered messages.

I’ve been trying to avoid putting chat messages through TextService:FilterStringAsync, as that would be filtering the exact same message twice as far as I can tell. Can anybody help me figure out a way to do this with the new service?

1 Like

The original Lua chat system would filter text differently for each user, hence GetChatForUserAsync(), this is to abide by policy (age group, etc), and I am going to presume the new chat system does the same.

This is likely why you cannot get a server side filtered message, because there’s not just one end-all-be-all filtered message, it’s going to be filtered differently for every user.

Unfortunately, because of how that is built, you will need to filter them twice. However, there’s likely not as much strain on the server because Roblox probably handles TextChatService filtering with more importance and speed (theory).

What are you processing the messages for that needs it to be filtered?