New Feature: Admin Only messages in AHelp (#35283)
* Feature * Update * Update * Update * Update Resources/Locale/en-US/administration/bwoink.ftl Co-authored-by: Pieter-Jan Briers <pieterjan.briers@gmail.com> * Yes --------- Co-authored-by: Pieter-Jan Briers <pieterjan.briers@gmail.com>
This commit is contained in:
@@ -19,11 +19,11 @@ namespace Content.Client.Administration.Systems
|
||||
OnBwoinkTextMessageRecieved?.Invoke(this, message);
|
||||
}
|
||||
|
||||
public void Send(NetUserId channelId, string text, bool playSound)
|
||||
public void Send(NetUserId channelId, string text, bool playSound, bool adminOnly)
|
||||
{
|
||||
// Reuse the channel ID as the 'true sender'.
|
||||
// Server will ignore this and if someone makes it not ignore this (which is bad, allows impersonation!!!), that will help.
|
||||
RaiseNetworkEvent(new BwoinkTextMessage(channelId, channelId, text, playSound: playSound));
|
||||
RaiseNetworkEvent(new BwoinkTextMessage(channelId, channelId, text, playSound: playSound, adminOnly: adminOnly));
|
||||
SendInputTextUpdated(channelId, false);
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,9 @@
|
||||
<BoxContainer Orientation="Vertical" HorizontalExpand="True" SizeFlagsStretchRatio="2">
|
||||
<BoxContainer Access="Public" Name="BwoinkArea" VerticalExpand="True" />
|
||||
<BoxContainer Orientation="Horizontal" HorizontalExpand="True">
|
||||
<CheckBox Visible="True" Name="PlaySound" Access="Public" Text="{Loc 'admin-bwoink-play-sound'}" Pressed="True" />
|
||||
<CheckBox Name="AdminOnly" Access="Public" Text="{Loc 'admin-ahelp-admin-only'}" ToolTip="{Loc 'admin-ahelp-admin-only-tooltip'}" />
|
||||
<Control HorizontalExpand="True" MinWidth="5" />
|
||||
<CheckBox Name="PlaySound" Access="Public" Text="{Loc 'admin-bwoink-play-sound'}" Pressed="True" />
|
||||
<Control HorizontalExpand="True" MinWidth="5" />
|
||||
<Button Visible="True" Name="PopOut" Access="Public" Text="{Loc 'admin-logs-pop-out'}" StyleClasses="OpenBoth" HorizontalAlignment="Left" />
|
||||
<Control HorizontalExpand="True" />
|
||||
|
||||
@@ -45,6 +45,8 @@ namespace Content.Client.Administration.UI.Bwoink
|
||||
_adminManager.AdminStatusUpdated += UpdateButtons;
|
||||
UpdateButtons();
|
||||
|
||||
AdminOnly.OnToggled += args => PlaySound.Disabled = args.Pressed;
|
||||
|
||||
ChannelSelector.OnSelectionChanged += sel =>
|
||||
{
|
||||
_currentPlayer = sel;
|
||||
|
||||
@@ -175,7 +175,7 @@ public sealed class AHelpUIController: UIController, IOnSystemChanged<BwoinkSyst
|
||||
UIHelper = isAdmin ? new AdminAHelpUIHandler(ownerUserId) : new UserAHelpUIHandler(ownerUserId);
|
||||
UIHelper.DiscordRelayChanged(_discordRelayActive);
|
||||
|
||||
UIHelper.SendMessageAction = (userId, textMessage, playSound) => _bwoinkSystem?.Send(userId, textMessage, playSound);
|
||||
UIHelper.SendMessageAction = (userId, textMessage, playSound, adminOnly) => _bwoinkSystem?.Send(userId, textMessage, playSound, adminOnly);
|
||||
UIHelper.InputTextChanged += (channel, text) => _bwoinkSystem?.SendInputTextUpdated(channel, text.Length > 0);
|
||||
UIHelper.OnClose += () => { SetAHelpPressed(false); };
|
||||
UIHelper.OnOpen += () => { SetAHelpPressed(true); };
|
||||
@@ -324,7 +324,7 @@ public interface IAHelpUIHandler : IDisposable
|
||||
public void PeopleTypingUpdated(BwoinkPlayerTypingUpdated args);
|
||||
public event Action OnClose;
|
||||
public event Action OnOpen;
|
||||
public Action<NetUserId, string, bool>? SendMessageAction { get; set; }
|
||||
public Action<NetUserId, string, bool, bool>? SendMessageAction { get; set; }
|
||||
public event Action<NetUserId, string>? InputTextChanged;
|
||||
}
|
||||
public sealed class AdminAHelpUIHandler : IAHelpUIHandler
|
||||
@@ -408,7 +408,7 @@ public sealed class AdminAHelpUIHandler : IAHelpUIHandler
|
||||
|
||||
public event Action? OnClose;
|
||||
public event Action? OnOpen;
|
||||
public Action<NetUserId, string, bool>? SendMessageAction { get; set; }
|
||||
public Action<NetUserId, string, bool, bool>? SendMessageAction { get; set; }
|
||||
public event Action<NetUserId, string>? InputTextChanged;
|
||||
|
||||
public void Open(NetUserId channelId, bool relayActive)
|
||||
@@ -462,7 +462,7 @@ public sealed class AdminAHelpUIHandler : IAHelpUIHandler
|
||||
if (_activePanelMap.TryGetValue(channelId, out var existingPanel))
|
||||
return existingPanel;
|
||||
|
||||
_activePanelMap[channelId] = existingPanel = new BwoinkPanel(text => SendMessageAction?.Invoke(channelId, text, Window?.Bwoink.PlaySound.Pressed ?? true));
|
||||
_activePanelMap[channelId] = existingPanel = new BwoinkPanel(text => SendMessageAction?.Invoke(channelId, text, Window?.Bwoink.PlaySound.Pressed ?? true, Window?.Bwoink.AdminOnly.Pressed ?? false));
|
||||
existingPanel.InputTextChanged += text => InputTextChanged?.Invoke(channelId, text);
|
||||
existingPanel.Visible = false;
|
||||
if (!Control!.BwoinkArea.Children.Contains(existingPanel))
|
||||
@@ -548,7 +548,7 @@ public sealed class UserAHelpUIHandler : IAHelpUIHandler
|
||||
|
||||
public event Action? OnClose;
|
||||
public event Action? OnOpen;
|
||||
public Action<NetUserId, string, bool>? SendMessageAction { get; set; }
|
||||
public Action<NetUserId, string, bool, bool>? SendMessageAction { get; set; }
|
||||
public event Action<NetUserId, string>? InputTextChanged;
|
||||
|
||||
public void Open(NetUserId channelId, bool relayActive)
|
||||
@@ -561,7 +561,7 @@ public sealed class UserAHelpUIHandler : IAHelpUIHandler
|
||||
{
|
||||
if (_window is { Disposed: false })
|
||||
return;
|
||||
_chatPanel = new BwoinkPanel(text => SendMessageAction?.Invoke(_ownerId, text, true));
|
||||
_chatPanel = new BwoinkPanel(text => SendMessageAction?.Invoke(_ownerId, text, true, false));
|
||||
_chatPanel.InputTextChanged += text => InputTextChanged?.Invoke(_ownerId, text);
|
||||
_chatPanel.RelayedToDiscordLabel.Visible = relayActive;
|
||||
_window = new DefaultWindow()
|
||||
|
||||
@@ -640,7 +640,7 @@ namespace Content.Server.Administration.Systems
|
||||
var personalChannel = senderSession.UserId == message.UserId;
|
||||
var senderAdmin = _adminManager.GetAdminData(senderSession);
|
||||
var senderAHelpAdmin = senderAdmin?.HasFlag(AdminFlags.Adminhelp) ?? false;
|
||||
var authorized = personalChannel || senderAHelpAdmin;
|
||||
var authorized = personalChannel && !message.AdminOnly || senderAHelpAdmin;
|
||||
if (!authorized)
|
||||
{
|
||||
// Unauthorized bwoink (log?)
|
||||
@@ -676,11 +676,11 @@ namespace Content.Server.Administration.Systems
|
||||
bwoinkText = $"{senderSession.Name}";
|
||||
}
|
||||
|
||||
bwoinkText = $"{(message.PlaySound ? "" : "(S) ")}{bwoinkText}: {escapedText}";
|
||||
bwoinkText = $"{(message.AdminOnly ? Loc.GetString("bwoink-message-admin-only") : !message.PlaySound ? Loc.GetString("bwoink-message-silent") : "")} {bwoinkText}: {escapedText}";
|
||||
|
||||
// If it's not an admin / admin chooses to keep the sound then play it.
|
||||
var playSound = !senderAHelpAdmin || message.PlaySound;
|
||||
var msg = new BwoinkTextMessage(message.UserId, senderSession.UserId, bwoinkText, playSound: playSound);
|
||||
// If it's not an admin / admin chooses to keep the sound and message is not an admin only message, then play it.
|
||||
var playSound = (!senderAHelpAdmin || message.PlaySound) && !message.AdminOnly;
|
||||
var msg = new BwoinkTextMessage(message.UserId, senderSession.UserId, bwoinkText, playSound: playSound, adminOnly: message.AdminOnly);
|
||||
|
||||
LogBwoink(msg);
|
||||
|
||||
@@ -700,7 +700,7 @@ namespace Content.Server.Administration.Systems
|
||||
}
|
||||
|
||||
// Notify player
|
||||
if (_playerManager.TryGetSessionById(message.UserId, out var session))
|
||||
if (_playerManager.TryGetSessionById(message.UserId, out var session) && !message.AdminOnly)
|
||||
{
|
||||
if (!admins.Contains(session.Channel))
|
||||
{
|
||||
|
||||
@@ -40,13 +40,16 @@ namespace Content.Shared.Administration
|
||||
|
||||
public bool PlaySound { get; }
|
||||
|
||||
public BwoinkTextMessage(NetUserId userId, NetUserId trueSender, string text, DateTime? sentAt = default, bool playSound = true)
|
||||
public readonly bool AdminOnly;
|
||||
|
||||
public BwoinkTextMessage(NetUserId userId, NetUserId trueSender, string text, DateTime? sentAt = default, bool playSound = true, bool adminOnly = false)
|
||||
{
|
||||
SentAt = sentAt ?? DateTime.Now;
|
||||
UserId = userId;
|
||||
TrueSender = trueSender;
|
||||
Text = text;
|
||||
PlaySound = playSound;
|
||||
AdminOnly = adminOnly;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,10 @@ bwoink-system-typing-indicator = {$players} {$count ->
|
||||
*[other] are
|
||||
} typing...
|
||||
|
||||
admin-ahelp-admin-only = Admin Only
|
||||
admin-ahelp-admin-only-tooltip = If checked, then the message won't be visible for the player,
|
||||
but will be visible for other admins and still will be Discord relayed.
|
||||
|
||||
admin-bwoink-play-sound = Bwoink?
|
||||
|
||||
bwoink-title-none-selected = None selected
|
||||
@@ -25,3 +29,6 @@ bwoink-system-rate-limited = System: you are sending messages too quickly.
|
||||
bwoink-system-player-disconnecting = has disconnected.
|
||||
bwoink-system-player-reconnecting = has reconnected.
|
||||
bwoink-system-player-banned = has been banned for: {$banReason}
|
||||
|
||||
bwoink-message-admin-only = (Admin Only)
|
||||
bwoink-message-silent = (S)
|
||||
|
||||
Reference in New Issue
Block a user