Skip to content

Commit

Permalink
feat 新增 DL2 命令
Browse files Browse the repository at this point in the history
移除 RLE、SIM4 DL22 等失效命令
  • Loading branch information
chr233 committed Jun 28, 2024
1 parent d15be73 commit 8ea561e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 213 deletions.
40 changes: 10 additions & 30 deletions ASFEnhance/ASFEnhance.cs
Original file line number Diff line number Diff line change
Expand Up @@ -263,17 +263,8 @@ public Task OnLoaded()
Update.Command.ResponsePluginUpdate(null),

//Event
"SIM4" when access >= EAccess.Operator =>
Event.Command.ResponseSim4(bot),

"DL2" when access >= EAccess.Operator =>
Event.Command.ResponseDL2(bot),

"DL22" when access >= EAccess.Operator =>
Event.Command.ResponseDL22(bot, null),

"RLE" when access >= EAccess.Operator =>
Event.Command.ResponseRle(bot, null),
Event.Command.ResponseDL2(bot, null),

"CLAIMITEM" or
"CI" when access >= EAccess.Operator =>
Expand All @@ -283,9 +274,9 @@ public Task OnLoaded()
"C20" when access >= EAccess.Operator =>
Event.Command.ResponseClaim20Th(bot),

"CV" or
"CHECKVOTE" when access >= EAccess.Operator =>
Event.Command.ResponseCheckWinterSteamAwardVote(bot),
//"CV" or
//"CHECKVOTE" when access >= EAccess.Operator =>
// Event.Command.ResponseCheckWinterSteamAwardVote(bot),

//Shortcut
"P" =>
Expand Down Expand Up @@ -506,21 +497,10 @@ public Task OnLoaded()
Update.Command.ResponsePluginUpdate(Utilities.GetArgsAsText(args, 1, ",")),

//Event
"SIM4" when access >= EAccess.Operator =>
Event.Command.ResponseSim4(Utilities.GetArgsAsText(args, 1, ",")),

"DL2" when argLength > 2 && access >= EAccess.Operator =>
Event.Command.ResponseDL2(SkipBotNames(args, 1, 1), args.Last()),
"DL2" when access >= EAccess.Operator =>
Event.Command.ResponseDL2(Utilities.GetArgsAsText(args, 1, ",")),

"DL22" when argLength > 2 && access >= EAccess.Operator =>
Event.Command.ResponseDL22(SkipBotNames(args, 1, 1), args.Last()),
"DL22" when access >= EAccess.Operator =>
Event.Command.ResponseDL22(args[1], null),

"RLE" when argLength > 2 && access >= EAccess.Operator =>
Event.Command.ResponseRle(SkipBotNames(args, 1, 1), args.Last()),
"RLE" when access >= EAccess.Operator =>
Event.Command.ResponseRle(args[1], null),
Event.Command.ResponseDL2(args[1], null),

"CLAIMITEM" or
"CI" when access >= EAccess.Operator =>
Expand All @@ -530,9 +510,9 @@ public Task OnLoaded()
"C20" when access >= EAccess.Operator =>
Event.Command.ResponseClaim20Th(Utilities.GetArgsAsText(args, 1, ",")),

"CV" or
"CHECKVOTE" when access >= EAccess.Operator =>
Event.Command.ResponseCheckWinterSteamAwardVote(Utilities.GetArgsAsText(args, 1, ",")),
//"CV" or
//"CHECKVOTE" when access >= EAccess.Operator =>
// Event.Command.ResponseCheckWinterSteamAwardVote(Utilities.GetArgsAsText(args, 1, ",")),

//Shortcut
"AL" =>
Expand Down
188 changes: 6 additions & 182 deletions ASFEnhance/Event/Command.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,127 +7,19 @@ namespace ASFEnhance.Event;
internal static class Command
{
/// <summary>
/// 获取SIM4贴纸 10.19 - ?
/// </summary>
/// <param name="bot"></param>
/// <returns></returns>
internal static async Task<string?> ResponseSim4(Bot bot)
{
if (!bot.IsConnectedAndLoggedOn)
{
return bot.FormatBotResponse(Strings.BotNotConnected);
}

var token = await WebRequest.FetchEventToken(bot, "simscelebrationsale").ConfigureAwait(false);
if (string.IsNullOrEmpty(token))
{
return bot.FormatBotResponse(Langs.NetworkError);
}

var door_indexs = new[] { 1, 3, 4, 5, 2 };

foreach (var index in door_indexs)
{
await WebRequest.DoEventTask(bot, token, index).ConfigureAwait(false);
}

return bot.FormatBotResponse("Done!");
}

/// <summary>
/// 获取SIM4贴纸 (多个Bot)
/// </summary>
/// <param name="botNames"></param>
/// <returns></returns>
/// <exception cref="ArgumentNullException"></exception>
internal static async Task<string?> ResponseSim4(string botNames)
{
if (string.IsNullOrEmpty(botNames))
{
throw new ArgumentNullException(nameof(botNames));
}

var bots = Bot.GetBots(botNames);

if ((bots == null) || (bots.Count == 0))
{
return FormatStaticResponse(Strings.BotNotFound, botNames);
}

var results = await Utilities.InParallel(bots.Select(bot => ResponseSim4(bot))).ConfigureAwait(false);
var responses = new List<string?>(results.Where(result => !string.IsNullOrEmpty(result)));

return responses.Count > 0 ? string.Join(Environment.NewLine, responses) : null;
}

/// <summary>
/// 获取DL2贴纸 11.11 - ?
/// </summary>
/// <param name="bot"></param>
/// <returns></returns>
internal static async Task<string?> ResponseDL2(Bot bot)
{
if (!bot.IsConnectedAndLoggedOn)
{
return bot.FormatBotResponse(Strings.BotNotConnected);
}

var token = await WebRequest.FetchEventToken(bot, "dyinglight").ConfigureAwait(false);
if (string.IsNullOrEmpty(token))
{
return bot.FormatBotResponse(Langs.NetworkError);
}

var door_indexs = new[] { 1, 3, 4, 5, 2 };

foreach (var index in door_indexs)
{
await WebRequest.DoEventTask(bot, token, index).ConfigureAwait(false);
}

return bot.FormatBotResponse("Done!");
}

/// <summary>
/// 获取DL2贴纸 (多个Bot)
/// </summary>
/// <param name="botNames"></param>
/// <returns></returns>
/// <exception cref="ArgumentNullException"></exception>
internal static async Task<string?> ResponseDL2(string botNames)
{
if (string.IsNullOrEmpty(botNames))
{
throw new ArgumentNullException(nameof(botNames));
}

var bots = Bot.GetBots(botNames);

if ((bots == null) || (bots.Count == 0))
{
return FormatStaticResponse(Strings.BotNotFound, botNames);
}

var results = await Utilities.InParallel(bots.Select(bot => ResponseDL2(bot))).ConfigureAwait(false);
var responses = new List<string?>(results.Where(result => !string.IsNullOrEmpty(result)));

return responses.Count > 0 ? string.Join(Environment.NewLine, responses) : null;
}

/// <summary>
/// 获取DL2贴纸 6.30 - ?
/// 获取DL2贴纸 6.28 - ?
/// </summary>
/// <param name="bot"></param>
/// <param name="query"></param>
/// <returns></returns>
internal static async Task<string?> ResponseDL22(Bot bot, string? query)
internal static async Task<string?> ResponseDL2(Bot bot, string? query)
{
if (!bot.IsConnectedAndLoggedOn)
{
return bot.FormatBotResponse(Strings.BotNotConnected);
}

var token = await WebRequest.FetchEventToken(bot, "Techland", "techlandsummer2023").ConfigureAwait(false);
var token = await WebRequest.FetchEventToken(bot, "dyinglight2towerraid").ConfigureAwait(false);
if (string.IsNullOrEmpty(token))
{
return bot.FormatBotResponse(Langs.NetworkError);
Expand All @@ -146,7 +38,7 @@ internal static class Command
}
else
{
var door_indexs = new[] { 1, 3, 4, 5, 8, 7, 2, 6 };
var door_indexs = new[] { 1 };
var tasks = door_indexs.Select(id => WebRequest.DoEventTask(bot, token, id));
await Utilities.InParallel(tasks).ConfigureAwait(false);
}
Expand All @@ -161,75 +53,7 @@ internal static class Command
/// <param name="query"></param>
/// <returns></returns>
/// <exception cref="ArgumentNullException"></exception>
internal static async Task<string?> ResponseDL22(string botNames, string? query)
{
if (string.IsNullOrEmpty(botNames))
{
throw new ArgumentNullException(nameof(botNames));
}

var bots = Bot.GetBots(botNames);

if ((bots == null) || (bots.Count == 0))
{
return FormatStaticResponse(Strings.BotNotFound, botNames);
}

var results = await Utilities.InParallel(bots.Select(bot => ResponseDL22(bot, query))).ConfigureAwait(false);
var responses = new List<string?>(results.Where(result => !string.IsNullOrEmpty(result)));

return responses.Count > 0 ? string.Join(Environment.NewLine, responses) : null;
}


/// <summary>
/// 获取RLE贴纸 5.1 - ?
/// </summary>
/// <param name="bot"></param>
/// <param name="query"></param>
/// <returns></returns>
internal static async Task<string?> ResponseRle(Bot bot, string? query)
{
if (!bot.IsConnectedAndLoggedOn)
{
return bot.FormatBotResponse(Strings.BotNotConnected);
}

var token = await WebRequest.FetchEventToken(bot, "redfall_launch").ConfigureAwait(false);
if (string.IsNullOrEmpty(token))
{
return bot.FormatBotResponse(Langs.NetworkError);
}

if (!string.IsNullOrEmpty(query))
{
if (int.TryParse(query, out var id))
{
await WebRequest.DoEventTask(bot, token, id).ConfigureAwait(false);
}
else
{
return bot.FormatBotResponse(Langs.AccountSubInvalidArg);
}
}
else
{
var door_indexs = new[] { 1, 2, 3, 4 };
var tasks = door_indexs.Select(id => WebRequest.DoEventTask(bot, token, id));
await Utilities.InParallel(tasks).ConfigureAwait(false);
}

return bot.FormatBotResponse("Done!");
}

/// <summary>
/// 获取RLE贴纸 (多个Bot)
/// </summary>
/// <param name="botNames"></param>
/// <param name="query"></param>
/// <returns></returns>
/// <exception cref="ArgumentNullException"></exception>
internal static async Task<string?> ResponseRle(string botNames, string? query)
internal static async Task<string?> ResponseDL2(string botNames, string? query)
{
if (string.IsNullOrEmpty(botNames))
{
Expand All @@ -243,7 +67,7 @@ internal static class Command
return FormatStaticResponse(Strings.BotNotFound, botNames);
}

var results = await Utilities.InParallel(bots.Select(bot => ResponseRle(bot, query))).ConfigureAwait(false);
var results = await Utilities.InParallel(bots.Select(bot => ResponseDL2(bot, query))).ConfigureAwait(false);
var responses = new List<string?>(results.Where(result => !string.IsNullOrEmpty(result)));

return responses.Count > 0 ? string.Join(Environment.NewLine, responses) : null;
Expand Down
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project>
<PropertyGroup>
<Version>2.1.8.3</Version>
<Version>2.1.9.0</Version>
</PropertyGroup>

<PropertyGroup>
Expand Down

0 comments on commit 8ea561e

Please sign in to comment.