Skip to content

Commit

Permalink
Merge pull request #959 from 13xforever/vnext
Browse files Browse the repository at this point in the history
Maintenance
  • Loading branch information
clienthax authored Jun 26, 2024
2 parents d6688fd + ed78dc2 commit 4067e29
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Clients/GithubClient/GithubClient.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="8.0.0" />
<PackageReference Include="Octokit" Version="12.0.0" />
<PackageReference Include="Octokit" Version="13.0.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\CompatApiClient\CompatApiClient.csproj" />
Expand Down
23 changes: 22 additions & 1 deletion CompatBot/Commands/BotMath.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Globalization;
using System.Threading;
using System.Threading.Tasks;
using CompatBot.Commands.Attributes;
using DSharpPlus.CommandsNext;
Expand All @@ -12,6 +13,11 @@ namespace CompatBot.Commands;
[Description("Math, here you go Juhn. Use `math help` for syntax help")]
internal sealed class BotMath : BaseCommandModuleCustom
{
static BotMath()
{
License.iConfirmNonCommercialUse("RPCS3");
}

[GroupCommand, Priority(9)]
public async Task Expression(CommandContext ctx, [RemainingText, Description("Math expression")] string expression)
{
Expand All @@ -35,8 +41,23 @@ public async Task Expression(CommandContext ctx, [RemainingText, Description("Ma
""";
try
{
mXparser.resetCancelCurrentCalculationFlag();
var expr = new Expression(expression);
result = expr.calculate().ToString(CultureInfo.InvariantCulture);
const int timeout = 1_000;
var cts = new CancellationTokenSource(timeout);
// ReSharper disable once MethodSupportsCancellation
var delayTask = Task.Delay(timeout);
var calcTask = Task.Run(() => expr.calculate().ToString(CultureInfo.InvariantCulture), cts.Token);
await Task.WhenAny(calcTask, delayTask).ConfigureAwait(false);
if (calcTask.IsCompletedSuccessfully)
{
result = await calcTask;
}
else
{
mXparser.cancelCurrentCalculation();
result = "Calculation took too much time and all operations were cancelled";
}
}
catch (Exception e)
{
Expand Down
3 changes: 2 additions & 1 deletion CompatBot/Commands/Warnings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,8 @@ private static async Task ListUserWarningsAsync(DiscordClient client, DiscordMes
table.Add(warning.Id.ToString(), "+", issuerName, timestamp, warning.Reason, warning.FullReason);
}
}
var result = new StringBuilder("Warning list for ").Append(userName);

var result = new StringBuilder("Warning list for ").Append(Formatter.Sanitize(userName));
if (!isPrivate && !isWhitelisted && count > maxWarningsInPublicChannel)
result.Append($" (last {showCount} of {count}, full list in DMs)");
result.AppendLine(":").Append(table);
Expand Down
5 changes: 3 additions & 2 deletions CompatBot/Utils/ResultFormatters/LogParserResultFormatter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1032,13 +1032,14 @@ select m
13 => "macOS High Sierra",
14 => "macOS Mojave",
15 => "macOS Catalina",
_ => null,
_ => "Unknown Apple OS",
},
11 => "macOS Big Sur",
12 => "macOS Monterey",
13 => "macOS Ventura",
14 => "macOS Sonoma",
_ => null,
15 => "macOS Sequoia",
_ => "Unknown Apple OS",
};

internal static bool IsAmd(string gpuInfo)
Expand Down

0 comments on commit 4067e29

Please sign in to comment.