Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dsahelpfix #119

Merged
merged 2 commits into from
Nov 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 12 additions & 7 deletions Content.Server/Administration/ServerApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -408,18 +408,23 @@ private async Task ActionAhelpSend(IStatusHandlerContext context, Actor actor)
await context.RespondErrorAsync(HttpStatusCode.BadRequest);
return;
}
var _bwoinkSystem = _entitySystemManager.GetEntitySystem<BwoinkSystem>();
var playerUserId = new NetUserId(body.UserId);
var senderUserId = new NetUserId(actor.Guid);
var message = new SharedBwoinkSystem.BwoinkTextMessage(playerUserId,senderUserId, body.Text);
var bwoinkSystem = _entitySystemManager.GetEntitySystem<BwoinkSystem>();
var data = await _locator.LookupIdByNameOrIdAsync($"{body.PlayerNickname}");
if (data != null)
{
var playerUserId = new NetUserId(data.UserId);

var senderUserId = new NetUserId(body.SenderUserId);
var message = new SharedBwoinkSystem.BwoinkTextMessage(playerUserId, senderUserId, body.Text);
await RunOnMainThread(async () =>
{
if (_playerManager.TryGetSessionById(playerUserId, out var session))
{
_bwoinkSystem.DiscordAhelpSendMessage(message, new EntitySessionEventArgs(session));
bwoinkSystem.DiscordAhelpSendMessage(message, new EntitySessionEventArgs(session));
await RespondOk(context);
}
});
}
}

private async Task ShutdownAction(IStatusHandlerContext context, Actor actor)
Expand Down Expand Up @@ -731,8 +736,8 @@ private sealed class GetCkeyActionBody

private sealed class DiscordAhelpBody
{
public required Guid UserId { get; init; }
public required Guid TrueSender { get; init; }
public required string PlayerNickname { get; init; }
public required Guid SenderUserId { get; init; }
public string? Text { get; init; }
}

Expand Down
7 changes: 4 additions & 3 deletions Content.Server/Administration/Systems/BwoinkSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,7 @@ public void DiscordAhelpSendMessage(BwoinkTextMessage message, EntitySessionEven
{
var senderSession = eventArgs.SenderSession;
// Confirm that this person is actually allowed to send a message here.
var adminNickname = _playerManager.GetSessionById(message.TrueSender).Name;
var personalChannel = senderSession.UserId == message.UserId;
var senderAdmin = _adminManager.GetAdminData(senderSession);
var senderAHelpAdmin = senderAdmin?.HasFlag(AdminFlags.Adminhelp) ?? false;
Expand All @@ -534,15 +535,15 @@ public void DiscordAhelpSendMessage(BwoinkTextMessage message, EntitySessionEven
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]";
bwoinkText = $"[color=purple]{adminNickname}[/color]";
}
else if (senderAdmin is not null && senderAdmin.HasFlag(AdminFlags.Adminhelp))
{
bwoinkText = $"[color=red]{senderSession.Name}[/color]";
bwoinkText = $"[color=red]{adminNickname}[/color]";
}
else
{
bwoinkText = $"{senderSession.Name}";
bwoinkText = $"{adminNickname}";
}
bwoinkText = $"{"(Discord) "}{bwoinkText}: {escapedText}";
// If it's not an admin / admin chooses to keep the sound then play it.
Expand Down
Loading