Skip to content

Commit e89ce2b

Browse files
authored
Merge branch 'master' into patch-1
2 parents 718981d + 11ebb46 commit e89ce2b

File tree

7 files changed

+765
-34
lines changed

7 files changed

+765
-34
lines changed

CompatBot/Commands/Attributes/RequiresDm.cs

+1-2
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,10 @@ namespace CompatBot.Commands.Attributes;
1111
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Class, Inherited = false)]
1212
internal class RequiresDm: CheckBaseAttribute
1313
{
14-
private const string Source = "https://cdn.discordapp.com/attachments/417347469521715210/534798232858001418/24qx11.jpg";
1514
private static readonly Lazy<byte[]> Poster = new(() =>
1615
{
1716
using var client = HttpClientFactory.Create();
18-
return client.GetByteArrayAsync(Source).ConfigureAwait(true).GetAwaiter().GetResult();
17+
return client.GetByteArrayAsync(Config.ImgSrcNotInPublic).ConfigureAwait(true).GetAwaiter().GetResult();
1918
});
2019

2120
public override async Task<bool> ExecuteCheckAsync(CommandContext ctx, bool help)

CompatBot/Commands/Psn.Check.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ public async Task Updates(CommandContext ctx, [RemainingText, Description("Produ
131131
newTitle += embed.Title[partStart..];
132132
embed.Title = newTitle;
133133
if (!string.IsNullOrEmpty(embed.Thumbnail?.Url))
134-
embed.WithThumbnail("https://cdn.discordapp.com/attachments/417347469521715210/516340151589535745/onionoff.png");
134+
embed.WithThumbnail(Config.ImgSrcNoCompatAbuse);
135135
}
136136
var sqvat = ctx.Client.GetEmoji(":sqvat:", Config.Reactions.No)!;
137137
await ctx.Message.ReactWithAsync(sqvat).ConfigureAwait(false);

CompatBot/CompatBot.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
<PackageReference Include="DSharpPlus.CommandsNext" Version="4.5.0" />
4444
<PackageReference Include="DSharpPlus.Interactivity" Version="4.5.0" />
4545
<PackageReference Include="DSharpPlus.SlashCommands" Version="4.5.0" />
46-
<PackageReference Include="Google.Apis.Drive.v3" Version="1.69.0.3693" />
46+
<PackageReference Include="Google.Apis.Drive.v3" Version="1.69.0.3699" />
4747
<PackageReference Include="ksemenenko.ColorThief" Version="1.1.1.4" />
4848
<PackageReference Include="MathParser.org-mXparser" Version="6.1.0" />
4949
<PackageReference Include="MegaApiClient" Version="1.10.4" />

CompatBot/Config.cs

+17-14
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ internal static class Config
4646
public static string? GitRevision { get; private set; }
4747

4848
// these settings could be configured either through `$ dotnet user-secrets`, or through environment variables (e.g. launchSettings.json, etc)
49-
public static string CommandPrefix => config.GetValue(nameof(CommandPrefix), "!")!;
50-
public static string AutoRemoveCommandPrefix => config.GetValue(nameof(AutoRemoveCommandPrefix), ".")!;
49+
public static string CommandPrefix => config.GetValue(nameof(CommandPrefix), "!");
50+
public static string AutoRemoveCommandPrefix => config.GetValue(nameof(AutoRemoveCommandPrefix), ".");
5151
public static ulong BotGuildId => config.GetValue(nameof(BotGuildId), 272035812277878785ul); // discord server where the bot is supposed to be
5252
public static ulong BotGeneralChannelId => config.GetValue(nameof(BotGeneralChannelId), 272035812277878785ul);// #rpcs3; main or general channel where noobs come first thing
5353
public static ulong BotChannelId => config.GetValue(nameof(BotChannelId), 291679908067803136ul); // #build-updates; this is used for new build announcements
@@ -79,20 +79,23 @@ internal static class Config
7979
public static int ChannelMessageHistorySize => config.GetValue(nameof(ChannelMessageHistorySize), 100);
8080
public static int FunMultiplier => config.GetValue(nameof(FunMultiplier), 1);
8181
public static int MaxPositionsForHwSurveyResults => config.GetValue(nameof(MaxPositionsForHwSurveyResults), 10);
82-
public static string Token => config.GetValue(nameof(Token), "")!;
83-
public static string AzureDevOpsToken => config.GetValue(nameof(AzureDevOpsToken), "")!;
84-
public static string AzureComputerVisionKey => config.GetValue(nameof(AzureComputerVisionKey), "")!;
85-
public static string AzureComputerVisionEndpoint => config.GetValue(nameof(AzureComputerVisionEndpoint), "https://westeurope.api.cognitive.microsoft.com/")!;
82+
public static string Token => config.GetValue(nameof(Token), "");
83+
public static string AzureDevOpsToken => config.GetValue(nameof(AzureDevOpsToken), "");
84+
public static string AzureComputerVisionKey => config.GetValue(nameof(AzureComputerVisionKey), "");
85+
public static string AzureComputerVisionEndpoint => config.GetValue(nameof(AzureComputerVisionEndpoint), "https://westeurope.api.cognitive.microsoft.com/");
8686
public static Guid AzureDevOpsProjectId => config.GetValue(nameof(AzureDevOpsProjectId), new Guid("3598951b-4d39-4fad-ad3b-ff2386a649de"));
87-
public static string AzureAppInsightsConnectionString => config.GetValue(nameof(AzureAppInsightsConnectionString), "")!;
88-
public static string GithubToken => config.GetValue(nameof(GithubToken), "")!;
89-
public static string GoogleApiCredentials => config.GetValue(nameof(GoogleApiCredentials), "")!;
90-
public static string PreferredFontFamily => config.GetValue(nameof(PreferredFontFamily), "")!;
91-
public static string LogPath => config.GetValue(nameof(LogPath), "./logs/")!; // paths are relative to the working directory
92-
public static string IrdCachePath => config.GetValue(nameof(IrdCachePath), "./ird/")!;
87+
public static string AzureAppInsightsConnectionString => config.GetValue(nameof(AzureAppInsightsConnectionString), "");
88+
public static string GithubToken => config.GetValue(nameof(GithubToken), "");
89+
public static string GoogleApiCredentials => config.GetValue(nameof(GoogleApiCredentials), "");
90+
public static string PreferredFontFamily => config.GetValue(nameof(PreferredFontFamily), "");
91+
public static string LogPath => config.GetValue(nameof(LogPath), "./logs/"); // paths are relative to the working directory
92+
public static string IrdCachePath => config.GetValue(nameof(IrdCachePath), "./ird/");
9393
public static double GameTitleMatchThreshold => config.GetValue(nameof(GameTitleMatchThreshold), 0.57);
94-
public static byte[] CryptoSalt => Convert.FromBase64String(config.GetValue(nameof(CryptoSalt), "")!);
95-
public static string RenameNameSuffix => config.GetValue(nameof(RenameNameSuffix), " (Rule 7)")!;
94+
public static byte[] CryptoSalt => Convert.FromBase64String(config.GetValue(nameof(CryptoSalt), ""));
95+
public static string RenameNameSuffix => config.GetValue(nameof(RenameNameSuffix), " (Rule 7)");
96+
97+
public static string ImgSrcNotInPublic => config.GetValue(nameof(ImgSrcNotInPublic), "https://cdn.discordapp.com/attachments/1207384388602560562/1344880816886517810/24qx11.jpg");
98+
public static string ImgSrcNoCompatAbuse => config.GetValue(nameof(ImgSrcNoCompatAbuse), "https://cdn.discordapp.com/attachments/1207384388602560562/1344881154528116777/onionoff.png");
9699

97100
internal static class AllowedMentions
98101
{

CompatBot/EventHandlers/ProductCodeLookup.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ public static async Task FixAfrikaAsync(DiscordClient client, DiscordMessage mes
172172
var sqvat = client.GetEmoji(":sqvat:", Config.Reactions.No)!;
173173
titleInfoEmbed.Title = "How about no (๑•ิཬ•ั๑)";
174174
if (!string.IsNullOrEmpty(titleInfoEmbed.Thumbnail?.Url))
175-
titleInfoEmbed.WithThumbnail("https://cdn.discordapp.com/attachments/417347469521715210/516340151589535745/onionoff.png");
175+
titleInfoEmbed.WithThumbnail(Config.ImgSrcNoCompatAbuse);
176176
await message.ReactWithAsync(sqvat).ConfigureAwait(false);
177177
}
178178
}

CompatBot/Watchdog.cs

+2-15
Original file line numberDiff line numberDiff line change
@@ -26,20 +26,6 @@ public static async Task Watch(DiscordClient client)
2626
do
2727
{
2828
await Task.Delay(Config.SocketDisconnectCheckIntervalInSec, Config.Cts.Token).ConfigureAwait(false);
29-
foreach (var sudoer in ModProvider.Mods.Values.Where(m => m.Sudoer))
30-
{
31-
var user = await client.GetUserAsync(sudoer.DiscordId).ConfigureAwait(false);
32-
if (user?.Presence?.Activity?.CustomStatus?.Name is string cmd && cmd.StartsWith("restart"))
33-
{
34-
var instance = cmd.Split(' ', StringSplitOptions.RemoveEmptyEntries).LastOrDefault();
35-
if (ulong.TryParse(instance, out var botId) && botId == client.CurrentUser.Id)
36-
{
37-
Config.Log.Warn($"Found request to restart on {user.Username}#{user.Discriminator}'s custom status");
38-
Sudo.Bot.Restart(Program.InvalidChannelId, $"Restarted by request from {user.Username}#{user.Discriminator}'s custom status");
39-
}
40-
}
41-
}
42-
4329
if (IsOk)
4430
continue;
4531

@@ -89,7 +75,8 @@ public static void OnLogHandler(string level, string message)
8975
}
9076
else if (level == nameof(LogLevel.Fatal))
9177
{
92-
if (message.Contains("Socket connection terminated")
78+
if (message.Contains("Connection closed (-1, '')")
79+
|| message.Contains("Socket connection terminated")
9380
|| message.Contains("heartbeats were skipped. Issuing reconnect."))
9481
DisconnectTimestamps.Enqueue(DateTime.UtcNow);
9582
}

0 commit comments

Comments
 (0)