Skip to content

Commit

Permalink
update to net6.0 and tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
Rudokhvist committed Dec 17, 2021
1 parent 790129e commit 8c3550c
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 34 deletions.
2 changes: 1 addition & 1 deletion ArchiSteamFarm
Submodule ArchiSteamFarm updated 288 files
46 changes: 19 additions & 27 deletions Selective-Loot-and-Transfer-Plugin/Class1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,31 +23,23 @@ public class Class1 : IBotCommand {
return null;
}

switch (args[0].ToUpperInvariant()) {
case "TRANSFER#" when args.Length > 3:
return await ResponseTransfer(steamID, args[1], args[2], Utilities.GetArgsAsText(args, 3, ",")).ConfigureAwait(false);
case "TRANSFER#" when args.Length > 2:
return await ResponseTransfer(bot, steamID, args[1], args[2]).ConfigureAwait(false);
case "LOOT#" when args.Length > 2:
return await ResponseLoot(steamID, args[1], Utilities.GetArgsAsText(args, 2, ",")).ConfigureAwait(false);
case "LOOT#":
return await ResponseLoot(bot, steamID, args[1]).ConfigureAwait(false);
case "TRANSFERM" when args.Length > 3:
return await ResponseTransfer(steamID, args[1], args[2], Utilities.GetArgsAsText(args, 3, ","),false).ConfigureAwait(false);
case "TRANSFERM" when args.Length > 2:
return await ResponseTransfer(bot, steamID, args[1], args[2],false).ConfigureAwait(false);
case "LOOTM" when args.Length > 2:
return await ResponseLoot(steamID, args[1], Utilities.GetArgsAsText(args, 2, ","),false).ConfigureAwait(false);
case "LOOTM":
return await ResponseLoot(bot, steamID, args[1],false).ConfigureAwait(false);

default:
return null;
}

return args[0].ToUpperInvariant() switch {
"TRANSFER#" when args.Length > 3 => await ResponseTransfer(steamID, args[1], args[2], Utilities.GetArgsAsText(args, 3, ",")).ConfigureAwait(false),
"TRANSFER#" when args.Length > 2 => await ResponseTransfer(bot, steamID, args[1], args[2]).ConfigureAwait(false),
"LOOT#" when args.Length > 2 => await ResponseLoot(steamID, args[1], Utilities.GetArgsAsText(args, 2, ",")).ConfigureAwait(false),
"LOOT#" => await ResponseLoot(bot, steamID, args[1]).ConfigureAwait(false),
"TRANSFERM" when args.Length > 3 => await ResponseTransfer(steamID, args[1], args[2], Utilities.GetArgsAsText(args, 3, ","), false).ConfigureAwait(false),
"TRANSFERM" when args.Length > 2 => await ResponseTransfer(bot, steamID, args[1], args[2], false).ConfigureAwait(false),
"LOOTM" when args.Length > 2 => await ResponseLoot(steamID, args[1], Utilities.GetArgsAsText(args, 2, ","), false).ConfigureAwait(false),
"LOOTM" => await ResponseLoot(bot, steamID, args[1], false).ConfigureAwait(false),
_ => null,
};
}

void IPlugin.OnLoaded() => ASF.ArchiLogger.LogGenericInfo("Selective Loot and Transfer Plugin by Ryzhehvost, powered by ginger cats");
public Task OnLoaded() {
ASF.ArchiLogger.LogGenericInfo("Selective Loot and Transfer Plugin by Ryzhehvost, powered by ginger cats");
return Task.CompletedTask;
}

private static async Task<string?> ResponseTransfer(Bot bot, ulong steamID, string mode, string botNameTo, bool sendNotMarketable = true) {
if ((steamID == 0) || string.IsNullOrEmpty(botNameTo) || string.IsNullOrEmpty(mode)) {
Expand Down Expand Up @@ -82,7 +74,7 @@ public class Class1 : IBotCommand {
return bot.Commands.FormatBotResponse(string.Format(ArchiSteamFarm.Localization.Strings.ErrorIsEmpty, nameof(modes)));
}

HashSet<Asset.EType> transferTypes = new HashSet<Asset.EType>();
HashSet<Asset.EType> transferTypes = new();

foreach (string singleMode in modes) {
switch (singleMode.ToUpper()) {
Expand Down Expand Up @@ -158,7 +150,7 @@ public class Class1 : IBotCommand {
break;
}

List<string?> responses = new List<string?>(results.Where(result => !string.IsNullOrEmpty(result)));
List<string?> responses = new(results.Where(result => !string.IsNullOrEmpty(result)));
return responses.Count > 0 ? string.Join("", responses) : null;
}

Expand Down Expand Up @@ -187,7 +179,7 @@ public class Class1 : IBotCommand {
return bot.Commands.FormatBotResponse(string.Format(ArchiSteamFarm.Localization.Strings.ErrorIsEmpty, nameof(modes)));
}

HashSet<Asset.EType> transferTypes = new HashSet<Asset.EType>();
HashSet<Asset.EType> transferTypes = new();

foreach (string singleMode in modes) {
switch (singleMode.ToUpper()) {
Expand Down Expand Up @@ -252,7 +244,7 @@ public class Class1 : IBotCommand {

IList<string?> results = await Utilities.InParallel(bots.Select(curbot => ResponseLoot(curbot, steamID, mode,sendNotMarketable))).ConfigureAwait(false);

List<string?> responses = new List<string?>(results.Where(result => !string.IsNullOrEmpty(result)));
List<string?> responses = new(results.Where(result => !string.IsNullOrEmpty(result)));

return responses.Count > 0 ? string.Join(Environment.NewLine, responses) : null;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Authors>Ryzhehvost</Authors>
<AssemblyVersion>0.0.3.0</AssemblyVersion>
<TargetFrameworks>net5.0;net48</TargetFrameworks>
<AssemblyVersion>0.0.4.0</AssemblyVersion>
<TargetFrameworks>net6.0;net48</TargetFrameworks>
<RootNamespace>Selective_Loot_and_Transfer_Plugin</RootNamespace>
<Nullable>enable</Nullable>
<LangVersion>latest</LangVersion>
Expand Down
2 changes: 1 addition & 1 deletion build.bat
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ if exist out rmdir /Q /S out

rem release generic version

dotnet publish -c "Release" -f "net5.0" -o "out/generic" "/p:LinkDuringPublish=false"
dotnet publish -c "Release" -f "net6.0" -o "out/generic" "/p:LinkDuringPublish=false"
mkdir .\out\%CurrDirName%
copy .\out\generic\%CurrDirName%.dll .\out\%CurrDirName%
7z a -tzip -mx7 .\out\%CurrDirName%.zip .\out\%CurrDirName%
Expand Down
6 changes: 3 additions & 3 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,21 +46,21 @@ fi

## hacks to allow building netf
if [[ $build_netf -eq 1 ]]; then
sed -i 's|<ItemGroup>|<ItemGroup Condition="'\''$(TargetFramework)'\'' == '\''net5.0'\''"><!--hacks-->|' $plugin_name/$plugin_name.csproj
sed -i 's|<ItemGroup>|<ItemGroup Condition="'\''$(TargetFramework)'\'' == '\''net6.0'\''"><!--hacks-->|' $plugin_name/$plugin_name.csproj
fi

## release generic version
dotnet restore
sync
dotnet publish -c "Release" -f net5.0 -o "out/generic" "/p:LinkDuringPublish=false"
dotnet publish -c "Release" -f net6.0 -o "out/generic" "/p:LinkDuringPublish=false"
mkdir ./out/$plugin_name
cp ./out/generic/$plugin_name.dll ./out/$plugin_name
7z a -tzip -mx7 ./out/$plugin_name.zip ./out/$plugin_name
rm -rf out/$plugin_name

## hacks to allow building netf
if [[ $build_netf -eq 1 ]]; then
sed -i 's|<ItemGroup Condition="'\''$(TargetFramework)'\'' == '\''net5.0'\''"><!--hacks-->|<ItemGroup Condition="'\''$(TargetFramework)'\'' == '\''net48'\''"><!--hacks-->|' $plugin_name/$plugin_name.csproj
sed -i 's|<ItemGroup Condition="'\''$(TargetFramework)'\'' == '\''net6.0'\''"><!--hacks-->|<ItemGroup Condition="'\''$(TargetFramework)'\'' == '\''net48'\''"><!--hacks-->|' $plugin_name/$plugin_name.csproj
fi

## release generic-netf version
Expand Down

0 comments on commit 8c3550c

Please sign in to comment.