Skip to content

Commit

Permalink
Merge branch '2.9'
Browse files Browse the repository at this point in the history
  • Loading branch information
Citrinate committed Apr 2, 2024
2 parents 104f6f2 + 14f6893 commit 4e746d5
Show file tree
Hide file tree
Showing 20 changed files with 1,412 additions and 489 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -488,3 +488,6 @@ $RECYCLE.BIN/

# Windows shortcuts
*.lnk

# https://www.paraesthesia.com/archive/2022/09/30/strongly-typed-resources-with-net-core/
*.Designer.cs
2 changes: 1 addition & 1 deletion ArchiSteamFarm
Submodule ArchiSteamFarm updated 278 files
42 changes: 0 additions & 42 deletions BoosterManager/AdapterBridge.cs

This file was deleted.

18 changes: 8 additions & 10 deletions BoosterManager/BoosterManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,18 @@
using ArchiSteamFarm.Steam.Exchange;
using System.Text.Json;
using ArchiSteamFarm.Helpers.Json;
using System.Reflection;

namespace BoosterManager {
[Export(typeof(IPlugin))]
public sealed class BoosterManager : IASF, IBotModules, IBotCommand2, IBotTradeOfferResults {
public sealed class BoosterManager : IASF, IBotModules, IBotCommand2, IBotTradeOfferResults, IGitHubPluginUpdates {
public string Name => nameof(BoosterManager);
public string RepositoryName => "Citrinate/BoosterManager";
public bool CanUpdate => !BoosterHandler.IsCraftingOneTimeBoosters();
public Version Version => typeof(BoosterManager).Assembly.GetName().Version ?? new Version("0");

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(AdapterBridge).GetMethod(nameof(AdapterBridge.Response), flag);
const string pluginId = nameof(BoosterManager);
const string cmdPrefix = "BOOSTERMANAGER";
const string repoName = "Citrinate/BoosterManager";
AdapterBridge.InitAdapter(Name, pluginId, cmdPrefix, repoName, handler);

return Task.CompletedTask;
}

Expand All @@ -47,6 +40,11 @@ public Task OnASFInit(IReadOnlyDictionary<string, JsonElement>? additionalConfig
BoosterHandler.AllowCraftUntradableBoosters = configProperty.Value.GetBoolean();
break;
}
case "AllowCraftUnmarketableBoosters" when (configProperty.Value.ValueKind == JsonValueKind.True || configProperty.Value.ValueKind == JsonValueKind.False): {
ASF.ArchiLogger.LogGenericInfo("Allow Craft Unmarketable Boosters : " + configProperty.Value);
BoosterHandler.AllowCraftUnmarketableBoosters = configProperty.Value.GetBoolean();
break;
}
case "BoosterDelayBetweenBots" when configProperty.Value.ValueKind == JsonValueKind.Number: {
ASF.ArchiLogger.LogGenericInfo("Booster Delay Between Bots : " + configProperty.Value);
BoosterHandler.UpdateBotDelays(configProperty.Value.GetInt32());
Expand Down
15 changes: 14 additions & 1 deletion BoosterManager/BoosterManager.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@

<PropertyGroup>
<Authors>Citrinate</Authors>
<AssemblyVersion>2.8.6</AssemblyVersion>
<AssemblyVersion>2.9.0.0</AssemblyVersion>
<Nullable>enable</Nullable>
<LangVersion>latest</LangVersion>
<TargetFramework>net8.0</TargetFramework>
<Deterministic>true</Deterministic>
<CoreCompileDependsOn>PrepareResources;$(CompileDependsOn)</CoreCompileDependsOn>
</PropertyGroup>

<ItemGroup>
Expand All @@ -17,4 +18,16 @@
<ProjectReference Include="..\ArchiSteamFarm\ArchiSteamFarm\ArchiSteamFarm.csproj" />
</ItemGroup>

<!-- https://www.paraesthesia.com/archive/2022/09/30/strongly-typed-resources-with-net-core/ -->
<ItemGroup>
<EmbeddedResource Update="Localization\Strings.resx">
<Generator>MSBuild:Compile</Generator>
<LastGenOutput>Strings.Designer.cs</LastGenOutput>
<StronglyTypedFileName>$(IntermediateOutputPath)\Strings.Designer.cs</StronglyTypedFileName>
<StronglyTypedLanguage>CSharp</StronglyTypedLanguage>
<StronglyTypedNamespace>BoosterManager.Localization</StronglyTypedNamespace>
<StronglyTypedClassName>Strings</StronglyTypedClassName>
</EmbeddedResource>
</ItemGroup>

</Project>
3 changes: 1 addition & 2 deletions BoosterManager/Boosters/BoosterDatabase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
using ArchiSteamFarm.Core;
using ArchiSteamFarm.Helpers;
using ArchiSteamFarm.Helpers.Json;
using ArchiSteamFarm.Localization;

namespace BoosterManager {
internal sealed class BoosterDatabase : SerializableFile {
Expand Down Expand Up @@ -41,7 +40,7 @@ private BoosterDatabase(string filePath) : this() {
string json = File.ReadAllText(filePath);

if (string.IsNullOrEmpty(json)) {
ASF.ArchiLogger.LogGenericError(string.Format(Strings.ErrorIsEmpty, nameof(json)));
ASF.ArchiLogger.LogGenericError(string.Format(ArchiSteamFarm.Localization.Strings.ErrorIsEmpty, nameof(json)));

return null;
}
Expand Down
11 changes: 5 additions & 6 deletions BoosterManager/Boosters/BoosterPageResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using System.Text.Json;
using System.Text.RegularExpressions;
using AngleSharp.Dom;
using ArchiSteamFarm.Localization;
using ArchiSteamFarm.Steam;

namespace BoosterManager {
Expand All @@ -25,8 +24,9 @@ internal BoosterPageResponse(Bot bot, IDocument? boosterPage) {

MatchCollection gooAmounts = Regex.Matches(boosterPage.Source.Text, "(?<=parseFloat\\( \")[0-9]+");
Match info = Regex.Match(boosterPage.Source.Text, "\\[\\{\"[\\s\\S]*\"}]");

if (!info.Success || (gooAmounts.Count != 3)) {
Bot.ArchiLogger.LogGenericError(string.Format(Strings.ErrorParsingObject, boosterPage));
Bot.ArchiLogger.LogGenericError(string.Format(ArchiSteamFarm.Localization.Strings.ErrorParsingObject, boosterPage));

throw new Exception();
}
Expand All @@ -38,11 +38,10 @@ internal BoosterPageResponse(Bot bot, IDocument? boosterPage) {
IEnumerable<Steam.BoosterInfo>? enumerableBoosters;
try {
enumerableBoosters = JsonSerializer.Deserialize<IEnumerable<Steam.BoosterInfo>>(info.Value);
} catch (JsonException ex) {
Bot.ArchiLogger.LogGenericError(ex.Message);

throw new Exception();
} catch (JsonException) {
throw;
}

if (enumerableBoosters == null) {
Bot.ArchiLogger.LogNullError(enumerableBoosters);

Expand Down
Loading

0 comments on commit 4e746d5

Please sign in to comment.