From 6377514aa2eed946f56b84053356d413c34685c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Schr=C3=B6dinger?= <132720404+Schrodinger71@users.noreply.github.com> Date: Wed, 27 Nov 2024 16:01:16 +0300 Subject: [PATCH] =?UTF-8?q?[ADMIN]=20=D0=9D=D0=BE=D0=B2=D1=8B=D0=B5=20?= =?UTF-8?q?=D1=84=D0=B8=D1=87=D0=B8=20Adminwho=20=D0=B4=D0=B8=D1=81=D0=B0?= =?UTF-8?q?=20(#843)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Описание PR Скрины ## Почему / Баланс **Ссылка на публикацию в Discord** ## Техническая информация ## Медиа ![image](https://github.com/user-attachments/assets/09c3e840-9c43-4537-8bce-df984b557bd7) ![image](https://github.com/user-attachments/assets/01238757-e042-4ca9-934d-a503083122f8) ## Требования - [x] Я прочитал(а) и следую [Руководство по созданию пулл реквестов](https://docs.spacestation14.com/en/general-development/codebase-info/pull-request-guidelines.html). Я понимаю, что в противном случае мой ПР может быть закрыт по усмотрению мейнтейнера. - [x] Я добавил скриншоты/видео к этому пулл реквесту, демонстрирующие его изменения в игре, **или** этот пулл реквест не требует демонстрации в игре ## Критические изменения **Чейнджлог** No cl. No fun. --- .../Adminwho/DiscordAdminInfoSenderSystem.cs | 20 +++++++++++++++++++ .../ServerUpdates/ServerUpdateManager.cs | 2 ++ .../ru-RU/ADT/Discord/discord-update.ftl | 1 + 3 files changed, 23 insertions(+) create mode 100644 Resources/Locale/ru-RU/ADT/Discord/discord-update.ftl diff --git a/Content.Server/ADT/Discord/Adminwho/DiscordAdminInfoSenderSystem.cs b/Content.Server/ADT/Discord/Adminwho/DiscordAdminInfoSenderSystem.cs index 95619a98b66..a806b093992 100644 --- a/Content.Server/ADT/Discord/Adminwho/DiscordAdminInfoSenderSystem.cs +++ b/Content.Server/ADT/Discord/Adminwho/DiscordAdminInfoSenderSystem.cs @@ -10,6 +10,9 @@ using Content.Server.Afk; using Content.Shared.Ghost; using Content.Shared.GameTicking; +using Robust.Server.Player; +using Content.Server.Maps; + namespace Content.Server.ADT.Discord.Adminwho; @@ -21,6 +24,9 @@ public sealed class DiscordAdminInfoSenderSystem : EntitySystem [Dependency] private readonly IGameTiming _time = default!; [Dependency] private readonly IEntitySystemManager _entitySystemManager = default!; [Dependency] private readonly IEntityManager _entities = default!; + [Dependency] private readonly IPlayerManager _playerManager = default!; + [Dependency] private readonly IGameMapManager _gameMapManager = default!; + [Dependency] private readonly GameTicker _gameTicker = default!; private TimeSpan _nextSendTime = TimeSpan.MinValue; private readonly TimeSpan _delayInterval = TimeSpan.FromMinutes(15); @@ -76,6 +82,9 @@ private async void SendAdminInfoToDiscord() sb.AppendLine(); } + if (sb.Length == 0) + sb.Append("Null админов"); + var serverName = _cfg.GetCVar(CCVars.GameHostName); var gameTicker = _entitySystemManager.GetEntitySystem(); @@ -90,6 +99,11 @@ private async void SendAdminInfoToDiscord() $"{gameTicker.RunLevel} was not matched."), }; + var countPlayer = _playerManager.PlayerCount; + var countPlayerMax = _cfg.GetCVar(CCVars.SoftMaxPlayers); + var mapName = _gameMapManager.GetSelectedMap(); + var selectGameRule = _gameTicker.CurrentPreset; + var embed = new WebhookEmbed { Title = Loc.GetString("title-embed-webhook-adminwho"), @@ -102,6 +116,12 @@ private async void SendAdminInfoToDiscord() }, }; + embed.Fields.Add(new WebhookEmbedField { Name = "Player", Value = $"{countPlayer}/{countPlayerMax}", Inline = true }); + if (mapName != null) + embed.Fields.Add(new WebhookEmbedField { Name = "Карта", Value = mapName.MapName, Inline = true }); + if (selectGameRule != null) + embed.Fields.Add(new WebhookEmbedField { Name = "Режим", Value = Loc.GetString(selectGameRule.ModeTitle), Inline = true }); + var payload = new WebhookPayload { Embeds = new List { embed }, diff --git a/Content.Server/ServerUpdates/ServerUpdateManager.cs b/Content.Server/ServerUpdates/ServerUpdateManager.cs index bf18428e25b..fdc222f20c6 100644 --- a/Content.Server/ServerUpdates/ServerUpdateManager.cs +++ b/Content.Server/ServerUpdates/ServerUpdateManager.cs @@ -27,6 +27,8 @@ public sealed class ServerUpdateManager : IPostInjectInit [Dependency] private readonly IBaseServer _server = default!; [Dependency] private readonly IConfigurationManager _cfg = default!; [Dependency] private readonly ILogManager _logManager = default!; + [Dependency] private readonly DiscordWebhook _discord = default!; + [Dependency] private readonly IEntitySystemManager _entitySystemManager = default!; private ISawmill _sawmill = default!; diff --git a/Resources/Locale/ru-RU/ADT/Discord/discord-update.ftl b/Resources/Locale/ru-RU/ADT/Discord/discord-update.ftl new file mode 100644 index 00000000000..6d7c4875d8b --- /dev/null +++ b/Resources/Locale/ru-RU/ADT/Discord/discord-update.ftl @@ -0,0 +1 @@ +username-webhook-update = Loremaster build`s update