Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix missing logging for commands used at round start. #30062

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions Content.Client/UserInterface/Systems/Info/InfoUIController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ public override void Initialize()
"",
(_, _, _) =>
{
OnAcceptPressed();

OnAcceptPressed(true);
});
}

Expand Down Expand Up @@ -71,7 +72,7 @@ private void ShowRules(float time)
};

_rulesPopup.OnQuitPressed += OnQuitPressed;
_rulesPopup.OnAcceptPressed += OnAcceptPressed;
_rulesPopup.OnAcceptPressed += ActionOnAcceptPressed;
UIManager.WindowRoot.AddChild(_rulesPopup);
LayoutContainer.SetAnchorPreset(_rulesPopup, LayoutContainer.LayoutPreset.Wide);
}
Expand All @@ -81,9 +82,14 @@ private void OnQuitPressed()
_consoleHost.ExecuteCommand("quit");
}

private void OnAcceptPressed()
private void ActionOnAcceptPressed()
{
OnAcceptPressed();
}

private void OnAcceptPressed(bool fuckedRules = false)
{
_netManager.ClientSendMessage(new RulesAcceptedMessage());
_netManager.ClientSendMessage(new RulesAcceptedMessage {FuckedRules = fuckedRules});

_rulesPopup?.Orphan();
_rulesPopup = null;
Expand Down
28 changes: 26 additions & 2 deletions Content.Server/Info/RulesManager.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
using System.Net;
using Content.Server.Administration.Commands;
using Content.Server.Chat.Managers;
using Content.Server.Database;
using Content.Server.Players.PlayTimeTracking;
using Content.Shared.Administration.Logs;
using Content.Shared.CCVar;
using Content.Shared.Database;
using Content.Shared.Info;
using Robust.Server.Player;
using Robust.Shared.Configuration;
using Robust.Shared.Network;

Expand All @@ -12,6 +18,10 @@ public sealed class RulesManager
[Dependency] private readonly IServerDbManager _dbManager = default!;
[Dependency] private readonly INetManager _netManager = default!;
[Dependency] private readonly IConfigurationManager _cfg = default!;
[Dependency] private readonly IChatManager _chatManager = default!;
[Dependency] private readonly PlayTimeTrackingManager _playTimeTracking = default!;
[Dependency] private readonly IPlayerManager _playerManager = default!;
[Dependency] private readonly ISharedAdminLogManager _adminLogger = default!;

private static DateTime LastValidReadTime => DateTime.UtcNow - TimeSpan.FromDays(60);

Expand All @@ -24,8 +34,8 @@ public void Initialize()

private async void OnConnected(object? sender, NetChannelArgs e)
{
var isLocalhost = IPAddress.IsLoopback(e.Channel.RemoteEndPoint.Address) &&
_cfg.GetCVar(CCVars.RulesExemptLocal);
var isLocalhost = IPAddress.IsLoopback(e.Channel.RemoteEndPoint.Address) &&
_cfg.GetCVar(CCVars.RulesExemptLocal);

var lastRead = await _dbManager.GetLastReadRules(e.Channel.UserId);
var hasCooldown = lastRead > LastValidReadTime;
Expand All @@ -43,5 +53,19 @@ private async void OnRulesAccepted(RulesAcceptedMessage message)
{
var date = DateTime.UtcNow;
await _dbManager.SetLastReadRules(message.MsgChannel.UserId, date);

if (_playerManager.TryGetSessionById(message.MsgChannel.UserId, out var session))
{
var playTime = _playTimeTracking.GetOverallPlaytime(session);
if (message.FuckedRules && playTime < TimeSpan.FromHours(1))
{
var skippedMessage = Loc.GetString("admin-alert-new-player-skipping-rules", ("username", session.Name));
_chatManager.SendAdminAlert(skippedMessage);

_adminLogger.Add(LogType.Action,
LogImpact.Medium,
$"{skippedMessage}");
}
}
}
}
4 changes: 4 additions & 0 deletions Content.Shared/Info/RulesMessages.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,15 @@ public sealed class RulesAcceptedMessage : NetMessage
{
public override MsgGroups MsgGroup => MsgGroups.Command;

public bool FuckedRules { get; set; }

public override void ReadFromBuffer(NetIncomingMessage buffer, IRobustSerializer serializer)
{
FuckedRules = buffer.ReadBoolean();
}

public override void WriteToBuffer(NetOutgoingMessage buffer, IRobustSerializer serializer)
{
buffer.Write(FuckedRules);
}
}
1 change: 1 addition & 0 deletions Resources/Locale/en-US/administration/admin-alerts.ftl
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
admin-alert-shared-connection = {$player} is sharing a connection with {$otherCount} connected player(s): {$otherList}
admin-alert-new-player-skipping-rules = User {$username} skipped the rules and has less than 1 hour of playtime.
Loading