Add `register_on_chat_receive_message` callback
Problem
Where there are many mods that filter which user can see which message, it becomes a tangled spider web of checks - checks that might overlap.
Practical example (also my usecase):
- mod A handles minigames, saying that users in a minigame can't interact with users in different minigames nor with the ones in the lobby
- mod B says that users in the lobby can't write when an event is in progress
- mod C says that, given condition X, some users in the lobby shouldn't receive messages from other users in the lobby
- mod D says that if you mute a player, you shouldn't see their messages
B fits into the register_on_chat_message, because I want to block the message for everyone and warn the user they can't write. A and C, it depends. D should be blocked when receiving the message.
Solutions
Add a register_on_chat_receive_message to filter messages on the receiver instead of on the sender. The callback might return the string to print, also allowing modders to modify the received message (e.g. you can't understand what someone from a different kingdom says unless you read some books, only seeing gibberish). If it returns nothing, message doesn't reach the user
Alternatives
--
Additional context
No response
Source: luanti-org/luanti