1
0
Fork 1
mirror of https://github.com/TeamOctolings/Octobot.git synced 2025-01-31 09:09:00 +03:00

Tidy up project structure, fix bug with edit logging (#47)

The project structure has been changed because the previous one had
everything in 1 folder. From this PR onwards, the following is true:
- The source code is stored in `src/`
- `*.resx` and `Messages.Designer.cs` is stored in `locale/`
- Documentation is stored on the wiki and in `docs/`
- Miscellaneous files, such as dotfiles, are stored in the root folder
of the repository

This PR additionally fixes an issue that would cause logs of edited
messages to not be syntax highlighted. This happened because the
responder of edited messages was changed to use the universal
`InBlockCode` extension method which did not support syntax highlighting
until this PR

This PR additionally changes CODEOWNERS to be more reliable. Previously,
it would be possible for some PRs to be unable to be approved because
the only person who can approve them is the same person who opened the
PR.

---------

Signed-off-by: Octol1ttle <l1ttleofficial@outlook.com>
This commit is contained in:
Octol1ttle 2023-07-09 22:36:44 +05:00 committed by GitHub
parent 2dd9f023ef
commit 3eb17b96c5
Signed by: GitHub
GPG key ID: 4AEE18F83AFDEB23
29 changed files with 180 additions and 179 deletions

4
.github/CODEOWNERS vendored
View file

@ -1,4 +1,2 @@
* @TeamOctolings/boyfriend
.github/CODEOWNERS @TeamOctolings/boyfriend-admins
/docs/ @mctaylors
Messages.tt-ru.resx @mctaylors
/docs/ @TeamOctolings/boyfriend-docs

View file

@ -23,8 +23,9 @@
<PackageReference Include="Humanizer.Core.ru" Version="2.14.1"/>
<PackageReference Include="Microsoft.Extensions.Hosting" Version="7.0.1"/>
<PackageReference Include="Remora.Discord" Version="2023.3.0"/>
<EmbeddedResource Update="Messages.resx">
</ItemGroup>
<ItemGroup>
<EmbeddedResource Update="locale\Messages.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Messages.Designer.cs</LastGenOutput>
</EmbeddedResource>

View file

@ -14,7 +14,7 @@
![CodeFactor](https://img.shields.io/codefactor/grade/github/TeamOctolings/Boyfriend)
Beep! I'm a general-purpose bot for moderation written by [@Octol1ttle](https://github.com/Octol1ttle) in C# and
Discord.Net
Remora.Discord
## Features

File diff suppressed because it is too large Load diff

View file

@ -59,8 +59,8 @@ public class AboutCommandGroup : CommandGroup {
builder.AppendLine($"@{dev} — {$"AboutDeveloper@{dev}".Localized()}");
builder.AppendLine()
.AppendLine(Markdown.Bold(Messages.AboutTitleWiki))
.AppendLine("https://github.com/TeamOctolings/Boyfriend/wiki");
.AppendLine(Markdown.Bold(Messages.AboutTitleWiki))
.AppendLine("https://github.com/TeamOctolings/Boyfriend/wiki");
var embed = new EmbedBuilder().WithSmallTitle(Messages.AboutBot, currentUser)
.WithDescription(builder.ToString())

View file

@ -63,10 +63,9 @@ public class BanCommandGroup : CommandGroup {
[RequireBotDiscordPermissions(DiscordPermission.BanMembers)]
[Description("Ban user")]
public async Task<Result> BanUserAsync(
[Description("User to ban")] IUser target,
[Description("Ban reason")] string reason,
[Description("Ban duration")]
TimeSpan? duration = null) {
[Description("User to ban")] IUser target,
[Description("Ban reason")] string reason,
[Description("Ban duration")] TimeSpan? duration = null) {
if (!_context.TryGetContextIDs(out var guildId, out var channelId, out var userId))
return Result.FromError(
new ArgumentNullError(nameof(_context), "Unable to retrieve necessary IDs from command context"));
@ -199,9 +198,8 @@ public class BanCommandGroup : CommandGroup {
[RequireBotDiscordPermissions(DiscordPermission.BanMembers)]
[Description("Unban user")]
public async Task<Result> UnbanUserAsync(
[Description("User to unban")] IUser target,
[Description("Unban reason")]
string reason) {
[Description("User to unban")] IUser target,
[Description("Unban reason")] string reason) {
if (!_context.TryGetContextIDs(out var guildId, out var channelId, out var userId))
return Result.FromError(
new ArgumentNullError(nameof(_context), "Unable to retrieve necessary IDs from command context"));

View file

@ -125,13 +125,17 @@ public static class Extensions {
}
/// <summary>
/// Sanitizes a string (see <see cref="SanitizeForBlockCode" />) and formats the string with block code.
/// Sanitizes a string (see <see cref="SanitizeForBlockCode" />) and formats the string to use Markdown Block Code formatting with a specified
/// language for syntax highlighting.
/// </summary>
/// <param name="s">The string to sanitize and format.</param>
/// <returns>The sanitized string formatted with <see cref="Markdown.BlockCode(string)" />.</returns>
public static string InBlockCode(this string s) {
/// <param name="language"></param>
/// <returns>The sanitized string formatted to use Markdown Block Code with a specified
/// language for syntax highlighting.</returns>
public static string InBlockCode(this string s, string language = "") {
s = s.SanitizeForBlockCode();
return $"```{s.SanitizeForBlockCode()}{(s.EndsWith("`") || string.IsNullOrWhiteSpace(s) ? " " : "")}```";
return
$"```{language}\n{s.SanitizeForBlockCode()}{(s.EndsWith("`") || string.IsNullOrWhiteSpace(s) ? " " : "")}```";
}
public static string Localized(this string key) {
@ -159,7 +163,7 @@ public static class Extensions {
builder.AppendLine(line.Text);
}
return InBlockCode(builder.ToString());
return InBlockCode(builder.ToString(), "diff");
}
public static string GetTag(this IUser user) {