Skip to content

Commit

Permalink
remove net48, bump, fix warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
ezhevita committed Feb 27, 2024
1 parent cdd39f8 commit 5d4bed8
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 22 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.DS_Store
.idea
[Bb]in/
[Oo]bj/
[Oo]bj/
6 changes: 1 addition & 5 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
<Project>

<ItemGroup>
<PackageVersion Include="AngleSharp" Version="1.1.0" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net48'">
<PackageVersion Include="IndexRange" Version="1.0.3" />
<PackageVersion Include="AngleSharp" Version="1.0.2" />
</ItemGroup>

<Import Project="ArchiSteamFarm/Directory.Packages.props" />
Expand Down
2 changes: 1 addition & 1 deletion GameRemover/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<PropertyGroup>
<Description>ASF plugin to remove games from account.</Description>
<Version>2.2.1.0</Version>
<Version>2.3.0</Version>
</PropertyGroup>

<Import Project="$([MSBuild]::GetPathOfFileAbove('Directory.Build.props', '$(MSBuildThisFileDirectory)../'))"/>
Expand Down
12 changes: 4 additions & 8 deletions GameRemover/GameRemover.csproj
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">

<ItemGroup>
<PackageReference Include="AngleSharp" IncludeAssets="compile" />
<PackageReference Include="JetBrains.Annotations" IncludeAssets="compile" />
<PackageReference Include="System.Composition.AttributedModel" IncludeAssets="compile" />
<ProjectReference Include="..\ArchiSteamFarm\ArchiSteamFarm\ArchiSteamFarm.csproj" Private="false" ExcludeAssets="all" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net48'">
<PackageReference Include="IndexRange" IncludeAssets="compile" />
<PackageReference Include="AngleSharp" IncludeAssets="compile"/>
<PackageReference Include="JetBrains.Annotations" IncludeAssets="compile"/>
<PackageReference Include="System.Composition.AttributedModel" IncludeAssets="compile"/>
<ProjectReference Include="..\ArchiSteamFarm\ArchiSteamFarm\ArchiSteamFarm.csproj" Private="false" ExcludeAssets="all"/>
</ItemGroup>

</Project>
18 changes: 11 additions & 7 deletions GameRemover/GameRemoverPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Globalization;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using AngleSharp.Dom;
using ArchiSteamFarm.Core;
Expand All @@ -22,6 +23,10 @@ namespace GameRemover;
[UsedImplicitly]
public class GameRemoverPlugin : IBotCommand2
{
private static readonly CompositeFormat ErrorIsInvalid = CompositeFormat.Parse(Strings.ErrorIsInvalid);
private static readonly CompositeFormat ErrorObjectIsNull = CompositeFormat.Parse(Strings.ErrorObjectIsNull);
private static readonly CompositeFormat BotNotFound = CompositeFormat.Parse(Strings.BotNotFound);

public Task OnLoaded()
{
ASF.ArchiLogger.LogGenericInfo($"{Name} by ezhevita | Support & source code: https://github.com/ezhevita/{Name}");
Expand Down Expand Up @@ -59,30 +64,29 @@ public Task OnLoaded()
{
if (!uint.TryParse(appIDText, out var appID) || (appID == 0) || !appIDs.Add(appID))
{
return bot.Commands.FormatBotResponse(string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsInvalid, appIDText));
return bot.Commands.FormatBotResponse(string.Format(CultureInfo.CurrentCulture, ErrorIsInvalid, appIDText));
}
}

ushort successCount = 0;
foreach (var appID in appIDs)
{
const string RequestDeleteGamePage = "/en/wizard/HelpWithGameIssue/?appid={0}&issueid=123";
Uri uriDeleteGamePage = new(ArchiWebHandler.SteamHelpURL, string.Format(CultureInfo.InvariantCulture, RequestDeleteGamePage, appID));
Uri uriDeleteGamePage = new(ArchiWebHandler.SteamHelpURL, $"/en/wizard/HelpWithGameIssue/?appid={appID}&issueid=123");
using var responseDeleteGamePage = (await bot.ArchiWebHandler.UrlGetToHtmlDocumentWithSession(uriDeleteGamePage).ConfigureAwait(false))?.Content;
if (responseDeleteGamePage == null)
{
return bot.Commands.FormatBotResponse(string.Format(CultureInfo.CurrentCulture, Strings.ErrorObjectIsNull, nameof(responseDeleteGamePage)));
return bot.Commands.FormatBotResponse(string.Format(CultureInfo.CurrentCulture, ErrorObjectIsNull, nameof(responseDeleteGamePage)));
}

var node = responseDeleteGamePage.SelectSingleNode<IElement>("//input[@id='packageid']");
if (node == null)
{
return bot.Commands.FormatBotResponse(string.Format(CultureInfo.CurrentCulture, Strings.ErrorObjectIsNull, nameof(node)));
return bot.Commands.FormatBotResponse(string.Format(CultureInfo.CurrentCulture, ErrorObjectIsNull, nameof(node)));
}

if (!uint.TryParse(node.GetAttribute("value"), out var packageID) || (packageID == 0))
{
return bot.Commands.FormatBotResponse(string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsInvalid, nameof(packageID)));
return bot.Commands.FormatBotResponse(string.Format(CultureInfo.CurrentCulture, ErrorIsInvalid, nameof(packageID)));
}

Dictionary<string, string> data = new(3)
Expand All @@ -106,7 +110,7 @@ public Task OnLoaded()
var bots = Bot.GetBots(botNames);
if ((bots == null) || (bots.Count == 0))
{
return access >= EAccess.Owner ? Commands.FormatStaticResponse(string.Format(CultureInfo.CurrentCulture, Strings.BotNotFound, botNames)) : null;
return access >= EAccess.Owner ? Commands.FormatStaticResponse(string.Format(CultureInfo.CurrentCulture, BotNotFound, botNames)) : null;
}

var results = await Utilities.InParallel(bots.Select(bot => ResponseDeleteGame(bot, Commands.GetProxyAccess(bot, access, steamID), appIDsText))).ConfigureAwait(false);
Expand Down

0 comments on commit 5d4bed8

Please sign in to comment.