From 6caea8e9e7a4bd86d2b43555f94c46e3e8092107 Mon Sep 17 00:00:00 2001 From: Kwoth Date: Thu, 9 May 2024 01:46:20 +0000 Subject: [PATCH] docs: Updated more links to point to new repo url dev: Fixed project id as nadeko is moved to nadeko/nadekobot --- .gitlab-ci.yml | 2 +- README.md | 2 +- docs/contribution-guide.md | 2 +- mkdocs.yml | 2 +- .../Self/CheckForUpdatesService.cs | 74 +++++++++++-------- src/NadekoBot/Modules/Help/Help.cs | 39 +++++----- 6 files changed, 68 insertions(+), 53 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index b751e6e90..bcdf80a20 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -78,7 +78,7 @@ build: # - if: $CI_COMMIT_TAG # script: # - | -# release-cli create --name "NadekoBot v$CI_COMMIT_TAG" --description "## [Changelog](https://gitlab.com/Kwoth/nadekobot/-/blob/v4/CHANGELOG.md#$(echo "$CI_COMMIT_TAG" | sed "s/\.//g")-$(date +%d%m%Y))" --tag-name $CI_COMMIT_TAG \ +# release-cli create --name "NadekoBot v$CI_COMMIT_TAG" --description "## [Changelog](https://gitlab.com/nadeko/nadekobot/-/blob/v5/CHANGELOG.md#$(echo "$CI_COMMIT_TAG" | sed "s/\.//g")-$(date +%d%m%Y))" --tag-name $CI_COMMIT_TAG \ # --assets-link "{\"name\":\"${LINUX_X64_RELEASE}\",\"url\":\"${PACKAGE_REGISTRY_URL}/${LINUX_X64_RELEASE}\"}" \ # --assets-link "{\"name\":\"${LINUX_ARM64_RELEASE}\",\"url\":\"${PACKAGE_REGISTRY_URL}/${LINUX_ARM64_RELEASE}\"}" \ # --assets-link "{\"name\":\"${WIN_X64_RELEASE}\",\"url\":\"${PACKAGE_REGISTRY_URL}/${WIN_X64_RELEASE}\"}" \ diff --git a/README.md b/README.md index 8bd6c094c..3b5ecdca6 100644 --- a/README.md +++ b/README.md @@ -5,5 +5,5 @@ [![nadeko2](https://cdn.nadeko.bot/tutorial/docs-bot.png)](https://nadeko.bot/commands) ### Useful links -- [Self hosting Guides and Docs](https://nadekobot.readthedocs.io/en/v4) +- [Self hosting Guides and Docs](https://nadekobot.readthedocs.io/en/latest) - [Discord support server](https://discord.nadeko.bot) diff --git a/docs/contribution-guide.md b/docs/contribution-guide.md index 505d83486..92b3c57b6 100644 --- a/docs/contribution-guide.md +++ b/docs/contribution-guide.md @@ -1,6 +1,6 @@ # How to contribute -1. Make Merge Requests to the [**v4 branch**](https://gitlab.com/nadeko/nadekobot/tree/v5) +1. Make Merge Requests to the [**v5 branch**](https://gitlab.com/nadeko/nadekobot/tree/v5) 2. Keep a single Merge Request to a single feature 3. Fill out the MR template diff --git a/mkdocs.yml b/mkdocs.yml index 9dc07e26d..b9a5fc3bc 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -1,6 +1,6 @@ site_name: 'NadekoBot' site_url: 'https://nadeko.bot' -repo_url: 'https://gitlab.com/kwoth/nadekobot' +repo_url: 'https://gitlab.com/nadeko/nadekobot' site_author: 'Kwoth' theme: diff --git a/src/NadekoBot/Modules/Administration/Self/CheckForUpdatesService.cs b/src/NadekoBot/Modules/Administration/Self/CheckForUpdatesService.cs index 754315615..b15ff0648 100644 --- a/src/NadekoBot/Modules/Administration/Self/CheckForUpdatesService.cs +++ b/src/NadekoBot/Modules/Administration/Self/CheckForUpdatesService.cs @@ -1,9 +1,15 @@ ο»Ώusing System.Net.Http.Json; using System.Text; using NadekoBot.Common.ModuleBehaviors; +using System.Text.Json.Serialization; namespace NadekoBot.Modules.Administration.Self; +public sealed class GitlabReleaseModel +{ + [JsonPropertyName("tag_name")] + public required string TagName { get; init; } +} public sealed class CheckForUpdatesService : INService, IReadyExecutor { private readonly BotConfigService _bcs; @@ -12,8 +18,15 @@ public sealed class CheckForUpdatesService : INService, IReadyExecutor private readonly DiscordSocketClient _client; private readonly IMessageSenderService _sender; - public CheckForUpdatesService(BotConfigService bcs, IBotCredsProvider bcp, IHttpClientFactory httpFactory, - DiscordSocketClient client, IMessageSenderService sender) + + private const string RELEASES_URL = "https://gitlab.com/api/v4/projects/57687445/releases"; + + public CheckForUpdatesService( + BotConfigService bcs, + IBotCredsProvider bcp, + IHttpClientFactory httpFactory, + DiscordSocketClient client, + IMessageSenderService sender) { _bcs = bcs; _bcp = bcp; @@ -21,12 +34,12 @@ public sealed class CheckForUpdatesService : INService, IReadyExecutor _client = client; _sender = sender; } - + public async Task OnReadyAsync() { if (_client.ShardId != 0) return; - + using var timer = new PeriodicTimer(TimeSpan.FromHours(1)); while (await timer.WaitForNextTickAsync()) { @@ -34,17 +47,17 @@ public sealed class CheckForUpdatesService : INService, IReadyExecutor if (!conf.CheckForUpdates) continue; - + try { - const string URL = "https://cdn.nadeko.bot/cmds/versions.json"; using var http = _httpFactory.CreateClient(); - var versions = await http.GetFromJsonAsync(URL); + var gitlabRelease = (await http.GetFromJsonAsync(RELEASES_URL)) + ?.FirstOrDefault(); - if (versions is null) + if (gitlabRelease?.TagName is null) continue; - - var latest = versions[0]; + + var latest = gitlabRelease.TagName; var latestVersion = Version.Parse(latest); var lastKnownVersion = GetLastKnownVersion(); @@ -53,13 +66,13 @@ public sealed class CheckForUpdatesService : INService, IReadyExecutor UpdateLastKnownVersion(latestVersion); continue; } - + if (latestVersion > lastKnownVersion) { UpdateLastKnownVersion(latestVersion); - + // pull changelog - var changelog = await http.GetStringAsync("https://gitlab.com/Kwoth/nadekobot/-/raw/v4/CHANGELOG.md"); + var changelog = await http.GetStringAsync("https://gitlab.com/nadeko/nadekobot/-/raw/v5/CHANGELOG.md"); var thisVersionChangelog = GetVersionChangelog(latestVersion, changelog); @@ -72,22 +85,24 @@ public sealed class CheckForUpdatesService : INService, IReadyExecutor var creds = _bcp.GetCreds(); await creds.OwnerIds - .Select(async x => - { - var user = await _client.GetUserAsync(x); - if (user is null) - return; + .Select(async x => + { + var user = await _client.GetUserAsync(x); + if (user is null) + return; - var eb = _sender.CreateEmbed() - .WithOkColor() - .WithAuthor($"NadekoBot v{latestVersion} Released!") - .WithTitle("Changelog") - .WithUrl("https://gitlab.com/Kwoth/nadekobot/-/blob/v4/CHANGELOG.md") - .WithDescription(thisVersionChangelog.TrimTo(4096)) - .WithFooter("You may disable these messages by typing '.conf bot checkforupdates false'"); + var eb = _sender.CreateEmbed() + .WithOkColor() + .WithAuthor($"NadekoBot v{latest} Released!") + .WithTitle("Changelog") + .WithUrl("https://gitlab.com/nadeko/nadekobot/-/blob/v5/CHANGELOG.md") + .WithDescription(thisVersionChangelog.TrimTo(4096)) + .WithFooter( + "You may disable these messages by typing '.conf bot checkforupdates false'"); - await _sender.Response(user).Embed(eb).SendAsync(); - }).WhenAll(); + await _sender.Response(user).Embed(eb).SendAsync(); + }) + .WhenAll(); } } catch (Exception ex) @@ -111,7 +126,7 @@ public sealed class CheckForUpdatesService : INService, IReadyExecutor // if we got to previous version, end if (line.StartsWith("## [")) break; - + // if we're reading a new segment, reformat it to print it better to discord if (line.StartsWith("### ")) { @@ -136,11 +151,12 @@ public sealed class CheckForUpdatesService : INService, IReadyExecutor } private const string LAST_KNOWN_VERSION_PATH = "data/last_known_version.txt"; + private Version? GetLastKnownVersion() { if (!File.Exists(LAST_KNOWN_VERSION_PATH)) return null; - + return Version.TryParse(File.ReadAllText(LAST_KNOWN_VERSION_PATH), out var ver) ? ver : null; diff --git a/src/NadekoBot/Modules/Help/Help.cs b/src/NadekoBot/Modules/Help/Help.cs index a6d1fd7c3..6ce51ece4 100644 --- a/src/NadekoBot/Modules/Help/Help.cs +++ b/src/NadekoBot/Modules/Help/Help.cs @@ -519,7 +519,7 @@ public sealed class Help : NadekoModule => smc.RespondConfirmAsync(_sender, """ - In case you don't want or cannot Donate to NadekoBot project, but you - - NadekoBot is a completely free and fully [open source](https://gitlab.com/kwoth/nadekobot) project which means you can run your own "selfhosted" instance on your computer or server for free. + - NadekoBot is a free and [open source](https://gitlab.com/nadeko/nadekobot) project which means you can run your own "selfhosted" instance on your computer. *Keep in mind that running the bot on your computer means that the bot will be offline when you turn off your computer* @@ -532,7 +532,6 @@ public sealed class Help : NadekoModule [OnlyPublicBot] public async Task Donate() { - // => new NadekoInteractionData(new Emoji("πŸ–₯️"), "donate:selfhosting", "Selfhosting"); var selfhostInter = _inter.Create(ctx.User.Id, new SimpleInteraction(new ButtonBuilder( emote: new Emoji("πŸ–₯️"), @@ -545,33 +544,33 @@ public sealed class Help : NadekoModule .WithTitle("Thank you for considering to donate to the NadekoBot project!"); eb - .WithDescription("NadekoBot relies on donations to keep the servers, services and APIs running.\n" - + "Donating will give you access to some exclusive features. You can read about them on the [patreon page](https://patreon.com/join/nadekobot)") + .WithDescription(""" + NadekoBot relies on donations to keep the servers, services and APIs running. + Donating will give you access to some exclusive features. You can read about them on the [patreon page](https://patreon.com/join/nadekobot) + """) .AddField("Donation Instructions", - $@" -πŸ—’οΈ Before pledging it is recommended to open your DMs as Nadeko will send you a welcome message with instructions after you pledge has been processed and confirmed. + $""" + πŸ—’οΈ Before pledging it is recommended to open your DMs as Nadeko will send you a welcome message with instructions after you pledge has been processed and confirmed. -**Step 1:** ❀️ Pledge on Patreon ❀️ + **Step 1:** ❀️ Pledge on Patreon ❀️ -`1.` Go to and choose a tier. -`2.` Make sure your payment is processed and accepted. + `1.` Go to and choose a tier. + `2.` Make sure your payment is processed and accepted. -**Step 2** 🀝 Connect your Discord account 🀝 + **Step 2** 🀝 Connect your Discord account 🀝 -`1.` Go to your profile settings on Patreon and connect your Discord account to it. -*please make sure you're logged into the correct Discord account* + `1.` Go to your profile settings on Patreon and connect your Discord account to it. + *please make sure you're logged into the correct Discord account* -If you do not know how to do it, you may follow instructions in this link: - + If you do not know how to do it, you may [follow instructions here](https://support.patreon.com/hc/en-us/articles/212052266-How-do-I-connect-Discord-to-Patreon-Patron-) -**Step 3** ⏰ Wait a short while (usually 1-3 minutes) ⏰ - -Nadeko will DM you the welcome instructions, and you may start using the patron-only commands and features! -πŸŽ‰ **Enjoy!** πŸŽ‰ -") + **Step 3** ⏰ Wait a short while (usually 1-3 minutes) ⏰ + + Nadeko will DM you the welcome instructions, and you may will receive your rewards! + πŸŽ‰ **Enjoy!** πŸŽ‰ + """) .AddField("Troubleshooting", """ - *In case you didn't receive the rewards within 5 minutes:* `1.` Make sure your DMs are open to everyone. Maybe your pledge was processed successfully but the bot was unable to DM you. Use the `.patron` command to check your status. `2.` Make sure you've connected the CORRECT Discord account. Quite often users log in to different Discord accounts in their browser. You may also try disconnecting and reconnecting your account.