add round time to the ahelp relay (#22937)

* Basic roundtime implementation

* Forgot to clamp the length checker
This commit is contained in:
LankLTE
2023-12-24 22:57:00 -08:00
committed by GitHub
parent 00813171c1
commit e10a314ec2

View File

@@ -1,4 +1,4 @@
using System.Linq;
using System.Linq;
using System.Net.Http;
using System.Text;
using System.Text.Json;
@@ -70,7 +70,7 @@ namespace Content.Server.Administration.Systems
_config.OnValueChanged(CVars.GameHostName, OnServerNameChanged, true);
_config.OnValueChanged(CCVars.AdminAhelpOverrideClientName, OnOverrideChanged, true);
_sawmill = IoCManager.Resolve<ILogManager>().GetSawmill("AHELP");
_maxAdditionalChars = GenerateAHelpMessage("", "", true).Length;
_maxAdditionalChars = GenerateAHelpMessage("", "", true, _timing.CurTime.ToString("hh\\:mm\\:ss"), _gameTicker.RunLevel).Length;
_playerManager.PlayerStatusChanged += OnPlayerStatusChanged;
SubscribeLocalEvent<GameRunLevelChangedEvent>(OnGameRunLevelChanged);
@@ -471,7 +471,7 @@ namespace Content.Server.Administration.Systems
{
str = str[..(DescriptionMax - _maxAdditionalChars - unameLength)];
}
_messageQueues[msg.UserId].Enqueue(GenerateAHelpMessage(senderSession.Name, str, !personalChannel, admins.Count == 0));
_messageQueues[msg.UserId].Enqueue(GenerateAHelpMessage(senderSession.Name, str, !personalChannel, _timing.CurTime.ToString("hh\\:mm\\:ss"), _gameTicker.RunLevel, admins.Count == 0));
}
if (admins.Count != 0 || sendsWebhook)
@@ -492,10 +492,10 @@ namespace Content.Server.Administration.Systems
.ToList();
}
private static string GenerateAHelpMessage(string username, string message, bool admin, bool noReceivers = false)
private static string GenerateAHelpMessage(string username, string message, bool admin, string roundTime, GameRunLevel roundState, bool noReceivers = false)
{
var stringbuilder = new StringBuilder();
if (admin)
stringbuilder.Append(":outbox_tray:");
else if (noReceivers)
@@ -503,6 +503,8 @@ namespace Content.Server.Administration.Systems
else
stringbuilder.Append(":inbox_tray:");
if(roundTime != string.Empty && roundState == GameRunLevel.InRound)
stringbuilder.Append($" **{roundTime}**");
stringbuilder.Append($" **{username}:** ");
stringbuilder.Append(message);
return stringbuilder.ToString();