2021-06-09 22:19:39 +02:00
|
|
|
using Content.Client.Administration.Managers;
|
|
|
|
|
using Content.Client.Ghost;
|
2020-11-01 23:55:55 +01:00
|
|
|
using Content.Shared.Administration;
|
2019-04-13 09:45:09 +02:00
|
|
|
using Content.Shared.Chat;
|
2019-04-15 21:11:38 -06:00
|
|
|
using Robust.Client.Console;
|
|
|
|
|
using Robust.Shared.Utility;
|
2019-04-13 09:45:09 +02:00
|
|
|
|
2024-08-15 20:26:57 +02:00
|
|
|
namespace Content.Client.Chat.Managers;
|
|
|
|
|
|
|
|
|
|
internal sealed class ChatManager : IChatManager
|
2019-04-13 09:45:09 +02:00
|
|
|
{
|
2024-08-15 20:26:57 +02:00
|
|
|
[Dependency] private readonly IClientConsoleHost _consoleHost = default!;
|
|
|
|
|
[Dependency] private readonly IClientAdminManager _adminMgr = default!;
|
|
|
|
|
[Dependency] private readonly IEntitySystemManager _systems = default!;
|
2021-07-20 10:29:09 +02:00
|
|
|
|
2024-08-15 20:26:57 +02:00
|
|
|
private ISawmill _sawmill = default!;
|
2019-07-30 23:13:05 +02:00
|
|
|
|
2024-08-15 20:26:57 +02:00
|
|
|
public void Initialize()
|
|
|
|
|
{
|
|
|
|
|
_sawmill = Logger.GetSawmill("chat");
|
|
|
|
|
_sawmill.Level = LogLevel.Info;
|
|
|
|
|
}
|
2021-04-20 18:39:39 -05:00
|
|
|
|
2024-09-30 01:19:00 +13:00
|
|
|
public void SendAdminAlert(string message)
|
|
|
|
|
{
|
|
|
|
|
// See server-side manager. This just exists for shared code.
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void SendAdminAlert(EntityUid player, string message)
|
|
|
|
|
{
|
|
|
|
|
// See server-side manager. This just exists for shared code.
|
|
|
|
|
}
|
|
|
|
|
|
2024-08-15 20:26:57 +02:00
|
|
|
public void SendMessage(string text, ChatSelectChannel channel)
|
|
|
|
|
{
|
|
|
|
|
var str = text.ToString();
|
|
|
|
|
switch (channel)
|
2019-07-30 23:13:05 +02:00
|
|
|
{
|
2024-08-15 20:26:57 +02:00
|
|
|
case ChatSelectChannel.Console:
|
|
|
|
|
// run locally
|
|
|
|
|
_consoleHost.ExecuteCommand(text);
|
|
|
|
|
break;
|
2021-07-20 10:29:09 +02:00
|
|
|
|
2024-08-15 20:26:57 +02:00
|
|
|
case ChatSelectChannel.LOOC:
|
|
|
|
|
_consoleHost.ExecuteCommand($"looc \"{CommandParsing.Escape(str)}\"");
|
|
|
|
|
break;
|
2022-01-11 16:29:55 +03:00
|
|
|
|
2024-08-15 20:26:57 +02:00
|
|
|
case ChatSelectChannel.OOC:
|
|
|
|
|
_consoleHost.ExecuteCommand($"ooc \"{CommandParsing.Escape(str)}\"");
|
|
|
|
|
break;
|
2021-07-20 10:29:09 +02:00
|
|
|
|
2024-08-15 20:26:57 +02:00
|
|
|
case ChatSelectChannel.Admin:
|
|
|
|
|
_consoleHost.ExecuteCommand($"asay \"{CommandParsing.Escape(str)}\"");
|
|
|
|
|
break;
|
2021-07-20 10:29:09 +02:00
|
|
|
|
2024-08-15 20:26:57 +02:00
|
|
|
case ChatSelectChannel.Emotes:
|
|
|
|
|
_consoleHost.ExecuteCommand($"me \"{CommandParsing.Escape(str)}\"");
|
|
|
|
|
break;
|
2021-07-20 10:29:09 +02:00
|
|
|
|
2024-08-15 20:26:57 +02:00
|
|
|
case ChatSelectChannel.Dead:
|
|
|
|
|
if (_systems.GetEntitySystemOrNull<GhostSystem>() is {IsGhost: true})
|
|
|
|
|
goto case ChatSelectChannel.Local;
|
2022-10-12 01:16:23 -07:00
|
|
|
|
2024-08-15 20:26:57 +02:00
|
|
|
if (_adminMgr.HasFlag(AdminFlags.Admin))
|
|
|
|
|
_consoleHost.ExecuteCommand($"dsay \"{CommandParsing.Escape(str)}\"");
|
|
|
|
|
else
|
|
|
|
|
_sawmill.Warning("Tried to speak on deadchat without being ghost or admin.");
|
|
|
|
|
break;
|
2020-11-01 23:55:55 +01:00
|
|
|
|
2024-08-15 20:26:57 +02:00
|
|
|
// TODO sepearate radio and say into separate commands.
|
|
|
|
|
case ChatSelectChannel.Radio:
|
|
|
|
|
case ChatSelectChannel.Local:
|
|
|
|
|
_consoleHost.ExecuteCommand($"say \"{CommandParsing.Escape(str)}\"");
|
|
|
|
|
break;
|
2021-07-20 10:29:09 +02:00
|
|
|
|
2024-08-15 20:26:57 +02:00
|
|
|
case ChatSelectChannel.Whisper:
|
|
|
|
|
_consoleHost.ExecuteCommand($"whisper \"{CommandParsing.Escape(str)}\"");
|
|
|
|
|
break;
|
2022-01-11 06:48:18 -08:00
|
|
|
|
2024-08-15 20:26:57 +02:00
|
|
|
default:
|
|
|
|
|
throw new ArgumentOutOfRangeException(nameof(channel), channel, null);
|
2019-04-13 09:45:09 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|