Thanks @xPaw
This commit is contained in:
Łukasz Domeradzki 2024-04-09 16:33:54 +02:00
parent b965971c79
commit 42dec2de39
No known key found for this signature in database
GPG key ID: 6B138B4C64555AEA
9 changed files with 18 additions and 18 deletions

View file

@ -147,7 +147,7 @@ internal sealed class MonitoringPlugin : OfficialPlugin, IWebServiceProvider, IG
Meter.CreateObservableGauge(
$"{MetricNamePrefix}_bots", static () => {
IEnumerable<Bot> bots = Bot.Bots?.Values ?? Enumerable.Empty<Bot>();
IEnumerable<Bot> bots = Bot.Bots?.Values ?? [];
int onlineCount = 0;
int offlineCount = 0;
@ -177,7 +177,7 @@ internal sealed class MonitoringPlugin : OfficialPlugin, IWebServiceProvider, IG
Meter.CreateObservableGauge(
$"{MetricNamePrefix}_bot_friends", static () => {
IEnumerable<Bot> bots = Bot.Bots?.Values ?? Enumerable.Empty<Bot>();
IEnumerable<Bot> bots = Bot.Bots?.Values ?? [];
return bots.Where(static bot => bot.IsConnectedAndLoggedOn).Select(static bot => new Measurement<int>(bot.SteamFriends.GetFriendCount(), new KeyValuePair<string, object?>(TagNames.BotName, bot.BotName), new KeyValuePair<string, object?>(TagNames.SteamID, bot.SteamID)));
},
@ -186,7 +186,7 @@ internal sealed class MonitoringPlugin : OfficialPlugin, IWebServiceProvider, IG
Meter.CreateObservableGauge(
$"{MetricNamePrefix}_bot_clans", static () => {
IEnumerable<Bot> bots = Bot.Bots?.Values ?? Enumerable.Empty<Bot>();
IEnumerable<Bot> bots = Bot.Bots?.Values ?? [];
return bots.Where(static bot => bot.IsConnectedAndLoggedOn).Select(static bot => new Measurement<int>(bot.SteamFriends.GetClanCount(), new KeyValuePair<string, object?>(TagNames.BotName, bot.BotName), new KeyValuePair<string, object?>(TagNames.SteamID, bot.SteamID)));
},
@ -196,7 +196,7 @@ internal sealed class MonitoringPlugin : OfficialPlugin, IWebServiceProvider, IG
// Keep in mind that we use a unit here and the unit needs to be a suffix to the name
Meter.CreateObservableGauge(
$"{MetricNamePrefix}_bot_farming_time_remaining_{Units.Minutes}", static () => {
IEnumerable<Bot> bots = Bot.Bots?.Values ?? Enumerable.Empty<Bot>();
IEnumerable<Bot> bots = Bot.Bots?.Values ?? [];
return bots.Select(static bot => new Measurement<double>(bot.CardsFarmer.TimeRemaining.TotalMinutes, new KeyValuePair<string, object?>(TagNames.BotName, bot.BotName), new KeyValuePair<string, object?>(TagNames.SteamID, bot.SteamID)));
},
@ -206,7 +206,7 @@ internal sealed class MonitoringPlugin : OfficialPlugin, IWebServiceProvider, IG
Meter.CreateObservableGauge(
$"{MetricNamePrefix}_bot_heartbeat_failures", static () => {
IEnumerable<Bot> bots = Bot.Bots?.Values ?? Enumerable.Empty<Bot>();
IEnumerable<Bot> bots = Bot.Bots?.Values ?? [];
return bots.Select(static bot => new Measurement<byte>(bot.HeartBeatFailures, new KeyValuePair<string, object?>(TagNames.BotName, bot.BotName), new KeyValuePair<string, object?>(TagNames.SteamID, bot.SteamID)));
},
@ -215,7 +215,7 @@ internal sealed class MonitoringPlugin : OfficialPlugin, IWebServiceProvider, IG
Meter.CreateObservableGauge(
$"{MetricNamePrefix}_bot_wallet_balance", static () => {
IEnumerable<Bot> bots = Bot.Bots?.Values ?? Enumerable.Empty<Bot>();
IEnumerable<Bot> bots = Bot.Bots?.Values ?? [];
return bots.Where(static bot => bot.WalletCurrency != ECurrencyCode.Invalid).Select(static bot => new Measurement<long>(bot.WalletBalance, new KeyValuePair<string, object?>(TagNames.BotName, bot.BotName), new KeyValuePair<string, object?>(TagNames.SteamID, bot.SteamID), new KeyValuePair<string, object?>(TagNames.CurrencyCode, bot.WalletCurrency.ToString())));
},
@ -224,7 +224,7 @@ internal sealed class MonitoringPlugin : OfficialPlugin, IWebServiceProvider, IG
Meter.CreateObservableGauge(
$"{MetricNamePrefix}_bot_bgr_keys_remaining", static () => {
IEnumerable<Bot> bots = Bot.Bots?.Values ?? Enumerable.Empty<Bot>();
IEnumerable<Bot> bots = Bot.Bots?.Values ?? [];
return bots.Select(static bot => new Measurement<int>((int) bot.GamesToRedeemInBackgroundCount, new KeyValuePair<string, object?>(TagNames.BotName, bot.BotName), new KeyValuePair<string, object?>(TagNames.SteamID, bot.SteamID)));
},

View file

@ -385,7 +385,7 @@ internal sealed class SteamTokenDumperPlugin : OfficialPlugin, IASF, IBot, IBotC
SteamApps.PICSTokensCallback response;
try {
response = await bot.SteamApps.PICSGetAccessTokens(appIDsThisRound, Enumerable.Empty<uint>()).ToLongRunningTask().ConfigureAwait(false);
response = await bot.SteamApps.PICSGetAccessTokens(appIDsThisRound, []).ToLongRunningTask().ConfigureAwait(false);
} catch (Exception e) {
bot.ArchiLogger.LogGenericWarningException(e);
@ -426,7 +426,7 @@ internal sealed class SteamTokenDumperPlugin : OfficialPlugin, IASF, IBot, IBotC
AsyncJobMultiple<SteamApps.PICSProductInfoCallback>.ResultSet response;
try {
response = await bot.SteamApps.PICSGetProductInfo(appIDsThisRound.Select(static appID => new SteamApps.PICSRequest(appID, GlobalCache.GetAppToken(appID))), Enumerable.Empty<SteamApps.PICSRequest>()).ToLongRunningTask().ConfigureAwait(false);
response = await bot.SteamApps.PICSGetProductInfo(appIDsThisRound.Select(static appID => new SteamApps.PICSRequest(appID, GlobalCache.GetAppToken(appID))), []).ToLongRunningTask().ConfigureAwait(false);
} catch (Exception e) {
bot.ArchiLogger.LogGenericWarningException(e);

View file

@ -336,7 +336,7 @@ internal static class ArchiKestrel {
}
},
Array.Empty<string>()
[]
}
}
);

View file

@ -122,7 +122,7 @@ public sealed class NLogController : ArchiController {
}
while (webSocket.State == WebSocketState.Open) {
WebSocketReceiveResult result = await webSocket.ReceiveAsync(Array.Empty<byte>(), cancellationToken).ConfigureAwait(false);
WebSocketReceiveResult result = await webSocket.ReceiveAsync([], cancellationToken).ConfigureAwait(false);
if (result.MessageType != WebSocketMessageType.Close) {
await webSocket.CloseAsync(WebSocketCloseStatus.InvalidMessageType, "You're not supposed to be sending any message but Close!", cancellationToken).ConfigureAwait(false);

View file

@ -579,7 +579,7 @@ public static class PluginsCore {
return null;
}
return responses.Where(static response => response != null).SelectMany(static handlers => handlers ?? Enumerable.Empty<ClientMsgHandler>()).ToHashSet();
return responses.Where(static response => response != null).SelectMany(static handlers => handlers ?? []).ToHashSet();
}
internal static async Task<bool> OnBotTradeOffer(Bot bot, TradeOffer tradeOffer) {

View file

@ -1200,7 +1200,7 @@ public sealed class Bot : IAsyncDisposable, IDisposable {
for (byte i = 0; (i < WebBrowser.MaxTries) && (productInfoResultSet == null) && IsConnectedAndLoggedOn; i++) {
try {
productInfoResultSet = await SteamApps.PICSGetProductInfo(request.ToEnumerable(), Enumerable.Empty<SteamApps.PICSRequest>()).ToLongRunningTask().ConfigureAwait(false);
productInfoResultSet = await SteamApps.PICSGetProductInfo(request.ToEnumerable(), []).ToLongRunningTask().ConfigureAwait(false);
} catch (Exception e) {
ArchiLogger.LogGenericWarningException(e);
}
@ -1338,7 +1338,7 @@ public sealed class Bot : IAsyncDisposable, IDisposable {
for (byte i = 0; (i < WebBrowser.MaxTries) && (productInfoResultSet == null) && IsConnectedAndLoggedOn; i++) {
try {
productInfoResultSet = await SteamApps.PICSGetProductInfo(Enumerable.Empty<SteamApps.PICSRequest>(), packageRequests).ToLongRunningTask().ConfigureAwait(false);
productInfoResultSet = await SteamApps.PICSGetProductInfo([], packageRequests).ToLongRunningTask().ConfigureAwait(false);
} catch (Exception e) {
ArchiLogger.LogGenericWarningException(e);
}

View file

@ -507,7 +507,7 @@ public sealed class ArchiWebHandler : IDisposable {
return null;
}
IEnumerable<TradeOffer> trades = Enumerable.Empty<TradeOffer>();
IEnumerable<TradeOffer> trades = [];
if (receivedOffers.GetValueOrDefault(true)) {
trades = trades.Concat(response.TradeOffersReceived);

View file

@ -269,7 +269,7 @@ public sealed class Actions : IAsyncDisposable, IDisposable {
// We add extra delay because OnFarmingStopped() also executes PlayGames()
// Despite of proper order on our end, Steam network might not respect it
await Task.Delay(Bot.CallbackSleep).ConfigureAwait(false);
await Bot.ArchiHandler.PlayGames(Array.Empty<uint>(), Bot.BotConfig.CustomGamePlayedWhileIdle).ConfigureAwait(false);
await Bot.ArchiHandler.PlayGames([], Bot.BotConfig.CustomGamePlayedWhileIdle).ConfigureAwait(false);
}
if (resumeInSeconds > 0) {

View file

@ -647,8 +647,8 @@ public sealed class Commands {
break;
}
grantedApps ??= Array.Empty<uint>();
grantedPackages ??= Array.Empty<uint>();
grantedApps ??= [];
grantedPackages ??= [];
response.AppendLine(FormatBotResponse(string.Format(CultureInfo.CurrentCulture, Strings.BotAddLicenseWithItems, $"app/{gameID}", result, string.Join(", ", grantedApps.Select(static appID => $"app/{appID}").Union(grantedPackages.Select(static subID => $"sub/{subID}"))))));