mirror of
https://github.com/JustArchiNET/ArchiSteamFarm.git
synced 2026-01-10 05:34:25 +00:00
Add BGR command + API info
@mrburrburr you might want to somehow make use of it (maybe show next to key icon? I don't know)
This commit is contained in:
@@ -78,6 +78,9 @@ namespace ArchiSteamFarm {
|
||||
[PublicAPI]
|
||||
public readonly Commands Commands;
|
||||
|
||||
[JsonProperty]
|
||||
public uint GamesToRedeemInBackgroundCount => BotDatabase?.GamesToRedeemInBackgroundCount ?? 0;
|
||||
|
||||
[JsonProperty]
|
||||
public bool IsConnectedAndLoggedOn => SteamClient?.SteamID != null;
|
||||
|
||||
|
||||
@@ -32,14 +32,16 @@ using Newtonsoft.Json;
|
||||
|
||||
namespace ArchiSteamFarm {
|
||||
internal sealed class BotDatabase : IDisposable {
|
||||
internal bool HasGamesToRedeemInBackground {
|
||||
internal uint GamesToRedeemInBackgroundCount {
|
||||
get {
|
||||
lock (GamesToRedeemInBackground) {
|
||||
return GamesToRedeemInBackground.Count > 0;
|
||||
return (uint) GamesToRedeemInBackground.Count;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal bool HasGamesToRedeemInBackground => GamesToRedeemInBackgroundCount > 0;
|
||||
|
||||
[JsonProperty(Required = Required.DisallowNull)]
|
||||
private readonly ConcurrentHashSet<ulong> BlacklistedFromTradesSteamIDs = new ConcurrentHashSet<ulong>();
|
||||
|
||||
|
||||
@@ -129,6 +129,9 @@ namespace ArchiSteamFarm {
|
||||
case "BALANCE":
|
||||
|
||||
return ResponseWalletBalance(steamID);
|
||||
case "BGR":
|
||||
|
||||
return ResponseBackgroundGamesRedeemer(steamID);
|
||||
case "BL":
|
||||
|
||||
return ResponseBlacklist(steamID);
|
||||
@@ -218,6 +221,9 @@ namespace ArchiSteamFarm {
|
||||
case "BALANCE":
|
||||
|
||||
return await ResponseWalletBalance(steamID, Utilities.GetArgsAsText(args, 1, ",")).ConfigureAwait(false);
|
||||
case "BGR":
|
||||
|
||||
return await ResponseBackgroundGamesRedeemer(steamID, Utilities.GetArgsAsText(args, 1, ",")).ConfigureAwait(false);
|
||||
case "BL":
|
||||
|
||||
return await ResponseBlacklist(steamID, Utilities.GetArgsAsText(args, 1, ",")).ConfigureAwait(false);
|
||||
@@ -890,6 +896,43 @@ namespace ArchiSteamFarm {
|
||||
return responses.Count > 0 ? string.Join(Environment.NewLine, responses) : null;
|
||||
}
|
||||
|
||||
private string ResponseBackgroundGamesRedeemer(ulong steamID) {
|
||||
if (steamID == 0) {
|
||||
Bot.ArchiLogger.LogNullError(nameof(steamID));
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!Bot.HasPermission(steamID, BotConfig.EPermission.Master)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
uint count = Bot.GamesToRedeemInBackgroundCount;
|
||||
|
||||
return FormatBotResponse(string.Format(Strings.BotGamesToRedeemInBackgroundCount, count));
|
||||
}
|
||||
|
||||
[ItemCanBeNull]
|
||||
private static async Task<string> ResponseBackgroundGamesRedeemer(ulong steamID, string botNames) {
|
||||
if ((steamID == 0) || string.IsNullOrEmpty(botNames)) {
|
||||
ASF.ArchiLogger.LogNullError(nameof(steamID) + " || " + nameof(botNames));
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
HashSet<Bot> bots = Bot.GetBots(botNames);
|
||||
|
||||
if ((bots == null) || (bots.Count == 0)) {
|
||||
return ASF.IsOwner(steamID) ? FormatStaticResponse(string.Format(Strings.BotNotFound, botNames)) : null;
|
||||
}
|
||||
|
||||
IList<string> results = await Utilities.InParallel(bots.Select(bot => Task.Run(() => bot.Commands.ResponseBackgroundGamesRedeemer(steamID)))).ConfigureAwait(false);
|
||||
|
||||
List<string> responses = new List<string>(results.Where(result => !string.IsNullOrEmpty(result)));
|
||||
|
||||
return responses.Count > 0 ? string.Join(Environment.NewLine, responses) : null;
|
||||
}
|
||||
|
||||
private string ResponseBlacklist(ulong steamID) {
|
||||
if (steamID == 0) {
|
||||
Bot.ArchiLogger.LogNullError(nameof(steamID));
|
||||
|
||||
9
ArchiSteamFarm/Localization/Strings.Designer.cs
generated
9
ArchiSteamFarm/Localization/Strings.Designer.cs
generated
@@ -312,6 +312,15 @@ namespace ArchiSteamFarm.Localization {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Wyszukuje zlokalizowany ciąg podobny do ciągu Bot has {0} games remaining in its background queue..
|
||||
/// </summary>
|
||||
public static string BotGamesToRedeemInBackgroundCount {
|
||||
get {
|
||||
return ResourceManager.GetString("BotGamesToRedeemInBackgroundCount", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Wyszukuje zlokalizowany ciąg podobny do ciągu Bot has no wallet..
|
||||
/// </summary>
|
||||
|
||||
@@ -713,4 +713,8 @@ StackTrace:
|
||||
<value>Response: {0}</value>
|
||||
<comment>{0} will be replaced by the generated response (string)</comment>
|
||||
</data>
|
||||
<data name="BotGamesToRedeemInBackgroundCount" xml:space="preserve">
|
||||
<value>Bot has {0} games remaining in its background queue.</value>
|
||||
<comment>{0} will be replaced by remaining number of games in BGR's queue</comment>
|
||||
</data>
|
||||
</root>
|
||||
Reference in New Issue
Block a user