Skip to content

Commit

Permalink
switch to organization
Browse files Browse the repository at this point in the history
  • Loading branch information
Rudokhvist committed Sep 16, 2024
1 parent 5d0debf commit 6b4a58e
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 5 deletions.
53 changes: 52 additions & 1 deletion ASFAchievementManager/ASFAchievementManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
using System.Collections.Concurrent;
using System.Text.Json;
using System.Globalization;
using ArchiSteamFarm.Web.GitHub.Data;
using ArchiSteamFarm.Web.GitHub;

namespace ASFAchievementManager;

Expand All @@ -23,7 +25,56 @@ internal sealed class ASFAchievementManager : IBotSteamClient, IBotCommand2, IAS

public static CultureInfo? AchievementsCulture { get; private set; }

public string RepositoryName => "Rudokhvist/ASFAchievementManager";
public string RepositoryName => "CatPoweredPlugins/ASFAchievementManager";

public async Task<Uri?> GetTargetReleaseURL(Version asfVersion, string asfVariant, bool asfUpdate, bool stable, bool forced) {
ArgumentNullException.ThrowIfNull(asfVersion);
ArgumentException.ThrowIfNullOrEmpty(asfVariant);

if (string.IsNullOrEmpty(RepositoryName)) {
ASF.ArchiLogger.LogGenericError(string.Format(CultureInfo.CurrentCulture, Strings.WarningFailedWithError, nameof(RepositoryName)));

return null;
}

ReleaseResponse? releaseResponse = await GitHubService.GetLatestRelease(RepositoryName, stable).ConfigureAwait(false);

if (releaseResponse == null) {
return null;
}

Version newVersion = new(releaseResponse.Tag);

if (!(Version.Major == newVersion.Major && Version.Minor == newVersion.Minor && Version.Build == newVersion.Build) && !(asfUpdate || forced)) {
ASF.ArchiLogger.LogGenericInfo(string.Format(CultureInfo.CurrentCulture, "New {0} plugin version {1} is only compatible with latest ASF version", Name, newVersion));
return null;
}


if (Version >= newVersion & !forced) {
ASF.ArchiLogger.LogGenericInfo(string.Format(CultureInfo.CurrentCulture, Strings.PluginUpdateNotFound, Name, Version, newVersion));

return null;
}

if (releaseResponse.Assets.Count == 0) {
ASF.ArchiLogger.LogGenericWarning(string.Format(CultureInfo.CurrentCulture, Strings.PluginUpdateNoAssetFound, Name, Version, newVersion));

return null;
}

ReleaseAsset? asset = await ((IGitHubPluginUpdates) this).GetTargetReleaseAsset(asfVersion, asfVariant, newVersion, releaseResponse.Assets).ConfigureAwait(false);

if ((asset == null) || !releaseResponse.Assets.Contains(asset)) {
ASF.ArchiLogger.LogGenericWarning(string.Format(CultureInfo.CurrentCulture, Strings.PluginUpdateNoAssetFound, Name, Version, newVersion));

return null;
}

ASF.ArchiLogger.LogGenericInfo(string.Format(CultureInfo.CurrentCulture, Strings.PluginUpdateFound, Name, Version, newVersion));

return asset.DownloadURL;
}

private static readonly char[] Separator = [','];

Expand Down
8 changes: 4 additions & 4 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@

<PropertyGroup>
<PluginName>ASFAchievementManager</PluginName>
<Version>1.0.0.0</Version>
<Version>1.0.0.1</Version>
</PropertyGroup>

<PropertyGroup>
<ApplicationIcon />
<Authors>Rudokhvist</Authors>
<Company>$(Authors)</Company>
<Copyright>Copyright © $([System.DateTime]::UtcNow.Year) $(Company)</Copyright>
<Description>$(PluginName)</Description>
<Company>CatPoweredPlugins</Company>
<Copyright>Copyright © $([System.DateTime]::UtcNow.Year) $(Authors)</Copyright>
<Description>$(PluginName) by $(Authors). This plugin is cat powered!</Description>
<PackageIcon />
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
<PackageProjectUrl>https://github.com/$(Company)/$(PluginName)</PackageProjectUrl>
Expand Down

0 comments on commit 6b4a58e

Please sign in to comment.