Skip to content

Commit 7349667

Browse files
authored
Merge pull request #1012 from 13xforever/vnext
Maintenance
2 parents 9655059 + 1871815 commit 7349667

File tree

10 files changed

+67
-14
lines changed

10 files changed

+67
-14
lines changed

Clients/GithubClient/GithubClient.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<ItemGroup>
88
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="10.0.1" />
99
<PackageReference Include="Octokit" Version="14.0.0" />
10-
<PackageReference Include="SharpCompress" Version="0.42.1" />
10+
<PackageReference Include="SharpCompress" Version="0.44.0" />
1111
</ItemGroup>
1212
<ItemGroup>
1313
<ProjectReference Include="..\CompatApiClient\CompatApiClient.csproj" />

Clients/IrdLibraryClient/IrdLibraryClient.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<Nullable>enable</Nullable>
66
</PropertyGroup>
77
<ItemGroup>
8-
<PackageReference Include="LTRData.DiscUtils.OpticalDisk" Version="1.0.72" />
8+
<PackageReference Include="LTRData.DiscUtils.OpticalDisk" Version="1.0.73" />
99
<PackageReference Include="Microsoft.IO.RecyclableMemoryStream" Version="3.0.1" />
1010
<PackageReference Include="System.IO.Hashing" Version="10.0.1" />
1111
</ItemGroup>

CompatBot/CompatBot.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,15 +64,15 @@
6464
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="10.0.1" />
6565
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="10.0.1" />
6666
<PackageReference Include="Microsoft.IO.RecyclableMemoryStream" Version="3.0.1" />
67-
<PackageReference Include="Microsoft.TeamFoundationServer.Client" Version="19.225.1" />
67+
<PackageReference Include="Microsoft.TeamFoundationServer.Client" Version="19.225.2" />
6868
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.22.1" />
6969
<PackageReference Include="Nerdbank.Streams" Version="2.13.16" />
7070
<PackageReference Include="Nito.AsyncEx" Version="5.1.2" />
7171
<PackageReference Include="NLog" Version="6.0.7" />
7272
<PackageReference Include="NLog.Extensions.Logging" Version="6.1.0" />
7373
<PackageReference Include="NReco.Text.AhoCorasickDoubleArrayTrie" Version="1.1.1" />
7474
<PackageReference Include="Result.Net" Version="1.7.0" />
75-
<PackageReference Include="SharpCompress" Version="0.42.1" />
75+
<PackageReference Include="SharpCompress" Version="0.44.0" />
7676
<PackageReference Include="SixLabors.ImageSharp.Drawing" Version="2.1.7" />
7777
<PackageReference Include="TesseractCSharp" Version="1.0.5" />
7878
</ItemGroup>

CompatBot/EventHandlers/AntiSpamMessageHandler.cs

Lines changed: 32 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,25 +28,35 @@ public static async Task<bool> OnMessageCreated(DiscordClient client, MessageCre
2828
Config.Log.Debug($"Removed checkpoint spam message from user {author.Username} ({author.Id}) in #{msg.Channel?.Name}");
2929
return false;
3030
}
31-
32-
if (msg.Content is not { Length: >0 })
33-
return true;
31+
3432

3533
if (MessageCache.TryGetValue(author.Id, out var item)
36-
&& item is (DiscordMessage { Content.Length: >0 } lastMessage, bool isWarned)
37-
&& lastMessage.Content == msg.Content
34+
&& item is (DiscordMessage lastMessage, bool isWarned)
35+
&& SameContent(lastMessage, msg)
3836
&& lastMessage.ChannelId != msg.ChannelId)
3937
{
4038
var removedSpam = false;
4139
try
4240
{
4341
await msg.DeleteAsync("spam").ConfigureAwait(false);
42+
removedSpam = true;
43+
44+
var newMsgContent = "<???>";
45+
if (msg.Content is { Length: > 0 })
46+
{
47+
newMsgContent = msg.Content;
48+
}
49+
else if (msg is { Attachments.Count: > 0 })
50+
{
51+
foreach (var att in msg.Attachments)
52+
newMsgContent += $"📎 {att.FileName}\n";
53+
newMsgContent = newMsgContent.TrimEnd();
54+
}
4455
Config.Log.Debug($"""
4556
Removed spam message from user {author.Username} ({author.Id}) in #{msg.Channel?.Name}:
46-
{msg.Content.Trim()}
57+
{newMsgContent.Trim()}
4758
"""
4859
);
49-
removedSpam = true;
5060
}
5161
catch (Exception e)
5262
{
@@ -71,4 +81,19 @@ public static async Task<bool> OnMessageCreated(DiscordClient client, MessageCre
7181
MessageCache.Set(author.Id, (msg, false), DefaultExpiration);
7282
return true;
7383
}
84+
85+
private static bool SameContent(DiscordMessage msg1, DiscordMessage msg2)
86+
{
87+
if (msg1 is { Content.Length: > 0 }
88+
&& msg2 is { Content.Length: > 0 }
89+
&& msg1.Content == msg2.Content)
90+
return true;
91+
92+
if (msg1 is { Attachments.Count: > 0 }
93+
&& msg2 is { Attachments.Count: > 0 }
94+
&& msg1.Attachments.SequenceEqual(msg2.Attachments, DiscordAttachmentComparer.Instance))
95+
return true;
96+
97+
return false;
98+
}
7499
}

CompatBot/EventHandlers/LogParsing/LogParser.LogSections.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ internal partial class LogParser
184184
["SYS: Title was set from"] = TitleWasSet(),
185185
["SYS: Path:"] = DigitalPathSys(),
186186
["SYS: Boot path:"] = BootPathInBodySys(),
187+
["SYS: Disc:"] = DiscMountSys(),
187188
["Elf path:"] = ElfPath(),
188189
["VFS: Mounted path \"/dev_bdvd\""] = VfsMountPath(),
189190
["Invalid or unsupported file format:"] = InvalidFileFormat(),

CompatBot/EventHandlers/LogParsing/LogParser.RegexPatterns.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,8 @@ internal partial class LogParser
248248
private static partial Regex DigitalPathSys();
249249
[GeneratedRegex(@"Boot path: (?<ldr_boot_path_full>.*(?<ldr_boot_path>/dev_hdd0/game/(?<ldr_boot_path_serial>[^/\r\n]+)).*|[^\r\n]*)\r?$", DefaultOptions)]
250250
private static partial Regex BootPathInBodySys();
251+
[GeneratedRegex(@"SYS: Disc: /(?<vfs_disc_mount>\w+)/\r?$", DefaultOptions)]
252+
private static partial Regex DiscMountSys();
251253
[GeneratedRegex(@"Elf path: (?<host_root_in_boot>/host_root/)?(?<elf_boot_path_full>(?<elf_boot_path>/dev_hdd0/game/(?<elf_boot_path_serial>[^/\r\n]+)/USRDIR/EBOOT\.BIN|.*?))\r?$", DefaultOptions)]
252254
private static partial Regex ElfPath();
253255
[GeneratedRegex(@"Mounted path ""/dev_bdvd"" to ""(?<mounted_dev_bdvd>[^""]+)""", DefaultOptions)]
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
namespace CompatBot.Utils;
2+
3+
internal class DiscordAttachmentComparer : IEqualityComparer<DiscordAttachment>
4+
{
5+
bool IEqualityComparer<DiscordAttachment>.Equals(DiscordAttachment? x, DiscordAttachment? y)
6+
{
7+
if (x is null && y is null)
8+
return true;
9+
10+
if (x is null || y is null)
11+
return false;
12+
13+
return x.FileName == y.FileName && x.FileSize == y.FileSize;
14+
}
15+
16+
int IEqualityComparer<DiscordAttachment>.GetHashCode(DiscordAttachment obj)
17+
=> HashCode.Combine((obj.FileName ?? "").GetHashCode(), obj.FileSize.GetHashCode());
18+
19+
public static DiscordAttachmentComparer Instance { get; } = new DiscordAttachmentComparer();
20+
}

CompatBot/Utils/Extensions/DiscordClientExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ private static async ValueTask<DiscordEmbedBuilder> MakeReportTemplateAsync(Disc
256256
Title = infraction,
257257
Color = GetColor(severity),
258258
}.AddField("Violator", author is null ? message.Author.Mention : GetMentionWithNickname(author), true)
259-
.AddField("Channel", message.Channel.IsPrivate ? "Bot's DM" : message.Channel.Mention, true);
259+
.AddField("Channel", message.Channel.IsPrivate ? "Bot's DM" : message.JumpLink.ToString(), true);
260260
if (filterId is not null)
261261
result.AddField("Filter #", filterId.ToString(), true);
262262
result.AddField("Content of the offending item", content.Trim(EmbedPager.MaxFieldLength));

CompatBot/Utils/ResultFormatters/LogParserResultFormatter.GeneralNotesSection.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,12 @@ private static async ValueTask BuildNotesSectionAsync(DiscordEmbedBuilder builde
116116
notes.Add("❌ Disc version of the game inside the `/dev_hdd0/game/` directory");
117117
if (serial is {Length: >0} && isElf)
118118
notes.Add($"⚠️ Retail game booted directly through `{Path.GetFileName(elfBootPath)}`, which is not recommended");
119-
if (items["mounted_dev_bdvd"] is { Length: > 0 } mountedBdvd
119+
120+
if (items["vfs_disc_mount"] is "vfsv0_virtual_iso_overlay_fs_dev")
121+
{
122+
notes.Add("ℹ️ Booted from ISO");
123+
}
124+
else if (items["mounted_dev_bdvd"] is { Length: > 0 } mountedBdvd
120125
&& items["os_type"] is {Length: >0} osType
121126
&& mountedBdvd.Split('/', StringSplitOptions.RemoveEmptyEntries) is {Length: <3} segments
122127
&& (osType is "Windows" && segments is [[_, ':']] // D:/

Tests/Tests.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="10.0.1" />
1111
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.0.1" />
1212
<PackageReference Include="NUnit" Version="4.4.0" />
13-
<PackageReference Include="NUnit3TestAdapter" Version="6.0.1">
13+
<PackageReference Include="NUnit3TestAdapter" Version="6.1.0">
1414
<PrivateAssets>all</PrivateAssets>
1515
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
1616
</PackageReference>

0 commit comments

Comments
 (0)