Fix aHelp relay to detect AFK Admins (#24482)

* Add AFK detection for aHelp relay and admin specific afk time.

* Correct query to new refactor

* Change AFK timeout to 10min or else Pancake closes my PR 😭

* It wasnt a bug it was a feature, way less aHelps that way.

* aHelp Colors arn't real!

* Update Content.Shared/CCVar/CCVars.cs

---------

Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
This commit is contained in:
Repo
2024-02-02 02:03:49 +13:00
committed by GitHub
parent 45dff4b47d
commit 0084121706
3 changed files with 32 additions and 9 deletions

View File

@@ -1,4 +1,5 @@
using Content.Shared.CCVar;
using Content.Server.Administration.Managers;
using Content.Shared.CCVar;
using JetBrains.Annotations;
using Robust.Server.Player;
using Robust.Shared.Configuration;
@@ -38,6 +39,7 @@ namespace Content.Server.Afk
[Dependency] private readonly IGameTiming _gameTiming = default!;
[Dependency] private readonly IConfigurationManager _cfg = default!;
[Dependency] private readonly IConsoleHost _consoleHost = default!;
[Dependency] private readonly IAdminManager _adminManager = default!;
private readonly Dictionary<ICommonSession, TimeSpan> _lastActionTimes = new();
@@ -61,10 +63,15 @@ namespace Content.Server.Afk
public bool IsAfk(ICommonSession player)
{
if (!_lastActionTimes.TryGetValue(player, out var time))
{
// Some weird edge case like disconnected clients. Just say true I guess.
return true;
}
var timeOut = _adminManager.IsAdmin(player)
? TimeSpan.FromSeconds(_cfg.GetCVar(CCVars.AdminAfkTime))
: TimeSpan.FromSeconds(_cfg.GetCVar(CCVars.AfkTime));
var timeOut = TimeSpan.FromSeconds(_cfg.GetCVar(CCVars.AfkTime));
return _gameTiming.RealTime - time > timeOut;
}