mirror of
https://github.com/luanti-org/luanti.git
synced 2025-08-11 17:51:04 +00:00
Add a server-sided way to remove color codes from incoming chat messages (#5948)
These code be generated by CSM, a modded client or just copy and pasted by the player. Changes - Update configuration example and setting translation file. - Remove colour codes before logging chat. - Add setting to remove colour codes before processing the chat.
This commit is contained in:
parent
07be63b287
commit
25ae0739ed
6 changed files with 25 additions and 16 deletions
|
@ -2880,12 +2880,15 @@ void Server::handleChatInterfaceEvent(ChatEvent *evt)
|
|||
}
|
||||
|
||||
std::wstring Server::handleChat(const std::string &name, const std::wstring &wname,
|
||||
const std::wstring &wmessage, bool check_shout_priv, RemotePlayer *player)
|
||||
std::wstring wmessage, bool check_shout_priv, RemotePlayer *player)
|
||||
{
|
||||
// If something goes wrong, this player is to blame
|
||||
RollbackScopeActor rollback_scope(m_rollback,
|
||||
std::string("player:") + name);
|
||||
|
||||
if (g_settings->getBool("strip_color_codes"))
|
||||
wmessage = unescape_enriched(wmessage);
|
||||
|
||||
if (player) {
|
||||
switch (player->canSendChatMessage()) {
|
||||
case RPLAYER_CHATRESULT_FLOODING: {
|
||||
|
@ -2940,7 +2943,7 @@ std::wstring Server::handleChat(const std::string &name, const std::wstring &wna
|
|||
/*
|
||||
Send the message to others
|
||||
*/
|
||||
actionstream << "CHAT: " << wide_to_narrow(line) << std::endl;
|
||||
actionstream << "CHAT: " << wide_to_narrow(unescape_enriched(line)) << std::endl;
|
||||
|
||||
std::vector<u16> clients = m_clients.getClientIDs();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue