Skip to content

Commit

Permalink
Merge branch 'master' into 2.9
Browse files Browse the repository at this point in the history
  • Loading branch information
Citrinate committed Mar 11, 2024
2 parents d9b14c1 + a48e7b7 commit eb2ed5c
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 21 deletions.
14 changes: 12 additions & 2 deletions BoosterManager/AdapterBridge.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Reflection;
using ArchiSteamFarm.Core;
using ArchiSteamFarm.Steam;

// ASFEnhanced Adapter https://github.com/chr233/ASFEnhanceAdapterDemoPlugin

Expand All @@ -23,10 +24,19 @@ public static bool InitAdapter(string pluginName, string pluginId, string? cmdPr
}
}
}
} catch (Exception ex) {
ASF.ArchiLogger.LogGenericException(ex, "Community with ASFEnhance failed");
} catch (Exception) {
ASF.ArchiLogger.LogGenericDebug("Could not find ASFEnhance plugin");
}

return false;
}

internal static string? Response(Bot bot, EAccess access, ulong steamID, string message, string[] args) {
// ASFEnhance wants to intercept commands meant for this plugin, for the purpose of it's DisabledCmds config setting.
// Seems buggy though: https://github.com/Citrinate/FreePackages/issues/28
// Therefore I'm feeding it this dummy response function, as ASFEnhance requires that cmdHandler not be null.
// This disables DisabledCmds support, but should not effect PLUGINSUPDATE command support

return null;
}
}
10 changes: 2 additions & 8 deletions BoosterManager/BoosterManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,28 +16,22 @@ namespace BoosterManager {
public sealed class BoosterManager : IASF, IBotModules, IBotCommand2, IBotTradeOfferResults {
public string Name => nameof(BoosterManager);
public Version Version => typeof(BoosterManager).Assembly.GetName().Version ?? new Version("0");
private bool ASFEnhanceEnabled = false;

public Task OnLoaded() {
ASF.ArchiLogger.LogGenericInfo("BoosterManager ASF Plugin by Citrinate");

// ASFEnhanced Adapter https://github.com/chr233/ASFEnhanceAdapterDemoPlugin
var flag = BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic;
var handler = typeof(Commands).GetMethod(nameof(Commands.Response), flag);
var handler = typeof(AdapterBridge).GetMethod(nameof(AdapterBridge.Response), flag);
const string pluginId = nameof(BoosterManager);
const string cmdPrefix = "BOOSTERMANAGER";
const string repoName = "Citrinate/BoosterManager";
var registered = AdapterBridge.InitAdapter(Name, pluginId, cmdPrefix, repoName, handler);
ASFEnhanceEnabled = registered;
AdapterBridge.InitAdapter(Name, pluginId, cmdPrefix, repoName, handler);

return Task.CompletedTask;
}

public async Task<string?> OnBotCommand(Bot bot, EAccess access, string message, string[] args, ulong steamID = 0) {
if (ASFEnhanceEnabled) {
return null;
}

return await Commands.Response(bot, access, steamID, message, args).ConfigureAwait(false);
}

Expand Down
2 changes: 1 addition & 1 deletion BoosterManager/BoosterManager.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<Authors>Citrinate</Authors>
<AssemblyVersion>2.8.3</AssemblyVersion>
<AssemblyVersion>2.8.5</AssemblyVersion>
<Nullable>enable</Nullable>
<LangVersion>latest</LangVersion>
<TargetFramework>net8.0</TargetFramework>
Expand Down
2 changes: 1 addition & 1 deletion BoosterManager/Boosters/BoosterPageResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ internal BoosterPageResponse(Bot bot, IDocument? boosterPage) {

IEnumerable<Steam.BoosterInfo>? enumerableBoosters;
try {
enumerableBoosters = JsonSerializer.Deserialize<IEnumerable<Steam.BoosterInfo>>(info.Value, new JsonSerializerOptions { NumberHandling = System.Text.Json.Serialization.JsonNumberHandling.AllowReadingFromString });
enumerableBoosters = JsonSerializer.Deserialize<IEnumerable<Steam.BoosterInfo>>(info.Value);
} catch (JsonException ex) {
Bot.ArchiLogger.LogGenericError(ex.Message);

Expand Down
3 changes: 3 additions & 0 deletions BoosterManager/Commands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,9 @@ internal static class Commands {

case "BSTATUS" or "BOOSTERSTATUS":
return ResponseBoosterStatus(access, steamID, args[1]);

case "BSTATUS^" or "BOOSTERSTATUS^":
return ResponseBoosterStatus(access, steamID, args[1], true);

case "BSTOP" or "BOOSTERSTOP" when args.Length > 2:
return ResponseBoosterStop(access, steamID, args[1], Utilities.GetArgsAsText(args, 2, ","));
Expand Down
4 changes: 4 additions & 0 deletions BoosterManager/Docs/InventoryHistory.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ I feel the need to provide unofficial documentation here, because doing anything

Much of the inventory history is delivered as `html` that needs to be parsed.

> [!NOTE]
> The BoosterManager plugin does not, and likely never will, support parsing of `html`. The best I can do is to offer this incomplete list of possible history event descriptions.
Be aware that each of these descriptions describes a unique type of event. For example, "Listed on the Community Market" and "You listed an item on the Community Market." are different types of events, and not two different ways to describe the same event.
Expand Down Expand Up @@ -138,6 +139,7 @@ Not all gaps are as large as in the examples above. It's very common to have lo

In my experience, because small gaps tend to only happen due to market-related activity, they can be safely ignored, as market history is more accurately collected using the Market History API.

> [!NOTE]
> The BoosterManager plugin cannot detect this bug. You'll need to monitor the plugin's activity yourself to ensure there's no gaps. Within your `InventoryHistoryAPI`, `page - data["cursor"]["time"]` represents the size of the gap in seconds between the current page and the next page. Be aware that `data["cursor"]` [can be](#history-ends-early-bug) `null`. You can attempt to address this bug with your API by setting the `next_page` or `next_cursor` response parameters, telling the plugin which page you'd like it to fetch next.
## History Ends Early Bug
Expand All @@ -152,6 +154,7 @@ For example, assuming we have history older than `4/30/21`, this can happen:

This is resolved the same way as the [Missing History Bug](#missing-history-bug): by searching for history events at times past the cutoff.

> [!NOTE]
> The BoosterManager plugin will detect when the bug may have occurred. On the `InventoryHistoryAPI` side of things, the value for `data[cursor]` will be `null` when it receives a page with this bug on it. If your API does not send a `next_page` or `next_cursor` response parameter, then the plugin will stop running and send a link in the Steam Chat to the page where the bug occurred.
## Missing Descriptions Bugs
Expand All @@ -170,4 +173,5 @@ There's at least one instance where this type of error will never go away by rel

- Most events involving Steam Gems on or before December 12, 2014 will appear as "Unknown Asset" in place of the gems, and will have no `descriptions` entry. This is likely due to a gem duplication exploit and the resulting rollbacks.

> [!NOTE]
> The BoosterManager plugin does not detect these bugs. You can tell the plugin to refresh the page by sending back `cursor` and `page` in the `next_cursor` and `next_page` response parameters respectively.
13 changes: 7 additions & 6 deletions BoosterManager/Json.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ internal sealed class BoosterInfo {

[JsonInclude]
[JsonPropertyName("price")]
[JsonNumberHandling(JsonNumberHandling.AllowReadingFromString)]
[JsonRequired]
internal uint Price { get; private init; }

Expand Down Expand Up @@ -118,22 +119,22 @@ internal sealed class MarketListingsResponse {
[JsonInclude]
[JsonPropertyName("listings")]
[JsonRequired]
internal JsonArray? Listings { get; private init; }
internal List<JsonNode>? Listings { get; private init; }

[JsonInclude]
[JsonPropertyName("listings_on_hold")]
[JsonRequired]
internal JsonArray? ListingsOnHold { get; private init; } = new();
internal List<JsonNode>? ListingsOnHold { get; private init; } = new();

[JsonInclude]
[JsonPropertyName("listings_to_confirm")]
[JsonRequired]
internal JsonArray ListingsToConfirm { get; private init; } = new();
internal List<JsonNode> ListingsToConfirm { get; private init; } = new();

[JsonInclude]
[JsonPropertyName("buy_orders")]
[JsonRequired]
internal JsonArray BuyOrders { get; private init; } = new();
internal List<JsonNode> BuyOrders { get; private init; } = new();

[JsonConstructor]
private MarketListingsResponse() { }
Expand Down Expand Up @@ -167,7 +168,7 @@ internal sealed class MarketHistoryResponse {

[JsonInclude]
[JsonPropertyName("events")]
internal JsonArray? Events { get; private init; }
internal List<JsonNode>? Events { get; private init; }

[JsonInclude]
[JsonPropertyName("purchases")]
Expand Down Expand Up @@ -232,7 +233,7 @@ internal sealed class InventoryHistoryResponse {

[JsonInclude]
[JsonPropertyName("apps")]
internal JsonArray Apps { get; private init; } = new();
internal List<JsonNode> Apps { get; private init; } = new();

[JsonInclude]
[JsonPropertyName("cursor")]
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ This project is based off of the [Booster Creator Plugin](https://github.com/Rud
- Unpack the downloaded .zip file to the `plugins` folder inside your ASF folder.
- (Re)start ASF, you should get a message indicating that the plugin loaded successfully.

> **Note**
> [!NOTE]
> This plugin is only tested to work with ASF-generic. It may or may not work with other ASF variants, but feel free to report any issues you may encounter.
## Usage
Expand Down Expand Up @@ -220,7 +220,7 @@ Example:
"GamesToBooster": [730, 570],
```

> **Note**
> [!NOTE]
> It's not possible to remove any of these `AppIDs` from the booster queue using any commands. Any changes you want to make will need to be made in the configuration file.
---
Expand All @@ -235,7 +235,7 @@ Example:
"BoosterDelayBetweenBots": 60,
```

> **Note**
> [!NOTE]
> This is not recommended to be used except in the most extreme cases.
---
Expand Down

0 comments on commit eb2ed5c

Please sign in to comment.