Merge pull request #120 from 13xforever/vnext

Update title info formatting for compat search results and embeds
This commit is contained in:
Ilya 2018-11-06 19:02:51 +05:00 committed by GitHub
commit d9381af291
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 12 deletions

View File

@ -177,7 +177,7 @@ Example usage:
var channel = ctx.Channel.IsPrivate ? ctx.Channel : await ctx.Client.GetChannelAsync(Config.BotChannelId).ConfigureAwait(false);
foreach (var msg in FormatSearchResults(ctx, result))
await channel.SendAutosplitMessageAsync(msg).ConfigureAwait(false);
await channel.SendAutosplitMessageAsync(msg, blockStart:"", blockEnd:"").ConfigureAwait(false);
}
private IEnumerable<string> FormatSearchResults(CommandContext ctx, CompatResult compatResult)
@ -204,23 +204,18 @@ Example usage:
}
result.AppendFormat(returnCode.info, compatResult.SearchTerm);
yield return result.ToString();
result.Clear();
//var footer = $"Retrieved from: *<{request.Build(false).ToString().Replace(' ', '+')}>* in {compatResult.RequestDuration.TotalMilliseconds:0} milliseconds!";
if (returnCode.displayResults)
{
result.Append("```");
foreach (var resultInfo in compatResult.Results.Take(request.amountRequested))
{
var info = resultInfo.AsString();
result.AppendLine(info);
}
result.Append("```");
yield return result.ToString();
//yield return footer;
}
//else if (returnCode.displayFooter)
// yield return footer;
}
}
}

View File

@ -31,9 +31,9 @@ namespace CompatBot.Utils.ResultFormatters
return defaultString;
if (link)
return $"[{info.Pr}](https://github.com/RPCS3/rpcs3/pull/{info.Pr})";
return $"[#{info.Pr}](https://github.com/RPCS3/rpcs3/pull/{info.Pr})";
return info.Pr.ToString();
return $"#{info.Pr}";
}
public static string AsString(this TitleInfo info, string titleId)
@ -47,7 +47,7 @@ namespace CompatBot.Utils.ResultFormatters
if (StatusColors.TryGetValue(info.Status, out _))
{
var title = info.Title.Trim(40);
return $"ID:{titleId,-9} Title:{title,-40} PR:{info.ToPrString("???"),-4} Status:{info.Status,-8} Updated:{info.ToUpdated(),-10}";
return $"`[{titleId,-9}] {title,-40} {info.Status,8} since {info.ToUpdated(),-10} (PR {info.ToPrString("#????"),-5})` https://forums.rpcs3.net/thread-{info.Thread}.html";
}
return $"Product code {titleId} was not found in compatibility database, possibly untested!";
@ -67,8 +67,10 @@ namespace CompatBot.Utils.ResultFormatters
if (StatusColors.TryGetValue(info.Status, out var color))
{
// apparently there's no formatting in the footer, but you need to escape everything in description; ugh
var pr = info.ToPrString(@"¯\\\_(ツ)\_ /¯", true);
var desc = $"Status: {info.Status}, PR: {pr}, Updated: {info.ToUpdated()}";
var pr = info.ToPrString(null, true);
var desc = $"{info.Status} since {info.ToUpdated()}";
if (pr is string _)
desc += $" (PR {pr})";
if (!forLog && !string.IsNullOrEmpty(info.AlternativeTitle))
desc = info.AlternativeTitle + Environment.NewLine + desc;
if (!string.IsNullOrEmpty(info.WikiTitle))