mirror of
https://github.com/RPCS3/discord-bot.git
synced 2024-12-13 22:08:37 +00:00
shrink full links in issue descriptions
This commit is contained in:
parent
ed3eae728f
commit
0a8ebba7af
@ -13,7 +13,7 @@ namespace CompatBot.EventHandlers
|
||||
internal static class GithubLinksHandler
|
||||
{
|
||||
private const RegexOptions DefaultOptions = RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.Singleline | RegexOptions.ExplicitCapture;
|
||||
public static readonly Regex IssueMention = new Regex(@"(?<issue_mention>\b(issue|pr|pull[ \-]request|bug)\s*#?\s*(?<number>\d+)|(?=\W|^)#(?<also_number>\d{4}))\b", DefaultOptions);
|
||||
public static readonly Regex IssueMention = new Regex(@"(?<issue_mention>\b(issue|pr|pull[ \-]request|bug)\s*#?\s*(?<number>\d+)|(?=\W|^)#(?<also_number>\d{4})|(https?://)github.com/RPCS3/rpcs3/(issues|pull)/(?<another_number>\d+))\b", DefaultOptions);
|
||||
private static readonly Regex IssueLink = new Regex(@"github.com/RPCS3/rpcs3/issues/(?<number>\d+)", DefaultOptions);
|
||||
private static readonly GithubClient.Client Client = new GithubClient.Client();
|
||||
|
||||
|
@ -58,13 +58,19 @@ namespace CompatBot.Utils.ResultFormatters
|
||||
{
|
||||
if (m.Groups["issue_mention"]?.Value is string str && !string.IsNullOrEmpty(str))
|
||||
{
|
||||
var name = str;
|
||||
var num = m.Groups["number"].Value;
|
||||
if (string.IsNullOrEmpty(num))
|
||||
num = m.Groups["also_number"].Value;
|
||||
if (string.IsNullOrEmpty(num))
|
||||
{
|
||||
num = m.Groups["another_number"].Value;
|
||||
name = "#" + num;
|
||||
}
|
||||
if (string.IsNullOrEmpty(num))
|
||||
continue;
|
||||
|
||||
desc = desc.Replace(str, $"[{str}](https://github.com/RPCS3/rpcs3/issues/{num})");
|
||||
desc = desc.Replace(str, $"[{name}](https://github.com/RPCS3/rpcs3/issues/{num})");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user