Alert the user if nobody's around to hear a bwoink (#5147)
This commit is contained in:
@@ -10,6 +10,7 @@ using Robust.Shared.GameObjects.Components;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Players;
|
||||
using Robust.Shared.Network;
|
||||
using Robust.Shared.Localization;
|
||||
using Robust.Server.Player;
|
||||
using Robust.Shared.IoC;
|
||||
|
||||
@@ -28,7 +29,10 @@ namespace Content.Server.Administration
|
||||
|
||||
// TODO: Sanitize text?
|
||||
// Confirm that this person is actually allowed to send a message here.
|
||||
if ((senderSession.UserId != message.ChannelId) && (_adminManager.GetAdminData(senderSession) == null))
|
||||
var senderPersonalChannel = senderSession.UserId == message.ChannelId;
|
||||
var senderAdmin = _adminManager.GetAdminData(senderSession) != null;
|
||||
var authorized = senderPersonalChannel || senderAdmin;
|
||||
if (!authorized)
|
||||
{
|
||||
// Unauthorized bwoink (log?)
|
||||
return;
|
||||
@@ -38,16 +42,25 @@ namespace Content.Server.Administration
|
||||
|
||||
LogBwoink(msg);
|
||||
|
||||
var targets = _adminManager.ActiveAdmins.Select(p => p.ConnectedClient);
|
||||
|
||||
// Admins
|
||||
foreach (var channel in targets)
|
||||
RaiseNetworkEvent(msg, channel);
|
||||
var targets = _adminManager.ActiveAdmins.Select(p => p.ConnectedClient).ToList();
|
||||
|
||||
// And involved player
|
||||
if (_playerManager.TryGetSessionById(message.ChannelId, out var session))
|
||||
if (!targets.Contains(session.ConnectedClient))
|
||||
RaiseNetworkEvent(msg, session.ConnectedClient);
|
||||
targets.Add(session.ConnectedClient);
|
||||
|
||||
foreach (var channel in targets)
|
||||
RaiseNetworkEvent(msg, channel);
|
||||
|
||||
if (targets.Count == 1)
|
||||
{
|
||||
var systemText = senderPersonalChannel ?
|
||||
Loc.GetString("bwoink-system-starmute-message-no-other-users-primary") :
|
||||
Loc.GetString("bwoink-system-starmute-message-no-other-users-secondary");
|
||||
var starMuteMsg = new BwoinkTextMessage(message.ChannelId, SystemUserId, systemText);
|
||||
RaiseNetworkEvent(starMuteMsg, senderSession.ConnectedClient);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,6 +13,9 @@ namespace Content.Shared.Administration
|
||||
{
|
||||
public abstract class SharedBwoinkSystem : EntitySystem
|
||||
{
|
||||
// System users
|
||||
public static NetUserId SystemUserId { get; } = new NetUserId(Guid.Empty);
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
4
Resources/Locale/en-US/administration/bwoink.ftl
Normal file
4
Resources/Locale/en-US/administration/bwoink.ftl
Normal file
@@ -0,0 +1,4 @@
|
||||
bwoink-system-starmute-message-no-other-users-primary = *System: Nobody is available to receive your message. Try pinging Game Admins on Discord.
|
||||
|
||||
bwoink-system-starmute-message-no-other-users-secondary = *System: Nobody is available to receive your message.
|
||||
|
||||
Reference in New Issue
Block a user