From e0f9fe3555d94e49d13b7b33f4480747c9e14d38 Mon Sep 17 00:00:00 2001 From: Archi Date: Tue, 24 Jan 2023 01:29:55 +0100 Subject: [PATCH] Skip empty nickname in self persona state callback --- .../RemoteCommunication.cs | 2 +- ArchiSteamFarm/Steam/Bot.cs | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/ArchiSteamFarm.OfficialPlugins.ItemsMatcher/RemoteCommunication.cs b/ArchiSteamFarm.OfficialPlugins.ItemsMatcher/RemoteCommunication.cs index b5057b2f7..68563a077 100644 --- a/ArchiSteamFarm.OfficialPlugins.ItemsMatcher/RemoteCommunication.cs +++ b/ArchiSteamFarm.OfficialPlugins.ItemsMatcher/RemoteCommunication.cs @@ -320,7 +320,7 @@ internal sealed class RemoteCommunication : IAsyncDisposable, IDisposable { SignedInWithSteam = true; } - Bot.ArchiLogger.LogGenericInfo(string.Format(CultureInfo.CurrentCulture, Localization.Strings.ListingAnnouncing, Bot.SteamID, nickname, assetsForListing.Count)); + Bot.ArchiLogger.LogGenericInfo(string.Format(CultureInfo.CurrentCulture, Localization.Strings.ListingAnnouncing, Bot.SteamID, nickname ?? Bot.SteamID.ToString(CultureInfo.InvariantCulture), assetsForListing.Count)); // ReSharper disable once RedundantSuppressNullableWarningExpression - required for .NET Framework BasicResponse? response = await Backend.AnnounceForListing(Bot.SteamID, WebBrowser, assetsForListing, acceptedMatchableTypes, (uint) inventory.Count, matchEverything, tradeToken!, nickname, avatarHash).ConfigureAwait(false); diff --git a/ArchiSteamFarm/Steam/Bot.cs b/ArchiSteamFarm/Steam/Bot.cs index 8e1cfab4e..1841fa18d 100644 --- a/ArchiSteamFarm/Steam/Bot.cs +++ b/ArchiSteamFarm/Steam/Bot.cs @@ -3000,11 +3000,12 @@ public sealed class Bot : IAsyncDisposable, IDisposable { return; } - Nickname = callback.Name; + // Empty name should be converted to null, this is actually lack of value, but it's transmitted as empty in protobufs + Nickname = !string.IsNullOrEmpty(callback.Name) ? callback.Name : null; string? avatarHash = null; - if ((callback.AvatarHash?.Length > 0) && callback.AvatarHash.Any(static singleByte => singleByte != 0)) { + if ((callback.AvatarHash?.Length > 0) && callback.AvatarHash.Any(static singleByte => singleByte > 0)) { #pragma warning disable CA1308 // False positive, we're intentionally converting this part to lowercase and it's not used for any security decisions based on the result of the normalization avatarHash = Convert.ToHexString(callback.AvatarHash).ToLowerInvariant(); #pragma warning restore CA1308 // False positive, we're intentionally converting this part to lowercase and it's not used for any security decisions based on the result of the normalization