Skip to content

Commit 1ecb859

Browse files
committed
switch to organization
1 parent 6d4cb60 commit 1ecb859

File tree

5 files changed

+97
-60
lines changed

5 files changed

+97
-60
lines changed

ArchiSteamFarm

Submodule ArchiSteamFarm updated 446 files

CommandlessRedeem/CommandAliasPlugin.csproj

Lines changed: 0 additions & 18 deletions
This file was deleted.

CommandlessRedeem/CommandlessRedeem.cs

Lines changed: 72 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,33 +3,87 @@
33
using System.Threading.Tasks;
44
using ArchiSteamFarm.Core;
55
using ArchiSteamFarm.Steam;
6+
using ArchiSteamFarm.Localization;
67
using ArchiSteamFarm.Plugins.Interfaces;
8+
using ArchiSteamFarm.Web.GitHub.Data;
9+
using ArchiSteamFarm.Web.GitHub;
10+
using System.Globalization;
711

8-
namespace CommandlessRedeem {
9-
[Export(typeof(IPlugin))]
10-
public sealed class CommandlessRedeem : IBotMessage, IBotCommand2 {
11-
public string Name => nameof(CommandlessRedeem);
12-
public Version Version => typeof(CommandlessRedeem).Assembly.GetName().Version ?? new Version("0");
12+
namespace CommandlessRedeem;
13+
[Export(typeof(IPlugin))]
14+
internal sealed class CommandlessRedeem : IBotMessage, IBotCommand2, IGitHubPluginUpdates {
15+
public string Name => nameof(CommandlessRedeem);
16+
public Version Version => typeof(CommandlessRedeem).Assembly.GetName().Version ?? new Version("0");
1317

14-
public Task OnLoaded() {
15-
ASF.ArchiLogger.LogGenericInfo("Commandless Redeem Plugin by Rudokhvist, powered by ginger cats");
16-
return Task.CompletedTask;
18+
public string RepositoryName => "CatPoweredPlugins/CommandlessRedeem";
19+
20+
public async Task<Uri?> GetTargetReleaseURL(Version asfVersion, string asfVariant, bool asfUpdate, bool stable, bool forced) {
21+
ArgumentNullException.ThrowIfNull(asfVersion);
22+
ArgumentException.ThrowIfNullOrEmpty(asfVariant);
23+
24+
if (string.IsNullOrEmpty(RepositoryName)) {
25+
ASF.ArchiLogger.LogGenericError(string.Format(CultureInfo.CurrentCulture, Strings.WarningFailedWithError, nameof(RepositoryName)));
26+
27+
return null;
28+
}
29+
30+
ReleaseResponse? releaseResponse = await GitHubService.GetLatestRelease(RepositoryName, stable).ConfigureAwait(false);
31+
32+
if (releaseResponse == null) {
33+
return null;
34+
}
35+
36+
Version newVersion = new(releaseResponse.Tag);
37+
38+
if (!(Version.Major == newVersion.Major && Version.Minor == newVersion.Minor && Version.Build == newVersion.Build) && !(asfUpdate || forced)) {
39+
ASF.ArchiLogger.LogGenericInfo(string.Format(CultureInfo.CurrentCulture, "New {0} plugin version {1} is only compatible with latest ASF version", Name, newVersion));
40+
return null;
41+
}
42+
43+
44+
if (Version >= newVersion & !forced) {
45+
ASF.ArchiLogger.LogGenericInfo(string.Format(CultureInfo.CurrentCulture, Strings.PluginUpdateNotFound, Name, Version, newVersion));
46+
47+
return null;
1748
}
1849

19-
public Task<string?> OnBotMessage(Bot bot, ulong steamID, string message) => HandleMessageInternal(bot, bot.GetAccess(steamID), message);
50+
if (releaseResponse.Assets.Count == 0) {
51+
ASF.ArchiLogger.LogGenericWarning(string.Format(CultureInfo.CurrentCulture, Strings.PluginUpdateNoAssetFound, Name, Version, newVersion));
2052

21-
public static async Task<string?> HandleMessageInternal(Bot bot, EAccess access, string message) {
22-
if (access < EAccess.Operator) {
23-
return null;
24-
}
53+
return null;
54+
}
55+
56+
ReleaseAsset? asset = await ((IGitHubPluginUpdates) this).GetTargetReleaseAsset(asfVersion, asfVariant, newVersion, releaseResponse.Assets).ConfigureAwait(false);
2557

26-
if (!Utilities.IsValidCdKey(message.Split((char[]?) null, StringSplitOptions.RemoveEmptyEntries)[0])) {
27-
return null;
28-
}
58+
if ((asset == null) || !releaseResponse.Assets.Contains(asset)) {
59+
ASF.ArchiLogger.LogGenericWarning(string.Format(CultureInfo.CurrentCulture, Strings.PluginUpdateNoAssetFound, Name, Version, newVersion));
2960

30-
return await bot.Commands.Response(access, "r " + bot.BotName + " " + message).ConfigureAwait(false);
61+
return null;
3162
}
3263

33-
public Task<string?> OnBotCommand(Bot bot, EAccess access, string message, string[] args, ulong steamID = 0) => HandleMessageInternal(bot, access, string.Join(" ", args));
64+
ASF.ArchiLogger.LogGenericInfo(string.Format(CultureInfo.CurrentCulture, Strings.PluginUpdateFound, Name, Version, newVersion));
65+
66+
return asset.DownloadURL;
3467
}
68+
69+
public Task OnLoaded() {
70+
ASF.ArchiLogger.LogGenericInfo("Commandless Redeem Plugin by Rudokhvist, powered by ginger cats");
71+
return Task.CompletedTask;
72+
}
73+
74+
public Task<string?> OnBotMessage(Bot bot, ulong steamID, string message) => HandleMessageInternal(bot, bot.GetAccess(steamID), message);
75+
76+
public static async Task<string?> HandleMessageInternal(Bot bot, EAccess access, string message) {
77+
if (access < EAccess.Operator) {
78+
return null;
79+
}
80+
81+
if (!Utilities.IsValidCdKey(message.Split((char[]?) null, StringSplitOptions.RemoveEmptyEntries)[0])) {
82+
return null;
83+
}
84+
85+
return await bot.Commands.Response(access, "r " + bot.BotName + " " + message).ConfigureAwait(false);
86+
}
87+
88+
public Task<string?> OnBotCommand(Bot bot, EAccess access, string message, string[] args, ulong steamID = 0) => HandleMessageInternal(bot, access, string.Join(" ", args));
3589
}
Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,18 @@
11
<Project Sdk="Microsoft.NET.Sdk">
2+
<PropertyGroup>
3+
<OutputType>Library</OutputType>
4+
</PropertyGroup>
25

3-
<PropertyGroup>
4-
<Authors>Rudokhvist</Authors>
5-
<AssemblyVersion>0.5.2.0</AssemblyVersion>
6-
<TargetFrameworks>net7.0;net481</TargetFrameworks>
7-
<Nullable>enable</Nullable>
8-
<LangVersion>latest</LangVersion>
9-
</PropertyGroup>
6+
<ItemGroup>
7+
<PackageReference Include="JetBrains.Annotations" PrivateAssets="all" />
8+
<PackageReference Include="System.Composition.AttributedModel" IncludeAssets="compile" />
9+
</ItemGroup>
1010

11-
<ItemGroup>
12-
<PackageReference Include="System.Composition.AttributedModel" Version="*" />
13-
</ItemGroup>
14-
15-
<ItemGroup>
16-
<ProjectReference Include="..\ArchiSteamFarm\ArchiSteamFarm\ArchiSteamFarm.csproj" />
17-
</ItemGroup>
11+
<ItemGroup>
12+
<ProjectReference Include="..\ArchiSteamFarm\ArchiSteamFarm\ArchiSteamFarm.csproj" ExcludeAssets="all" Private="false" />
13+
</ItemGroup>
1814

15+
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
16+
<Copy SourceFiles="$(TargetPath)" DestinationFolder="..\ArchiSteamFarm\ArchiSteamFarm\bin\$(Configuration)\$(TargetFramework)\plugins\" SkipUnchangedFiles="true" />
17+
</Target>
1918
</Project>

build.bat

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,19 @@ if exist out rmdir /Q /S out
2121

2222
rem release generic version
2323

24-
dotnet publish -c "Release" -f "net7.0" -o "out/generic" "/p:LinkDuringPublish=false"
24+
dotnet publish -c "Release" -f "net8.0" -o "out/generic" "/p:LinkDuringPublish=false"
2525
mkdir .\out\%CurrDirName%
2626
copy .\out\generic\%CurrDirName%.dll .\out\%CurrDirName%
27+
rem comment section below (downto :zip label) if you don't want to include documentation
28+
if not exist README.md (goto zip)
29+
where /q pandoc.exe
30+
if ERRORLEVEL 1 (
31+
copy README.md .\out\%CurrDirName%
32+
goto zip
33+
) else (
34+
pandoc --metadata title="%CurrDirName%" --standalone --columns 2000 -f markdown -t html --self-contained -c .\github-pandoc.css -o .\out\%CurrDirName%\README.html README.md
35+
)
36+
:zip
2737
7z a -tzip -mx7 .\out\%CurrDirName%.zip .\out\%CurrDirName%
2838
rmdir /Q /S out\%CurrDirName%
2939

30-
rem release generic-netf version
31-
rem comment section below if you don't target netf ASF version
32-
33-
dotnet publish -c "Release" -f "net481" -o "out/generic-netf"
34-
mkdir .\out\%CurrDirName%
35-
copy .\out\generic-netf\%CurrDirName%.dll .\out\%CurrDirName%
36-
7z a -tzip -mx7 .\out\%CurrDirName%-netf.zip .\out\%CurrDirName%
37-
rmdir /Q /S out\%CurrDirName%

0 commit comments

Comments
 (0)