Files
tbd-station-14/Content.Server/Chat/Commands/LOOCCommand.cs
slarticodefast 1469b9484d Add virtual chat API methods in Shared (#40895)
* move chat stuff to shared

* refactor: using cleanup +whitespaces + xml-doc

* review

---------

Co-authored-by: pa.pecherskij <pa.pecherskij@interfax.ru>
2025-10-19 19:08:27 +00:00

43 lines
1.3 KiB
C#

using Content.Server.Chat.Systems;
using Content.Shared.Administration;
using Content.Shared.Chat;
using Robust.Shared.Console;
using Robust.Shared.Enums;
namespace Content.Server.Chat.Commands
{
[AnyCommand]
internal sealed class LOOCCommand : IConsoleCommand
{
[Dependency] private readonly IEntityManager _e = default!;
public string Command => "looc";
public string Description => "Send Local Out Of Character chat messages.";
public string Help => "looc <text>";
public void Execute(IConsoleShell shell, string argStr, string[] args)
{
if (shell.Player is not { } player)
{
shell.WriteError(Loc.GetString("shell-cannot-run-command-from-server"));
return;
}
if (player.AttachedEntity is not { Valid: true } entity)
return;
if (player.Status != SessionStatus.InGame)
return;
if (args.Length < 1)
return;
var message = string.Join(" ", args).Trim();
if (string.IsNullOrEmpty(message))
return;
_e.System<ChatSystem>().TrySendInGameOOCMessage(entity, message, InGameOOCChatType.Looc, false, shell, player);
}
}
}