Files
OldThink/Content.Server/UtkaIntegration/Commands/UtkaPmCommand.cs
rhailrake aca6843c0a [feat] Sockets, i guess mm hmm
# Conflicts:
#	Content.Server/Administration/Systems/BwoinkSystem.cs
#	Content.Server/Chat/Managers/ChatManager.cs
#	Content.Server/Entry/EntryPoint.cs
#	Content.Server/GameTicking/GameTicker.RoundFlow.cs
#	Content.Server/IoC/ServerContentIoC.cs
#	Content.Server/RoundEnd/RoundEndSystem.cs
#	Content.Server/Shuttles/Systems/EmergencyShuttleSystem.Console.cs
#	Content.Server/Shuttles/Systems/EmergencyShuttleSystem.cs
#	Content.Shared/CCVar/CCVars.cs
2024-01-10 22:21:52 +07:00

37 lines
1.3 KiB
C#

using Content.Server.Administration.Systems;
using Content.Server.UtkaIntegration.TCP;
using Robust.Server.Player;
namespace Content.Server.UtkaIntegration;
public sealed class UtkaPmCommand : IUtkaCommand
{
public string Name => "discord_pm";
public Type RequestMessageType => typeof(UtkaPmRequest);
[Dependency] private readonly IPlayerManager _playerManager = default!;
[Dependency] private UtkaTCPWrapper _utkaSocketWrapper = default!;
public void Execute(UtkaTCPSession session, UtkaBaseMessage baseMessage)
{
if(baseMessage is not UtkaPmRequest message) return;
var _bwoink = EntitySystem.Get<BwoinkSystem>();
IoCManager.InjectDependencies(this);
if(string.IsNullOrWhiteSpace(message.Message) || string.IsNullOrWhiteSpace(message.Sender) || string.IsNullOrWhiteSpace(message.Reciever)) return;
var toUtkaMessage = new UtkaPmResponse();
if (!_playerManager.TryGetUserId(message.Reciever, out var reciever))
{
toUtkaMessage.Message = false;
_utkaSocketWrapper.SendMessageToAll(toUtkaMessage);
return;
}
_bwoink.SendUtkaBwoinkMessage(reciever, message.Sender, message.Message);
toUtkaMessage.Message = true;
_utkaSocketWrapper.SendMessageToAll(toUtkaMessage);
}
}