mirror of
https://github.com/RPCS3/discord-bot.git
synced 2024-11-23 02:09:38 +00:00
commit
4067e294a2
@ -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" />
|
||||
|
@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using CompatBot.Commands.Attributes;
|
||||
using DSharpPlus.CommandsNext;
|
||||
@ -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)
|
||||
{
|
||||
@ -35,8 +41,23 @@ internal sealed class BotMath : BaseCommandModuleCustom
|
||||
""";
|
||||
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)
|
||||
{
|
||||
|
@ -326,7 +326,8 @@ internal sealed partial class Warnings: BaseCommandModuleCustom
|
||||
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);
|
||||
|
@ -1032,13 +1032,14 @@ internal static partial class LogParserResult
|
||||
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)
|
||||
|
Loading…
Reference in New Issue
Block a user