Skip to content

Commit

Permalink
HELP命令添加命令说明
Browse files Browse the repository at this point in the history
  • Loading branch information
chr233 committed May 21, 2022
1 parent 2e614e2 commit 862a9ad
Show file tree
Hide file tree
Showing 9 changed files with 123 additions and 70 deletions.
1 change: 1 addition & 0 deletions ASFEnhance/ASFEnhance.cs
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,7 @@ public Task OnLoaded()
case "K" when access >= EAccess.FamilySharing:
return Other.Command.ResponseExtractKeys(Utilities.GetArgsAsText(args, 1, ","));

case "EHELP" when access >= EAccess.FamilySharing:
case "HELP" when access >= EAccess.FamilySharing:
return Other.Command.ResponseCommandHelp(args);

Expand Down
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.1.435")]
[assembly: AssemblyFileVersion("1.6.1.435")]
[assembly: AssemblyVersion("1.6.1.439")]
[assembly: AssemblyFileVersion("1.6.1.439")]

[assembly: AssemblyCopyright("Copyright © 2022 Chr_")]
[assembly: AssemblyProduct("ASFEnhance")]
Expand Down
13 changes: 11 additions & 2 deletions ASFEnhance/Localization/Langs.Designer.cs

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

7 changes: 5 additions & 2 deletions ASFEnhance/Localization/Langs.en-US.resx
Original file line number Diff line number Diff line change
Expand Up @@ -577,15 +577,18 @@
<value>当前已经是最新版本, 无需更新插件</value>
</data>
<data name="CommandHelpWithShortName" xml:space="preserve">
<value>- {0} / {1} : {2}</value>
<value>- {0} / {1} {2} : {3}</value>
</data>
<data name="CommandHelpNoShortName" xml:space="preserve">
<value>- {0} : {1}</value>
<value>- {0} {1} : {2}</value>
</data>
<data name="CommandHelpCmdNotFound" xml:space="preserve">
<value>找不到相关命令的帮助</value>
</data>
<data name="PruchaseHistoryTypeWalletPurchase" xml:space="preserve">
<value> - 余额充值: {0:0.00} {1}</value>
</data>
<data name="CommandHelpNoUsage" xml:space="preserve">
<value>无描述</value>
</data>
</root>
7 changes: 5 additions & 2 deletions ASFEnhance/Localization/Langs.resx
Original file line number Diff line number Diff line change
Expand Up @@ -577,15 +577,18 @@
<value>**插件更新准备完毕,重启ASF即可应用更新.**</value>
</data>
<data name="CommandHelpNoShortName" xml:space="preserve">
<value>- {0} : {1}</value>
<value>- {0} {1} : {2}</value>
</data>
<data name="CommandHelpWithShortName" xml:space="preserve">
<value>- {0} / {1} : {2}</value>
<value>- {0} / {1} {2} : {3}</value>
</data>
<data name="CommandHelpCmdNotFound" xml:space="preserve">
<value>找不到相关命令的帮助</value>
</data>
<data name="PruchaseHistoryTypeWalletPurchase" xml:space="preserve">
<value> - 余额充值: {0:0.00} {1}</value>
</data>
<data name="CommandHelpNoUsage" xml:space="preserve">
<value>无描述</value>
</data>
</root>
7 changes: 5 additions & 2 deletions ASFEnhance/Localization/Langs.zh-Hans.resx
Original file line number Diff line number Diff line change
Expand Up @@ -577,15 +577,18 @@
<value>当前已经是最新版本, 无需更新插件</value>
</data>
<data name="CommandHelpWithShortName" xml:space="preserve">
<value>- {0} / {1} : {2}</value>
<value>- {0} / {1} {2} : {3}</value>
</data>
<data name="CommandHelpNoShortName" xml:space="preserve">
<value>- {0} : {1}</value>
<value>- {0} {1} : {2}</value>
</data>
<data name="CommandHelpCmdNotFound" xml:space="preserve">
<value>找不到相关命令的帮助</value>
</data>
<data name="PruchaseHistoryTypeWalletPurchase" xml:space="preserve">
<value> - 余额充值: {0:0.00} {1}</value>
</data>
<data name="CommandHelpNoUsage" xml:space="preserve">
<value>无描述</value>
</data>
</root>
57 changes: 32 additions & 25 deletions ASFEnhance/Other/Command.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,25 +50,27 @@ internal static string ResponseASFEnhanceVersion()
sb.AppendLine(Langs.MultipleLineResult);
sb.AppendLine(Langs.CommandHelp);

foreach (KeyValuePair<string, string> item in Response.CommandUsage)
foreach (KeyValuePair<string, string> item in Response.CommandArges)
{
string cmd = item.Key;

string usage = Response.CommandUsage[cmd];

if (string.IsNullOrEmpty(usage))
string args = string.IsNullOrEmpty(item.Value) ? Langs.NoArgs : item.Value;
string usage;
if (Response.CommandUsage.ContainsKey(cmd))
{
usage = Langs.NoArgs;
usage = Response.CommandUsage[cmd];
}

if (Response.FullCommand.ContainsKey(cmd))
else
{
string shortCmd = Response.FullCommand[cmd];
sb.AppendLine(string.Format(Langs.CommandHelpWithShortName, cmd, shortCmd, usage));
usage = Langs.CommandHelpNoUsage;
}
if (Response.FullCmd2ShortCmd.ContainsKey(cmd))
{
string shortCmd = Response.FullCmd2ShortCmd[cmd];
sb.AppendLine(string.Format(Langs.CommandHelpWithShortName, cmd, shortCmd, args, usage));
}
else
{
sb.AppendLine(string.Format(Langs.CommandHelpNoShortName, cmd, usage));
sb.AppendLine(string.Format(Langs.CommandHelpNoShortName, cmd, args, usage));
}
}

Expand All @@ -83,11 +85,8 @@ internal static string ResponseASFEnhanceVersion()
internal static string? ResponseCommandHelp(string[] commands)
{
StringBuilder sb = new();

sb.AppendLine(Langs.MultipleLineResult);

sb.AppendLine(Langs.CommandHelp);

int count = 0;
bool skip = true;
foreach (string command in commands)
Expand All @@ -97,30 +96,38 @@ internal static string ResponseASFEnhanceVersion()
skip = false;
continue;
}

string cmd = command.ToUpperInvariant();
if (Response.ShortCommands.ContainsKey(cmd))
if (Response.ShortCmd2FullCmd.ContainsKey(cmd))
{
cmd = Response.ShortCommands[cmd];
cmd = Response.ShortCmd2FullCmd[cmd];
}
if (Response.CommandUsage.ContainsKey(cmd))
if (Response.CommandArges.ContainsKey(cmd))
{
count++;
string usage = Response.CommandUsage[cmd];
string args = Response.CommandArges[cmd];
if (string.IsNullOrEmpty(args))
{
args = Langs.NoArgs;
}

if (string.IsNullOrEmpty(usage))
string usage;
if (Response.CommandUsage.ContainsKey(cmd))
{
usage = Response.CommandUsage[cmd];
}
else
{
usage = Langs.NoArgs;
usage = Langs.CommandHelpNoUsage;
}

if (Response.FullCommand.ContainsKey(cmd))
if (Response.FullCmd2ShortCmd.ContainsKey(cmd))
{
string shortCmd = Response.FullCommand[cmd];
sb.AppendLine(string.Format(Langs.CommandHelpWithShortName, cmd, shortCmd, usage));
string shortCmd = Response.FullCmd2ShortCmd[cmd];
sb.AppendLine(string.Format(Langs.CommandHelpWithShortName, cmd, shortCmd, args, usage));
}
else
{
sb.AppendLine(string.Format(Langs.CommandHelpNoShortName, cmd, usage));
sb.AppendLine(string.Format(Langs.CommandHelpNoShortName, cmd, args, usage));
}
}
}
Expand Down
89 changes: 60 additions & 29 deletions ASFEnhance/Other/Response.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,46 +2,77 @@
{
internal static class Response
{
internal static readonly Dictionary<string, string> CommandUsage = new() {
internal static readonly Dictionary<string, string> CommandArges = new() {
// 其他
{ "ASFENHANCE", ""},
{ "KEY", "KEY <Text>"},
{ "KEY", "<Text>"},
{ "ASFEHELP", "ASFEHELP" },
{ "HELP", "HELP <Command>" },
{ "HELP", "<Command>" },
{ "ASFEVERSION", "" },
{ "ASFEUPDATE", "" },
// 社区
{ "PROFILE", "PROFILE [Bots]"},
{ "STEAMID", "STEAMID [Bots]"},
{ "FRIENDCODE", "FRIENDCODE [Bots]"},
{ "GROUPLIST", "GROUPLIST [Bots]"},
{ "JOINGROUP", "JOINGROUP [Bots] <GroupName>"},
{ "LEAVEGROUP [Bots] <GroupID>", "LEAVEGROUP [Bots] <GroupID>"},
{ "PROFILE", "[Bots]"},
{ "STEAMID", "[Bots]"},
{ "FRIENDCODE", "[Bots]"},
{ "GROUPLIST", "[Bots]"},
{ "JOINGROUP", "[Bots] <GroupName>"},
{ "LEAVEGROUP", "[Bots] <GroupID>"},
// 愿望单
{ "ADDWISHLIST", "ADDWISHLIST [Bots] <AppIDs>"},
{ "REMOVEWISHLIST", "REMOVEWISHLIST [Bots] <AppIDs>"},
{ "ADDWISHLIST", "[Bots] <AppIDs>"},
{ "REMOVEWISHLIST", "[Bots] <AppIDs>"},
// 商店
{ "APPDETAIL", "APPDETAIL [Bots] <AppIDS>"},
{ "SEARCH", "SEARCH [Bots] Keywords"},
{ "SUBS", "SUBS [Bots] <AppIDS|SubIDS|BundleIDS>"},
{ "APPDETAIL", "[Bots] <AppIDS>"},
{ "SEARCH", "[Bots] Keywords"},
{ "SUBS", "[Bots] <AppIDS|SubIDS|BundleIDS>"},
{ "PURCHASEHISTORY", ""},
{ "PUBLISHRECOMMENT", "PUBLISHRECOMMENT [Bots] <AppIDS> COMMENT"},
{ "DELETERECOMMENT", "DELETERECOMMENT [Bots] <AppIDS>"},
{ "PUBLISHRECOMMENT", "[Bots] <AppIDS> COMMENT"},
{ "DELETERECOMMENT", "[Bots] <AppIDS>"},
// 购物车
{ "CART", "[Bots]"},
{ "ADDCART", "[Bots] <SubIDs|BundleIDs>"},
{ "CARTRESET", "[Bots]"},
{ "CARTCOUNTRY", "[Bots]"},
{ "SETCOUNTRY", "[Bots] <CountryCode>"},
{ "PURCHASE", "[Bots]"},
{ "PURCHASEGIFT", "[BotA] BotB"},
};

internal static readonly Dictionary<string, string> CommandUsage = new() {
// 其他
{ "ASFENHANCE", "查看 ASFEnhance 的版本"},
{ "KEY", "从文本提取 key"},
{ "ASFEHELP", "查看全部指令说明" },
{ "HELP", "查看指令说明" },
{ "ASFEVERSION", "检查 ASFEnhance 的最新版本" },
{ "ASFEUPDATE", "更新 ASFEnhance 到最新版本" },
// 社区
{ "PROFILE", "查看个人资料"},
{ "STEAMID", "查看 steamID"},
{ "FRIENDCODE", "查看好友代码"},
{ "GROUPLIST", "查看机器人的群组列表"},
{ "JOINGROUP", "加入指定群组"},
{ "LEAVEGROUP", "离开指定群组"},
// 愿望单
{ "ADDWISHLIST", "添加愿望单"},
{ "REMOVEWISHLIST", "移除愿望单"},
// 商店
{ "APPDETAIL", "获取 APP 信息, 无法获取锁区游戏信息, 仅支持APP"},
{ "SEARCH", "搜索商店"},
{ "SUBS", "查询商店 SUB, 支持APP/SUB/BUNDLE"},
{ "PURCHASEHISTORY", "读取商店消费历史记录"},
{ "PUBLISHRECOMMENT", "发布评测, APPID > 0 给好评, AppID < 0 给差评"},
{ "DELETERECOMMENT", "删除评测 (有 BUG,暂不能正常工作)"},
// 购物车
{ "CART", "CART [Bots]"},
{ "ADDCART", "ADDCART [Bots] <SubIDs|BundleIDs>"},
{ "CARTRESET", "CARTRESET [Bots]"},
{ "CARTCOUNTRY", "CARTCOUNTRY [Bots]"},
{ "SETCOUNTRY", "SETCOUNTRY [Bots] <CountryCode>"},
{ "PURCHASE", "PURCHASE [Bots]"},
{ "PURCHASEGIFT", "PURCHASEGIFT [BotA] BotB"},
// 调试
{ "COOKIES", "COOKIES [Bots]"},
{ "APIKEY", "APIKEY [Bots]"},
{ "ACCESSTOKEN", "ACCESSTOKEN [Bots]"},
{ "CART", "查看机器人购物车"},
{ "ADDCART", "添加购物车, 仅能使用SubID和BundleID"},
{ "CARTRESET", "清空购物车"},
{ "CARTCOUNTRY", "获取购物车可用结算区域(跟账号钱包和当前 IP 所在地有关)"},
{ "SETCOUNTRY", "购物车改区,可以用CARTCOUNTRY命令获取当前可选的CountryCode(仍然有 Bug)"},
{ "PURCHASE", "结算机器人的购物车, 只能为机器人自己购买 (使用 Steam 钱包余额结算)"},
{ "PURCHASEGIFT", "结算机器人 A 的购物车, 发送礼物给机器人 B (使用 Steam 钱包余额结算)"},
};

internal static readonly Dictionary<string, string> ShortCommands = new() {
internal static readonly Dictionary<string, string> ShortCmd2FullCmd = new() {
{ "K", "KEY" },
{ "ASFE", "ASFENHANCE" },
{ "EHELP", "ASFEHELP" },
Expand Down Expand Up @@ -70,6 +101,6 @@ internal static class Response
{ "PCG", "PURCHASEGIFT" },
};

internal static readonly Dictionary<string, string> FullCommand = ShortCommands.ToDictionary(x => x.Value, x => x.Key);
internal static readonly Dictionary<string, string> FullCmd2ShortCmd = ShortCmd2FullCmd.ToDictionary(x => x.Value, x => x.Key);
}
}
8 changes: 2 additions & 6 deletions ASFEnhance/Store/WebRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -167,12 +167,10 @@ internal static async Task<bool> DeleteRecommend(Bot bot, uint gameID)
/// <param name="bot"></param>
/// <param name="currency"></param>
/// <returns></returns>
private static async Task<ExchangeAPIResponse?> GetExchangeRatio(Bot bot, string currency)
private static async Task<ExchangeAPIResponse?> GetExchangeRatio(string currency)
{
Uri request = new($"https://api.exchangerate-api.com/v4/latest/{currency}");

ObjectResponse<ExchangeAPIResponse> response = await ASF.WebBrowser.UrlGetToJsonObject<ExchangeAPIResponse>(request).ConfigureAwait(false);

return response?.Content;
}

Expand All @@ -184,9 +182,7 @@ internal static async Task<bool> DeleteRecommend(Bot bot, uint gameID)
private static async Task<HtmlDocumentResponse?> GetAccountHistoryAjax(Bot bot)
{
Uri request = new(SteamStoreURL, "/account/history?l=schinese");

HtmlDocumentResponse? response = await bot.ArchiWebHandler.UrlGetToHtmlDocumentWithSession(request, referer: SteamStoreURL).ConfigureAwait(false);

return response;
}

Expand All @@ -199,7 +195,7 @@ internal static async Task<bool> DeleteRecommend(Bot bot, uint gameID)
{
// 读取在线汇率
string myCurrency = bot.WalletCurrency.ToString();
ExchangeAPIResponse? exchangeRate = await GetExchangeRatio(bot, myCurrency).ConfigureAwait(false);
ExchangeAPIResponse? exchangeRate = await GetExchangeRatio(myCurrency).ConfigureAwait(false);
if (exchangeRate == null)
{
return Langs.GetExchangeRateFailed;
Expand Down

0 comments on commit 862a9ad

Please sign in to comment.