Skip to content

Commit

Permalink
Merge branch 'master' into translation
Browse files Browse the repository at this point in the history
  • Loading branch information
CrimeMoot authored Jul 27, 2024
2 parents dd8a461 + 856c5d4 commit 404cc51
Show file tree
Hide file tree
Showing 82 changed files with 1,173 additions and 526 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,11 @@ jobs:
ARTIFACT_ID: ${{ steps.artifact-upload-step.outputs.artifact-id }}
GITHUB_REPOSITORY: ${{ vars.GITHUB_REPOSITORY }}

# - name: Publish changelog (Discord)
# run: Tools/actions_changelogs_since_last_run.py
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# DISCORD_WEBHOOK_URL: ${{ secrets.CHANGELOG_DISCORD_WEBHOOK }}
- name: Publish changelog
run: Tools/actions_changelogs_since_last_run.py
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
DISCORD_WEBHOOK_URL: ${{ secrets.CHANGELOG_DISCORD_WEBHOOK }}

# - name: Publish changelog (RSS)
# run: Tools/actions_changelog_rss.py
Expand Down
92 changes: 0 additions & 92 deletions .github/workflows/update-wiki.yml

This file was deleted.

1 change: 1 addition & 0 deletions Content.Client/Options/UI/EscapeMenu.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<Button Access="Public" Name="RulesButton" Text="{Loc 'ui-escape-rules'}" />
<Button Access="Public" Name="GuidebookButton" Text="{Loc 'ui-escape-guidebook'}" />
<Button Access="Public" Name="WikiButton" Text="{Loc 'ui-escape-wiki'}" />
<Button Access="Public" Name="DiscordButton" Text="{Loc 'ui-escape-discord'}" />
<Button Access="Public" Name="DisconnectButton" Text="{Loc 'ui-escape-disconnect'}" />
<Button Access="Public" Name="QuitButton" Text="{Loc 'ui-escape-quit'}" />
</BoxContainer>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -787,7 +787,7 @@ private void OnDamageForceSay(DamageForceSayEvent ev, EntitySessionEventArgs _)

// we need to handle selected channel
// and prefix-channel separately..
var allowedChannels = ChatSelectChannel.Local | ChatSelectChannel.Whisper;
var allowedChannels = ChatSelectChannel.Local | ChatSelectChannel.Whisper | ChatSelectChannel.Radio;
if ((chatBox.SelectedChannel & allowedChannels) == ChatSelectChannel.None)
return;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,20 @@ public void OnStateEntered(GameplayState state)
_uri.OpenUri(_cfg.GetCVar(CCVars.InfoLinksWiki));
};

_escapeWindow.DiscordButton.OnPressed += _ =>
{
_uri.OpenUri(_cfg.GetCVar(CCVars.InfoLinksDiscord));
};

_escapeWindow.GuidebookButton.OnPressed += _ =>
{
_guidebook.ToggleGuidebook();
};

// Hide wiki button if we don't have a link for it.
_escapeWindow.WikiButton.Visible = _cfg.GetCVar(CCVars.InfoLinksWiki) != "";
// Hide discord button if we don't have a link for it.
_escapeWindow.DiscordButton.Visible = _cfg.GetCVar(CCVars.InfoLinksDiscord) != ""; //discord-button

CommandBinds.Builder
.Bind(EngineKeyFunctions.EscapeMenu,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public void AddDenied(int denied)
EntryContainer.AddChild(textLabel);

var whitelistButton = new Button();
whitelistButton.Text = Loc.GetString("ui-escape-discord");
whitelistButton.Text = Loc.GetString("ui-escap-discord");

var uri = IoCManager.Resolve<IUriOpener>();
var cfg = IoCManager.Resolve<IConfigurationManager>();
Expand Down
14 changes: 7 additions & 7 deletions Content.Server/Administration/Commands/AdminWhoCommand.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Text;
using System.Linq;
using System.Text;
using Content.Server.Administration.Managers;
using Content.Server.Afk;
using Content.Shared.Administration;
Expand Down Expand Up @@ -29,13 +30,10 @@ public void Execute(IConsoleShell shell, string argStr, string[] args)
seeStealth = playerData != null && playerData.CanStealth();
}

var sb = new StringBuilder();
var first = true;
var adminList = new List<string>();
foreach (var admin in adminMgr.ActiveAdmins)
{
if (!first)
sb.Append('\n');
first = false;
var sb = new StringBuilder();

var adminData = adminMgr.GetAdminData(admin)!;
DebugTools.AssertNotNull(adminData);
Expand All @@ -55,8 +53,10 @@ public void Execute(IConsoleShell shell, string argStr, string[] args)
if (afk.IsAfk(admin))
sb.Append(" [AFK]");
}

adminList.Add(sb.ToString());
}

shell.WriteLine(sb.ToString());
shell.WriteLine(string.Join(Environment.NewLine, adminList));
}
}
86 changes: 30 additions & 56 deletions Content.Server/Administration/Systems/BwoinkSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,9 @@
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using Content.Server.Administration.Managers;
using Content.Server.Backmen.Administration.Bwoink.Gpt;
using Content.Server.Afk;
using Content.Server.Discord;
using Content.Server.GameTicking;
using Content.Server.Players.RateLimiting;
using Content.Shared.Administration;
using Content.Shared.CCVar;
using Content.Shared.Mind;
Expand All @@ -23,14 +21,15 @@
using Robust.Shared.Player;
using Robust.Shared.Timing;
using Robust.Shared.Utility;
using Robust.Shared.Console;
using Content.Server.Administration.Commands;


namespace Content.Server.Administration.Systems
{
[UsedImplicitly]
public sealed partial class BwoinkSystem : SharedBwoinkSystem
public sealed class BwoinkSystem : SharedBwoinkSystem
{
private const string RateLimitKey = "AdminHelp";

[Dependency] private readonly IPlayerManager _playerManager = default!;
[Dependency] private readonly IAdminManager _adminManager = default!;
[Dependency] private readonly IConfigurationManager _config = default!;
Expand All @@ -39,10 +38,6 @@ public sealed partial class BwoinkSystem : SharedBwoinkSystem
[Dependency] private readonly GameTicker _gameTicker = default!;
[Dependency] private readonly SharedMindSystem _minds = default!;
[Dependency] private readonly IAfkManager _afkManager = default!;
[Dependency] private readonly PlayerRateLimitManager _rateLimit = default!;

[GeneratedRegex(@"^https://discord\.com/api/webhooks/(\d+)/((?!.*/).*)$")]
private static partial Regex DiscordRegex();

private ISawmill _sawmill = default!;
private readonly HttpClient _httpClient = new();
Expand Down Expand Up @@ -74,33 +69,17 @@ public sealed partial class BwoinkSystem : SharedBwoinkSystem
public override void Initialize()
{
base.Initialize();
Subs.CVar(_config, CCVars.DiscordAHelpWebhook, OnWebhookChanged, true);
Subs.CVar(_config, CCVars.DiscordAHelpFooterIcon, OnFooterIconChanged, true);
Subs.CVar(_config, CCVars.DiscordAHelpAvatar, OnAvatarChanged, true);
Subs.CVar(_config, CVars.GameHostName, OnServerNameChanged, true);
Subs.CVar(_config, CCVars.AdminAhelpOverrideClientName, OnOverrideChanged, true);
_config.OnValueChanged(CCVars.DiscordAHelpWebhook, OnWebhookChanged, true);
_config.OnValueChanged(CCVars.DiscordAHelpFooterIcon, OnFooterIconChanged, true);
_config.OnValueChanged(CCVars.DiscordAHelpAvatar, OnAvatarChanged, true);
_config.OnValueChanged(CVars.GameHostName, OnServerNameChanged, true);
_config.OnValueChanged(CCVars.AdminAhelpOverrideClientName, OnOverrideChanged, true);
_sawmill = IoCManager.Resolve<ILogManager>().GetSawmill("AHELP");
_maxAdditionalChars = GenerateAHelpMessage("", "", true, _gameTicker.RoundDuration().ToString("hh\\:mm\\:ss"), _gameTicker.RunLevel, playedSound: false).Length;
_maxAdditionalChars = GenerateAHelpMessage("", "", true, _gameTicker.RoundDuration().ToString("hh\\:mm\\:ss"), _gameTicker.RunLevel).Length;
_playerManager.PlayerStatusChanged += OnPlayerStatusChanged;

SubscribeLocalEvent<GameRunLevelChangedEvent>(OnGameRunLevelChanged);
SubscribeNetworkEvent<BwoinkClientTypingUpdated>(OnClientTypingUpdated);

_rateLimit.Register(
RateLimitKey,
new RateLimitRegistration
{
CVarLimitPeriodLength = CCVars.AhelpRateLimitPeriod,
CVarLimitCount = CCVars.AhelpRateLimitCount,
PlayerLimitedAction = PlayerRateLimitedAction
});
}

private void PlayerRateLimitedAction(ICommonSession obj)
{
RaiseNetworkEvent(
new BwoinkTextMessage(obj.UserId, default, Loc.GetString("bwoink-system-rate-limited"), playSound: false),
obj.Channel);
}

private void OnOverrideChanged(string obj)
Expand Down Expand Up @@ -171,6 +150,15 @@ private void OnServerNameChanged(string obj)
_serverName = obj;
}

public override void Shutdown()
{
base.Shutdown();
_config.UnsubValueChanged(CCVars.DiscordAHelpWebhook, OnWebhookChanged);
_config.UnsubValueChanged(CCVars.DiscordAHelpFooterIcon, OnFooterIconChanged);
_config.UnsubValueChanged(CVars.GameHostName, OnServerNameChanged);
_config.UnsubValueChanged(CCVars.AdminAhelpOverrideClientName, OnOverrideChanged);
}

private async void OnWebhookChanged(string url)
{
_webhookUrl = url;
Expand All @@ -181,7 +169,7 @@ private async void OnWebhookChanged(string url)
return;

// Basic sanity check and capturing webhook ID and token
var match = DiscordRegex().Match(url);
var match = Regex.Match(url, @"^https://discord\.com/api/webhooks/(\d+)/((?!.*/).*)$");

if (!match.Success)
{
Expand Down Expand Up @@ -416,31 +404,24 @@ protected override void OnBwoinkTextMessage(BwoinkTextMessage message, EntitySes
return;
}

if (_rateLimit.CountAction(eventArgs.SenderSession, RateLimitKey) != RateLimitStatus.Allowed)
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]";
bwoinkText = $"[color=purple]{senderSession.Name}[/color]: {escapedText}";
}
else if (senderAdmin is not null && senderAdmin.HasFlag(AdminFlags.Adminhelp))
{
bwoinkText = $"[color=red]{senderSession.Name}[/color]";
bwoinkText = $"\\[{senderAdmin.Title}\\] [color=red]{senderSession.Name}[/color]: {escapedText}"; // сообщение админа
}
else
{
bwoinkText = $"{senderSession.Name}";
bwoinkText = $"{senderSession.Name}: {escapedText}";
}

bwoinkText = $"{(message.PlaySound ? "" : "(S) ")}{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);
var msg = new BwoinkTextMessage(message.UserId, senderSession.UserId, bwoinkText);

LogBwoink(msg);

Expand All @@ -464,20 +445,18 @@ protected override void OnBwoinkTextMessage(BwoinkTextMessage message, EntitySes
// 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.
{
overrideMsgText = $"[color=purple]{_overrideClientName}[/color]";
overrideMsgText = $"[color=purple]{_overrideClientName}[/color]: {escapedText}";
}
else if (senderAdmin is not null && senderAdmin.HasFlag(AdminFlags.Adminhelp))
{
overrideMsgText = $"[color=red]{_overrideClientName}[/color]";
overrideMsgText = $"[color=red]{_overrideClientName}[/color]: {escapedText}";
}
else
{
overrideMsgText = $"{senderSession.Name}"; // Not an admin, name is not overridden.
overrideMsgText = $"{senderSession.Name}: {escapedText}"; // Not an admin, name is not overridden.
}

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), session.Channel);
}
else
RaiseNetworkEvent(msg, session.Channel);
Expand All @@ -498,11 +477,9 @@ protected override void OnBwoinkTextMessage(BwoinkTextMessage message, EntitySes
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));
_messageQueues[msg.UserId].Enqueue(GenerateAHelpMessage(senderSession.Name, str, !personalChannel, _gameTicker.RoundDuration().ToString("hh\\:mm\\:ss"), _gameTicker.RunLevel, nonAfkAdmins.Count == 0));
}

EntityManager.SystemOrNull<GptAhelpSystem>()?.AddUserMessage(message.UserId, personalChannel, escapedText); // backmen: gpt

if (admins.Count != 0 || sendsWebhook)
return;

Expand All @@ -528,7 +505,7 @@ private IList<INetChannel> GetTargetAdmins()
.ToList();
}

private static string GenerateAHelpMessage(string username, string message, bool admin, string roundTime, GameRunLevel roundState, bool playedSound, bool noReceivers = false)
private static string GenerateAHelpMessage(string username, string message, bool admin, string roundTime, GameRunLevel roundState, bool noReceivers = false)
{
var stringbuilder = new StringBuilder();

Expand All @@ -541,12 +518,9 @@ private static string GenerateAHelpMessage(string username, string message, bool

if(roundTime != string.Empty && roundState == GameRunLevel.InRound)
stringbuilder.Append($" **{roundTime}**");
if (!playedSound)
stringbuilder.Append(" **(S)**");
stringbuilder.Append($" **{username}:** ");
stringbuilder.Append(message);
return stringbuilder.ToString();
}
}
}

Loading

0 comments on commit 404cc51

Please sign in to comment.