Admin chat (#1287)

* Admin chat

* Change it to show username, not character name

* moves the thing

* Removes SenderEntity
This commit is contained in:
ike709
2020-07-08 05:18:16 -05:00
committed by GitHub
parent df395b9435
commit 2d2385032a
13 changed files with 124 additions and 4 deletions

View File

@@ -4,6 +4,7 @@ using Content.Server.Interfaces.Chat;
using Content.Server.Interfaces.GameObjects;
using Content.Server.Players;
using Content.Shared.GameObjects;
using Robust.Server.Console;
using Robust.Server.Interfaces.Console;
using Robust.Server.Interfaces.Player;
using Robust.Shared.Enums;
@@ -79,6 +80,19 @@ namespace Content.Server.Chat
}
}
internal class AdminChatCommand : IClientCommand
{
public string Command => "asay";
public string Description => "Send chat messages to the private admin chat channel.";
public string Help => "asay <text>";
public void Execute(IConsoleShell shell, IPlayerSession player, string[] args)
{
var chat = IoCManager.Resolve<IChatManager>();
chat.SendAdminChat(player, string.Join(" ", args));
}
}
internal class SuicideCommand : IClientCommand
{
public string Command => "suicide";

View File

@@ -7,6 +7,7 @@ using Content.Server.Observer;
using Content.Server.Players;
using Content.Shared.Chat;
using Content.Shared.GameObjects.EntitySystems;
using Robust.Server.Console;
using Robust.Server.Interfaces.Player;
using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.Interfaces.Network;
@@ -28,6 +29,7 @@ namespace Content.Server.Chat
[Dependency] private readonly IPlayerManager _playerManager;
[Dependency] private readonly ILocalizationManager _localizationManager;
[Dependency] private readonly IMoMMILink _mommiLink;
[Dependency] private readonly IConGroupController _conGroupController;
#pragma warning restore 649
public void Initialize()
@@ -112,6 +114,23 @@ namespace Content.Server.Chat
_netManager.ServerSendToMany(msg, clients.ToList());
}
public void SendAdminChat(IPlayerSession player, string message)
{
if(!_conGroupController.CanCommand(player, "asay"))
{
SendOOC(player, message);
return;
}
var clients = _playerManager.GetPlayersBy(x => _conGroupController.CanCommand(x, "asay")).Select(p => p.ConnectedClient);;
var msg = _netManager.CreateNetMessage<MsgChatMessage>();
msg.Channel = ChatChannel.AdminChat;
msg.Message = message;
msg.MessageWrap = $"{_localizationManager.GetString("ADMIN")}: {player.SessionId}: {{0}}";
_netManager.ServerSendToMany(msg, clients.ToList());
}
public void SendHookOOC(string sender, string message)
{
var msg = _netManager.CreateNetMessage<MsgChatMessage>();