From 9ae35ef46e0bc40b274d3493574665079ec87d6b Mon Sep 17 00:00:00 2001 From: nishinji <107111782+nishinji@users.noreply.github.com> Date: Wed, 20 Nov 2024 01:12:13 +0900 Subject: [PATCH] get build from store repo --- LICENSE.md | 3 +-- README.md | 2 ++ .../APIClients/GithubClient/GithubClient.cs | 20 +++++++++---------- Vita3KBot/Services/MessageHandlingService.cs | 2 +- 4 files changed, 14 insertions(+), 13 deletions(-) create mode 100644 README.md diff --git a/LICENSE.md b/LICENSE.md index b821448..d43bc53 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -1,8 +1,7 @@ -Copyright 2024 Vita3K +Copyright 2024 Vita3K-team Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - diff --git a/README.md b/README.md new file mode 100644 index 0000000..16a8219 --- /dev/null +++ b/README.md @@ -0,0 +1,2 @@ +# Vita3KBot +A bot for the Vita3K Discord server. diff --git a/Vita3KBot/APIClients/GithubClient/GithubClient.cs b/Vita3KBot/APIClients/GithubClient/GithubClient.cs index 24accf2..abd52bc 100644 --- a/Vita3KBot/APIClients/GithubClient/GithubClient.cs +++ b/Vita3KBot/APIClients/GithubClient/GithubClient.cs @@ -11,27 +11,27 @@ public static class GithubClient { public static async Task GetLatestBuild() { GitHubClient github = new GitHubClient(new ProductHeaderValue("Vita3KBot")); - Release latestRelease = await github.Repository.Release.Get("Vita3k", "Vita3k", "continuous"); + Release latestRelease = await github.Repository.Release.Get("Vita3K", "Vita3K-builds", "latest"); string releaseTime = $"Published at {latestRelease.PublishedAt:u}"; ReleaseAsset windowsRelease = latestRelease.Assets.Where(release => { - return release.Name.StartsWith("windows-latest"); + return release.Name.EndsWith("windows.7z"); }).First(); ReleaseAsset linuxRelease = latestRelease.Assets.Where(release => { - return release.Name.StartsWith("ubuntu-latest"); + return release.Name.EndsWith("ubuntu.7z"); }).First(); ReleaseAsset appimageRelease = latestRelease.Assets.Where(release => { - return release.Name.StartsWith("Vita3K-x86_64.AppImage"); + return release.Name.EndsWith("Vita3K-x86_64.AppImage"); }).First(); ReleaseAsset macosRelease = latestRelease.Assets.Where(release => { - return release.Name.StartsWith("macos-latest"); + return release.Name.EndsWith("macos.dmg"); }).First(); - string commit = latestRelease.Body.Substring(latestRelease.Body.IndexOf(":") + 1).Trim(); - commit = commit.Substring(0, commit.IndexOf("\n")); - GitHubCommit REF = await github.Repository.Commit.Get("Vita3k", "Vita3k", commit); - Issue prInfo = await GetPRInfo(github, commit); + string commitSha = latestRelease.Body.Substring(latestRelease.Body.IndexOf("https://github.com/Vita3K/Vita3K/commit/") + 46).Trim(); + commitSha = commitSha.Substring(0, commitSha.IndexOf(")")); + GitHubCommit REF = await github.Repository.Commit.Get("Vita3k", "Vita3k", commitSha); + Issue prInfo = await GetPRInfo(github, commitSha); - EmbedBuilder LatestBuild = new EmbedBuilder(); + EmbedBuilder LatestBuild = new(); if (prInfo != null) { LatestBuild.WithTitle($"PR: #{prInfo.Number} By {prInfo.User.Login}") .WithUrl(prInfo.HtmlUrl); diff --git a/Vita3KBot/Services/MessageHandlingService.cs b/Vita3KBot/Services/MessageHandlingService.cs index 4094b87..8f43c66 100644 --- a/Vita3KBot/Services/MessageHandlingService.cs +++ b/Vita3KBot/Services/MessageHandlingService.cs @@ -41,7 +41,7 @@ private static async Task MonitorNewBuilds(SocketUserMessage msg) { if (msg.Channel.Name != "github" && msg.Author.ToString() != "GitHub#0000") return; var embed = msg.Embeds.FirstOrDefault(); - if (embed != null && embed.Title == "[Vita3K/Vita3K] New release published: continuous") { + if (embed != null && embed.Title.StartsWith("[Vita3K/Vita3K-builds] New release published:")) { var guild = (msg.Channel as SocketGuildChannel).Guild; await guild.GetTextChannel(965725409574539274).SendMessageAsync(embed: await GithubClient.GetLatestBuild()); }