Skip to content

Commit

Permalink
add round time to the ahelp relay (space-wizards#22937)
Browse files Browse the repository at this point in the history
* Basic roundtime implementation

* Forgot to clamp the length checker
  • Loading branch information
LankLTE authored Dec 25, 2023
1 parent 0081317 commit e10a314
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions Content.Server/Administration/Systems/BwoinkSystem.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Linq;
using System.Linq;
using System.Net.Http;
using System.Text;
using System.Text.Json;
Expand Down Expand Up @@ -70,7 +70,7 @@ public override void Initialize()
_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);
Expand Down Expand Up @@ -471,7 +471,7 @@ protected override void OnBwoinkTextMessage(BwoinkTextMessage message, EntitySes
{
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)
Expand All @@ -492,17 +492,19 @@ private IList<INetChannel> GetTargetAdmins()
.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)
stringbuilder.Append(":sos:");
else
stringbuilder.Append(":inbox_tray:");

if(roundTime != string.Empty && roundState == GameRunLevel.InRound)
stringbuilder.Append($" **{roundTime}**");
stringbuilder.Append($" **{username}:** ");
stringbuilder.Append(message);
return stringbuilder.ToString();
Expand Down

0 comments on commit e10a314

Please sign in to comment.