Basic rate limiting for chat messages (#21907)

This commit is contained in:
Pieter-Jan Briers
2023-11-27 04:08:30 +01:00
committed by GitHub
parent dbb3da9232
commit 8bf807a9b5
7 changed files with 149 additions and 1 deletions

View File

@@ -183,6 +183,9 @@ public sealed partial class ChatSystem : SharedChatSystem
return;
}
if (player != null && !_chatManager.HandleRateLimit(player))
return;
// Sus
if (player?.AttachedEntity is { Valid: true } entity && source != entity)
{
@@ -267,6 +270,9 @@ public sealed partial class ChatSystem : SharedChatSystem
if (!CanSendInGame(message, shell, player))
return;
if (player != null && !_chatManager.HandleRateLimit(player))
return;
// It doesn't make any sense for a non-player to send in-game OOC messages, whereas non-players may be sending
// in-game IC messages.
if (player?.AttachedEntity is not { Valid: true } entity || source != entity)