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> <NeutralLanguage>en</NeutralLanguage>
<Description>A general-purpose Discord bot for moderation written in C#</Description> <Description>A general-purpose Discord bot for moderation written in C#</Description>
<ApplicationIcon>docs/octobot.ico</ApplicationIcon> <ApplicationIcon>docs/octobot.ico</ApplicationIcon>
<GitVersion>false</GitVersion>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="DiffPlex" Version="1.7.2" /> <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="Humanizer.Core.ru" Version="2.14.1" />
<PackageReference Include="JetBrains.Annotations" Version="2023.3.0" /> <PackageReference Include="JetBrains.Annotations" Version="2023.3.0" />
<PackageReference Include="Microsoft.CodeAnalysis.BannedApiAnalyzers" Version="3.3.4" /> <PackageReference Include="Microsoft.CodeAnalysis.BannedApiAnalyzers" Version="3.3.4" />

View file

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

View file

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

View file

@ -657,6 +657,9 @@
<data name="TimeSpanExample" xml:space="preserve"> <data name="TimeSpanExample" xml:space="preserve">
<value>правильно пишут так: `1h30m`</value> <value>правильно пишут так: `1h30m`</value>
</data> </data>
<data name="Version" xml:space="preserve">
<value>{0}</value>
</data>
<data name="SettingsWelcomeMessagesChannel" xml:space="preserve"> <data name="SettingsWelcomeMessagesChannel" xml:space="preserve">
<value>канал куда говорить здравствуйте</value> <value>канал куда говорить здравствуйте</value>
</data> </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()) .WithDescription(builder.ToString())
.WithColour(ColorsList.Cyan) .WithColour(ColorsList.Cyan)
.WithImageUrl("https://i.ibb.co/fS6wZhh/octobot-banner.png") .WithImageUrl("https://i.ibb.co/fS6wZhh/octobot-banner.png")
.WithFooter(string.Format(Messages.Version, BuildInfo.Version))
.Build(); .Build();
var repositoryButton = new ButtonComponent( var repositoryButton = new ButtonComponent(
ButtonComponentStyle.Link, ButtonComponentStyle.Link,
Messages.ButtonOpenRepository, Messages.ButtonOpenRepository,
new PartialEmoji(Name: "🌐"), new PartialEmoji(Name: "🌐"),
URL: Octobot.RepositoryUrl URL: BuildInfo.RepositoryUrl
); );
var issuesButton = new ButtonComponent( var issuesButton = new ButtonComponent(
ButtonComponentStyle.Link, ButtonComponentStyle.Link,
Messages.ButtonReportIssue, Messages.ButtonReportIssue,
new PartialEmoji(Name: "⚠️"), new PartialEmoji(Name: "⚠️"),
URL: Octobot.IssuesUrl URL: BuildInfo.IssuesUrl
); );
return await _feedback.SendContextualEmbedResultAsync(embed, return await _feedback.SendContextualEmbedResultAsync(embed,

View file

@ -72,7 +72,7 @@ public class ErrorLoggingPostExecutionEvent : IPostExecutionEvent
ButtonComponentStyle.Link, ButtonComponentStyle.Link,
Messages.ButtonReportIssue, Messages.ButtonReportIssue,
new PartialEmoji(Name: "⚠️"), new PartialEmoji(Name: "⚠️"),
URL: Octobot.IssuesUrl URL: BuildInfo.IssuesUrl
); );
return await _feedback.SendContextualEmbedResultAsync(embed, 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 { get {
return ResourceManager.GetString("SettingsWelcomeMessagesChannel", resourceCulture); return ResourceManager.GetString("SettingsWelcomeMessagesChannel", resourceCulture);
} }

View file

@ -22,9 +22,6 @@ namespace Octobot;
public sealed class 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( public static readonly AllowedMentions NoMentions = new(
Array.Empty<MentionType>(), Array.Empty<Snowflake>(), Array.Empty<Snowflake>()); Array.Empty<MentionType>(), Array.Empty<Snowflake>(), Array.Empty<Snowflake>());

View file

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