From b9de0bc58b9535080eb55007c632e6952a23b84a Mon Sep 17 00:00:00 2001 From: Dmitriy <108795395+Sh1ntra@users.noreply.github.com> Date: Fri, 1 Nov 2024 02:04:30 +0300 Subject: [PATCH] Ahelpfix (#108) * fix ahelp system for logging * fix ahelp system v2 * try fix ahelp v3 * fixed ahelp sys --- .../Administration/Systems/BwoinkSystem.cs | 88 +------------------ 1 file changed, 3 insertions(+), 85 deletions(-) diff --git a/Content.Server/Administration/Systems/BwoinkSystem.cs b/Content.Server/Administration/Systems/BwoinkSystem.cs index 9fbcb229d0..11ff2eadf7 100644 --- a/Content.Server/Administration/Systems/BwoinkSystem.cs +++ b/Content.Server/Administration/Systems/BwoinkSystem.cs @@ -35,7 +35,6 @@ public sealed class BwoinkSystem : SharedBwoinkSystem [Dependency] private readonly GameTicker _gameTicker = default!; [Dependency] private readonly SharedMindSystem _minds = default!; [Dependency] private readonly IAfkManager _afkManager = default!; - [Dependency] private readonly INetManager _netManager = default!; private ISawmill _sawmill = default!; private readonly HttpClient _httpClient = new(); @@ -397,9 +396,7 @@ protected override void OnBwoinkTextMessage(BwoinkTextMessage message, EntitySes string bwoinkText; - if (senderAdmin is not null && - senderAdmin.Flags == - AdminFlags.Adminhelp) // Mentor. Not full admin. That's why it's colored differently. + if (senderAdmin is not null && senderAdmin.Flags == AdminFlags.Adminhelp) // Mentor. Not full admin. That's why it's colored differently. { bwoinkText = $"[color=purple]{senderSession.Name}[/color]"; } @@ -438,9 +435,7 @@ protected override void OnBwoinkTextMessage(BwoinkTextMessage message, EntitySes { string overrideMsgText; // Doing the same thing as above, but with the override name. Theres probably a better way to do this. - if (senderAdmin is not null && - senderAdmin.Flags == - AdminFlags.Adminhelp) // Mentor. Not full admin. That's why it's colored differently. + if (senderAdmin is not null && senderAdmin.Flags == AdminFlags.Adminhelp) // Mentor. Not full admin. That's why it's colored differently. { overrideMsgText = $"[color=purple]{_overrideClientName}[/color]"; } @@ -455,9 +450,7 @@ protected override void OnBwoinkTextMessage(BwoinkTextMessage message, EntitySes overrideMsgText = $"{(message.PlaySound ? "" : "(S) ")}{overrideMsgText}: {escapedText}"; - RaiseNetworkEvent( - new BwoinkTextMessage(message.UserId, senderSession.UserId, overrideMsgText, - playSound: playSound), session.Channel); + RaiseNetworkEvent(new BwoinkTextMessage(message.UserId, senderSession.UserId, overrideMsgText, playSound: playSound), session.Channel); } else RaiseNetworkEvent(msg, session.Channel); @@ -465,80 +458,6 @@ protected override void OnBwoinkTextMessage(BwoinkTextMessage message, EntitySes } } - /*public void DiscordAhelpSendMessage(BwoinkTextMessage message, EntitySessionEventArgs eventArgs) - { - var senderSession = eventArgs.SenderSession; - - // Confirm that this person is actually allowed to send a message here. - var personalChannel = senderSession.UserId == message.UserId; - var senderAdmin = _adminManager.GetAdminData(senderSession); - var senderAHelpAdmin = senderAdmin?.HasFlag(AdminFlags.Adminhelp) ?? false; - var authorized = personalChannel || senderAHelpAdmin; - if (!authorized) - { - // Unauthorized bwoink (log?) - return; - } - - var escapedText = FormattedMessage.EscapeText(message.Text); - - string bwoinkText; - - if (senderAdmin is not null && senderAdmin.Flags == AdminFlags.Adminhelp) // Mentor. Not full admin. That's why it's colored differently. - { - bwoinkText = $"[color=purple]{senderSession.Name}[/color]"; - } - else if (senderAdmin is not null && senderAdmin.HasFlag(AdminFlags.Adminhelp)) - { - bwoinkText = $"[color=red]{senderSession.Name}[/color]"; - } - else - { - bwoinkText = $"{senderSession.Name}"; - } - - bwoinkText = $"{"(Discord) "}{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); - - LogBwoink(msg); - - var admins = GetTargetAdmins(); - - // Notify all admins - foreach (var channel in admins) - { - RaiseNetworkEvent(msg, channel); - } - - var sendsWebhook = _webhookUrl != string.Empty; - if (sendsWebhook) - { - if (!_messageQueues.ContainsKey(msg.UserId)) - _messageQueues[msg.UserId] = new Queue(); - - var str = message.Text; - var unameLength = senderSession.Name.Length; - - if (unameLength + str.Length + _maxAdditionalChars > DescriptionMax) - { - str = str[..(DescriptionMax - _maxAdditionalChars - unameLength)]; - } - var nonAfkAdmins = GetNonAfkAdmins(); - _messageQueues[msg.UserId].Enqueue(GenerateAHelpMessage(senderSession.Name, str, !personalChannel, _gameTicker.RoundDuration().ToString("hh\\:mm\\:ss"), _gameTicker.RunLevel, playedSound: playSound, noReceivers: nonAfkAdmins.Count == 0)); - } - - if (admins.Count != 0 || sendsWebhook) - return; - - // No admin online, let the player know - var systemText = Loc.GetString("bwoink-system-starmute-message-no-other-users"); - var starMuteMsg = new BwoinkTextMessage(message.UserId, SystemUserId, systemText); - RaiseNetworkEvent(starMuteMsg, senderSession.Channel); - }*/ - private IList GetNonAfkAdmins() { return _adminManager.ActiveAdmins @@ -576,4 +495,3 @@ private static string GenerateAHelpMessage(string username, string message, bool } } } -