Skip to content

Commit

Permalink
Ahelpfix (#108)
Browse files Browse the repository at this point in the history
* fix ahelp system for logging

* fix ahelp system v2

* try fix ahelp v3

* fixed ahelp sys
  • Loading branch information
Sh1ntra authored Oct 31, 2024
1 parent cb6ba5c commit b9de0bc
Showing 1 changed file with 3 additions and 85 deletions.
88 changes: 3 additions & 85 deletions Content.Server/Administration/Systems/BwoinkSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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]";
}
Expand Down Expand Up @@ -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]";
}
Expand All @@ -455,90 +450,14 @@ 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);
}
}
}

/*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<string>();
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<INetChannel> GetNonAfkAdmins()
{
return _adminManager.ActiveAdmins
Expand Down Expand Up @@ -576,4 +495,3 @@ private static string GenerateAHelpMessage(string username, string message, bool
}
}
}

0 comments on commit b9de0bc

Please sign in to comment.