Skip to content

Commit

Permalink
правки
Browse files Browse the repository at this point in the history
  • Loading branch information
Schrodinger71 committed Jan 6, 2025
1 parent 73124ba commit 81fd99b
Showing 1 changed file with 22 additions and 19 deletions.
41 changes: 22 additions & 19 deletions Content.Server/Administration/ServerApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
using Robust.Shared.Player;
using Robust.Shared.Prototypes;
using Robust.Shared.Utility;

using Content.Server.Administration.Managers;
using Content.Shared.Chat;
using Content.Server.Chat.Managers;
Expand Down Expand Up @@ -62,6 +61,9 @@ public sealed partial class ServerApi : IPostInjectInit
[Dependency] private readonly ILogManager _logManager = default!;
[Dependency] private readonly IEntitySystemManager _entitySystemManager = default!;
[Dependency] private readonly ILocalizationManager _loc = default!;
[Dependency] private readonly IAdminManager _admin = default!;
[Dependency] private readonly INetConfigurationManager _netConfigManager = default!;
[Dependency] private readonly IChatManager _chatManager = default!;

private string _token = string.Empty;
private ISawmill _sawmill = default!;
Expand Down Expand Up @@ -717,49 +719,50 @@ private sealed class GameruleResponse

#region ADT-Tweak


[Dependency] private readonly IAdminManager _admin = default!;
[Dependency] private readonly INetConfigurationManager _netConfigManager = default!;
[Dependency] private readonly IChatManager _chatManager = default!;

private async Task ActionAdminChat(IStatusHandlerContext context, Actor actor)
{
var body = await ReadJson<AdminChatActionBody>(context);
if (body == null)
return;

var discordName = body.NickName;
discordName += "(Discord)";
var message = body.Message;
string discordName = $"{body.NickName}(Discord)";
string message = body.Message;
var authorUser = new NetUserId(actor.Guid);

await RunOnMainThread(async () =>
{
var clients = _admin.ActiveAdmins.Select(p => p.Channel);
var clients = _admin.ActiveAdmins.Select(p => p.Channel).ToList();

// Используем Loc.GetString для формирования сообщения
var wrappedMessage = Loc.GetString("chat-manager-send-admin-chat-wrap-message",
("adminChannelName", Loc.GetString("chat-manager-admin-channel-name")),
("playerName", discordName), ("message", FormattedMessage.EscapeText(message)));
("adminChannelName", Loc.GetString("chat-manager-admin-channel-name")),
("playerName", discordName),
("message", FormattedMessage.EscapeText(body.Message))
);

// Отправляем сообщения всем администраторам
foreach (var client in clients)
{
var isSource = true;
_chatManager.ChatMessageToOne(ChatChannel.AdminChat,
bool isSource = true;
string? audioPath = isSource ? _netConfigManager.GetClientCVar(client, CCVars.AdminChatSoundPath) : default;
float audioVolume = isSource ? _netConfigManager.GetClientCVar(client, CCVars.AdminChatSoundVolume) : default;

_chatManager.ChatMessageToOne(
ChatChannel.AdminChat,
message,
wrappedMessage,
default,
false,
client,
audioPath: isSource ? _netConfigManager.GetClientCVar(client, CCVars.AdminChatSoundPath) : default,
audioVolume: isSource ? _netConfigManager.GetClientCVar(client, CCVars.AdminChatSoundVolume) : default,
audioPath: audioPath,
audioVolume: audioVolume,
author: authorUser
);

}
await RespondOk(context);

await RespondOk(context);
_sawmill.Info($"Send message by {FormatLogActor(actor)}");
});

}

private sealed class AdminChatActionBody
Expand Down

0 comments on commit 81fd99b

Please sign in to comment.