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

Add GitInfo NuGet package (#268)

In this PR, I added a NuGet package called GitInfo. It can replace
Octobot.RepositoryUrl and display the bot version as the current branch
and commit.

---------

Signed-off-by: mctaylors <cantsendmails@mctaylors.ru>
Signed-off-by: Macintxsh <95250141+mctaylors@users.noreply.github.com>
This commit is contained in:
Macintxsh 2024-03-19 20:51:32 +03:00 committed by GitHub
parent 771750c922
commit 2342116e87
Signed by: GitHub
GPG key ID: B5690EEEBB952194
10 changed files with 75 additions and 9 deletions

View file

@ -17,10 +17,12 @@
<NeutralLanguage>en</NeutralLanguage>
<Description>A general-purpose Discord bot for moderation written in C#</Description>
<ApplicationIcon>docs/octobot.ico</ApplicationIcon>
<GitVersion>false</GitVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="DiffPlex" Version="1.7.2" />
<PackageReference Include="GitInfo" Version="3.3.4" />
<PackageReference Include="Humanizer.Core.ru" Version="2.14.1" />
<PackageReference Include="JetBrains.Annotations" Version="2023.3.0" />
<PackageReference Include="Microsoft.CodeAnalysis.BannedApiAnalyzers" Version="3.3.4" />

View file

@ -657,6 +657,9 @@
<data name="TimeSpanExample" xml:space="preserve">
<value>Example of a valid input: `1h30m`</value>
</data>
<data name="Version" xml:space="preserve">
<value>Version: {0}</value>
</data>
<data name="SettingsWelcomeMessagesChannel" xml:space="preserve">
<value>Welcome messages channel</value>
</data>

View file

@ -657,6 +657,9 @@
<data name="TimeSpanExample" xml:space="preserve">
<value>Пример правильного ввода: `1ч30м`</value>
</data>
<data name="Version" xml:space="preserve">
<value>Версия: {0}</value>
</data>
<data name="SettingsWelcomeMessagesChannel" xml:space="preserve">
<value>Канал для приветствий</value>
</data>

View file

@ -657,6 +657,9 @@
<data name="TimeSpanExample" xml:space="preserve">
<value>правильно пишут так: `1h30m`</value>
</data>
<data name="Version" xml:space="preserve">
<value>{0}</value>
</data>
<data name="SettingsWelcomeMessagesChannel" xml:space="preserve">
<value>канал куда говорить здравствуйте</value>
</data>

52
src/BuildInfo.cs Normal file
View file

@ -0,0 +1,52 @@
namespace Octobot;
public static class BuildInfo
{
public static string RepositoryUrl
{
get
{
return ThisAssembly.Git.RepositoryUrl;
}
}
public static string IssuesUrl
{
get
{
return $"{RepositoryUrl}/issues";
}
}
private static string Commit
{
get
{
return ThisAssembly.Git.Commit;
}
}
private static string Branch
{
get
{
return ThisAssembly.Git.Branch;
}
}
private static bool IsDirty
{
get
{
return ThisAssembly.Git.IsDirty;
}
}
public static string Version
{
get
{
return IsDirty ? $"{Branch}-{Commit}-dirty" : $"{Branch}-{Commit}";
}
}
}

View file

@ -101,20 +101,21 @@ public class AboutCommandGroup : CommandGroup
.WithDescription(builder.ToString())
.WithColour(ColorsList.Cyan)
.WithImageUrl("https://i.ibb.co/fS6wZhh/octobot-banner.png")
.WithFooter(string.Format(Messages.Version, BuildInfo.Version))
.Build();
var repositoryButton = new ButtonComponent(
ButtonComponentStyle.Link,
Messages.ButtonOpenRepository,
new PartialEmoji(Name: "🌐"),
URL: Octobot.RepositoryUrl
URL: BuildInfo.RepositoryUrl
);
var issuesButton = new ButtonComponent(
ButtonComponentStyle.Link,
Messages.ButtonReportIssue,
new PartialEmoji(Name: "⚠️"),
URL: Octobot.IssuesUrl
URL: BuildInfo.IssuesUrl
);
return await _feedback.SendContextualEmbedResultAsync(embed,

View file

@ -72,7 +72,7 @@ public class ErrorLoggingPostExecutionEvent : IPostExecutionEvent
ButtonComponentStyle.Link,
Messages.ButtonReportIssue,
new PartialEmoji(Name: "⚠️"),
URL: Octobot.IssuesUrl
URL: BuildInfo.IssuesUrl
);
return await _feedback.SendContextualEmbedResultAsync(embed,

View file

@ -1185,8 +1185,13 @@ namespace Octobot {
}
}
internal static string SettingsWelcomeMessagesChannel
{
internal static string Version {
get {
return ResourceManager.GetString("Version", resourceCulture);
}
}
internal static string SettingsWelcomeMessagesChannel {
get {
return ResourceManager.GetString("SettingsWelcomeMessagesChannel", resourceCulture);
}

View file

@ -22,9 +22,6 @@ namespace Octobot;
public sealed class Octobot
{
public const string RepositoryUrl = "https://github.com/TeamOctolings/Octobot";
public const string IssuesUrl = $"{RepositoryUrl}/issues";
public static readonly AllowedMentions NoMentions = new(
Array.Empty<MentionType>(), Array.Empty<Snowflake>(), Array.Empty<Snowflake>());

View file

@ -117,7 +117,7 @@ public class GuildLoadedResponder : IResponder<IGuildCreate>
ButtonComponentStyle.Link,
Messages.ButtonReportIssue,
new PartialEmoji(Name: "⚠️"),
URL: Octobot.IssuesUrl
URL: BuildInfo.IssuesUrl
);
return await _channelApi.CreateMessageWithEmbedResultAsync(channel, embedResult: errorEmbed,