Skip to content

Commit

Permalink
优化文件格式
Browse files Browse the repository at this point in the history
修复bug
优化命令输出格式
  • Loading branch information
chr233 committed Jun 8, 2022
1 parent 1c1daec commit 0a32d47
Show file tree
Hide file tree
Showing 12 changed files with 33 additions and 32 deletions.
5 changes: 4 additions & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -207,4 +207,7 @@ end_of_line = crlf
dotnet_style_qualification_for_field = true:suggestion
dotnet_style_qualification_for_property = false:suggestion
dotnet_style_qualification_for_method = false:silent
dotnet_style_qualification_for_event = false:silent
dotnet_style_qualification_for_event = false:silent

# Default severity for analyzer diagnostics with category 'Style'
dotnet_analyzer_diagnostic.category-Style.severity = silent
4 changes: 2 additions & 2 deletions ASFEnhance/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using System.Reflection;

[assembly: System.CLSCompliant(false)]
[assembly: AssemblyVersion("1.6.4.465")]
[assembly: AssemblyFileVersion("1.6.4.465")]
[assembly: AssemblyVersion("1.6.4.469")]
[assembly: AssemblyFileVersion("1.6.4.469")]

[assembly: AssemblyCopyright("Copyright © 2022 Chr_")]
[assembly: AssemblyProduct("ASFEnhance")]
Expand Down
12 changes: 6 additions & 6 deletions ASFEnhance/Cart/Command.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,16 @@ internal static class Command

if (cartResponse.CartItems.Count > 0)
{
response.AppendLine(Langs.MultipleLineResult);
response.AppendLine(bot.FormatBotResponse(string.Format(Langs.CartTotalPrice, cartResponse.TotalPrice / 100.0, walletCurrency)));
response.AppendLine(bot.FormatBotResponse(Langs.MultipleLineResult));
response.AppendLine(string.Format(Langs.CartTotalPrice, cartResponse.TotalPrice / 100.0, walletCurrency));

foreach (var cartItem in cartResponse.CartItems)
{
response.AppendLine(string.Format(Langs.CartItemInfo, cartItem.GameID, cartItem.Name, cartItem.Price / 100.0));
}

response.AppendLine(bot.FormatBotResponse(string.Format(Langs.CartPurchaseSelf, cartResponse.PurchaseForSelf ? "√" : "×")));
response.AppendLine(bot.FormatBotResponse(string.Format(Langs.CartPurchaseGift, cartResponse.PurchaseAsGift ? "√" : "×")));
response.AppendLine(string.Format(Langs.CartPurchaseSelf, cartResponse.PurchaseForSelf ? "√" : "×"));
response.AppendLine(string.Format(Langs.CartPurchaseGift, cartResponse.PurchaseAsGift ? "√" : "×"));
}
else
{
Expand Down Expand Up @@ -109,7 +109,6 @@ internal static class Command
Dictionary<string, SteamGameID> gameIDs = FetchGameIDs(query, SteamGameIDType.Sub);

StringBuilder response = new();
response.AppendLine(Langs.MultipleLineResult);

foreach (KeyValuePair<string, SteamGameID> item in gameIDs)
{
Expand All @@ -123,13 +122,14 @@ internal static class Command
case SteamGameIDType.Sub:
case SteamGameIDType.Bundle:
bool? success = await WebRequest.AddCart(bot, gameID).ConfigureAwait(false);
response.AppendLine(bot.FormatBotResponse(string.Format(Strings.BotAddLicense, input, success == null ? Langs.CartNetworkError : (bool)success ? EResult.OK : EResult.Fail)));
response.AppendLine(bot.FormatBotResponse(string.Format(Strings.BotAddLicense, input, success == null ? Langs.NetworkError : (bool)success ? EResult.OK : EResult.Fail)));
break;
default:
response.AppendLine(bot.FormatBotResponse(string.Format(Langs.CartInvalidType, input)));
break;
}
}

return response.Length > 0 ? response.ToString() : null;
}

Expand Down
3 changes: 1 addition & 2 deletions ASFEnhance/Community/Command.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
using ArchiSteamFarm.Steam;
using ASFEnhance.Data;
using ASFEnhance.Localization;
using static ASFEnhance.Community.Response;
using static ASFEnhance.Utils;

namespace ASFEnhance.Community
Expand Down Expand Up @@ -43,7 +42,7 @@ internal static class Command
return bot.FormatBotResponse(string.Format(Langs.JoinGroup, message, statusString));
case JoinGroupStatus.Failed:
default:
return bot.FormatBotResponse(string.Format(Langs.JoinGroup, statusString, message ?? Langs.CartNetworkError));
return bot.FormatBotResponse(string.Format(Langs.JoinGroup, statusString, message ?? Langs.NetworkError));
}
}

Expand Down
2 changes: 1 addition & 1 deletion ASFEnhance/Community/HtmlParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ internal static (bool, string) GetGroupName(HtmlDocumentResponse response)
{
if (response == null)
{
return (false, Langs.CartNetworkError);
return (false, Langs.NetworkError);
}

IElement? groupNameNode = response.Content.SelectSingleNode("//div[@class='grouppage_resp_title ellipsis']");
Expand Down
20 changes: 10 additions & 10 deletions ASFEnhance/Localization/Langs.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions ASFEnhance/Localization/Langs.en-US.resx
Original file line number Diff line number Diff line change
Expand Up @@ -130,15 +130,15 @@
<value>Response is empty</value>
</data>
<data name="CartInvalidType" xml:space="preserve">
<value>- {0}: Invalid type [SUB|BUNDLE]</value>
<value>{0}: Invalid type [SUB|BUNDLE]</value>
</data>
<data name="CartIsEmpty" xml:space="preserve">
<value>Shopping cart is emoty</value>
</data>
<data name="CartItemInfo" xml:space="preserve">
<value>- {0} {1} {2:F2}</value>
</data>
<data name="CartNetworkError" xml:space="preserve">
<data name="NetworkError" xml:space="preserve">
<value>Network Error</value>
</data>
<data name="CartPurchaseGift" xml:space="preserve">
Expand Down
4 changes: 2 additions & 2 deletions ASFEnhance/Localization/Langs.resx
Original file line number Diff line number Diff line change
Expand Up @@ -130,15 +130,15 @@
<value>响应为空</value>
</data>
<data name="CartInvalidType" xml:space="preserve">
<value>- {0}: 类型无效 [SUB|BUNDLE]</value>
<value>{0}: 类型无效 [SUB|BUNDLE]</value>
</data>
<data name="CartIsEmpty" xml:space="preserve">
<value>购物车是空的</value>
</data>
<data name="CartItemInfo" xml:space="preserve">
<value>- {0} {1} {2:F2}</value>
</data>
<data name="CartNetworkError" xml:space="preserve">
<data name="NetworkError" xml:space="preserve">
<value>网络错误</value>
</data>
<data name="CartPurchaseGift" xml:space="preserve">
Expand Down
4 changes: 2 additions & 2 deletions ASFEnhance/Localization/Langs.zh-Hans.resx
Original file line number Diff line number Diff line change
Expand Up @@ -130,15 +130,15 @@
<value>响应为空</value>
</data>
<data name="CartInvalidType" xml:space="preserve">
<value>- {0}: 类型无效 [SUB|BUNDLE]</value>
<value>{0}: 类型无效 [SUB|BUNDLE]</value>
</data>
<data name="CartIsEmpty" xml:space="preserve">
<value>购物车是空的</value>
</data>
<data name="CartItemInfo" xml:space="preserve">
<value>- {0} {1} {2:F2}</value>
</data>
<data name="CartNetworkError" xml:space="preserve">
<data name="NetworkError" xml:space="preserve">
<value>网络错误</value>
</data>
<data name="CartPurchaseGift" xml:space="preserve">
Expand Down
2 changes: 1 addition & 1 deletion ASFEnhance/Other/CommandHelpData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ internal sealed class CommandHelpData
{ "SUBS", "查询商店 SUB, 支持APP/SUB/BUNDLE"},
{ "PURCHASEHISTORY", "读取商店消费历史记录"},
{ "PUBLISHRECOMMENT", "发布评测, APPID > 0 给好评, AppID < 0 给差评"},
{ "DELETERECOMMENT", "删除评测 (有 BUG,暂不能正常工作)"},
{ "DELETERECOMMENT", "删除评测"},
// 购物车
{ "CART", "查看机器人购物车"},
{ "ADDCART", "添加购物车, 仅能使用SubID和BundleID"},
Expand Down
3 changes: 1 addition & 2 deletions ASFEnhance/Store/Command.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
using ASFEnhance.Localization;
using SteamKit2;
using System.Text;
using static ASFEnhance.Store.Response;
using static ASFEnhance.Utils;

namespace ASFEnhance.Store
Expand Down Expand Up @@ -66,7 +65,7 @@ internal static class Command
{
response.AppendLine(string.Format(Langs.StoreItemHeader, gameID, storeResponse.GameName));

foreach (SingleSubData sub in storeResponse.SubDatas)
foreach (var sub in storeResponse.SubDatas)
{
response.AppendLine(string.Format(Langs.StoreItem, sub.IsBundle ? "Bundle" : "Sub", sub.SubID, sub.Name, sub.Price / 100.0, walletCurrency));
}
Expand Down
2 changes: 1 addition & 1 deletion ASFEnhance/Store/WebRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ internal static async Task<bool> DeleteRecommend(Bot bot, uint gameID)
HtmlDocumentResponse? accountHistory = await GetAccountHistoryAjax(bot).ConfigureAwait(false);
if (accountHistory == null)
{
result.AppendLine(Langs.CartNetworkError);
result.AppendLine(Langs.NetworkError);
}
else
{
Expand Down

0 comments on commit 0a32d47

Please sign in to comment.