private string FormatReplyPost(SearchResults result, string postTitle) { CrewData[] crew = { _botHelper.GetCrew(result.crew1.symbol), _botHelper.GetCrew(result.crew2.symbol), _botHelper.GetCrew(result.crew3.symbol) }; if ((crew[0] == null) || (crew[1] == null) || (crew[2] == null)) { return(string.Empty); } string title; var best = BeholdFormatter.GetBest(result, crew, out title); var c1s = CrewFormatter.FormatCrewStats(crew[0], false); var c2s = CrewFormatter.FormatCrewStats(crew[1], false); var c3s = CrewFormatter.FormatCrewStats(crew[2], false); DateTime FutureDate = new DateTime(2020, 3, 1); DateTime TodayDate = DateTime.Now; int days = (FutureDate - TodayDate).Days; if (days <= 0) { return(string.Empty); } if (postTitle.StartsWith("Behold", StringComparison.CurrentCultureIgnoreCase) && (postTitle.Split(',').Length > 1)) { // Appears to have correct title format Func <int, string> perCrewFormat = index => { var mainRanks = $@"Voyage #{crew[index].ranks.voyRank} | Gauntlet #{crew[index].ranks.gauntletRank}"; var statLine = string.Join(" | ", CrewFormatter.FormatCrewStats(crew[index], true)); return($@"# [{crew[index].name}]({_datacoreURL}crew/{crew[index].symbol}) Big Book {(crew[index].bigbook_tier.HasValue ? $"**Tier {crew[index].bigbook_tier.Value}**" : "unranked")} | {mainRanks} | {CrewFormatter.FormatCrewCoolRanks(crew[index], false, " | ")} | {crew[index].collections.Length} collection(s) | {(crew[index].events.HasValue ? $"{crew[index].events.Value} event(s)" : "No events")} {statLine} {crew[index].markdownContent}"); }; return($@"{title} (but read the [detailed comparison]({_datacoreURL}behold/?crew={crew[0].symbol}&crew={crew[1].symbol}&crew={crew[2].symbol}) to see what makes sense for your roster). {perCrewFormat(0)} {perCrewFormat(1)} {perCrewFormat(2)} Talk to TemporalAgent7 if you have questions or comments! **The bot will stop replying in {days} days. Please use [Discord](https://discord.gg/8Du7ZtJ); read [here](https://www.reddit.com/r/StarTrekTimelines/comments/eryf5l/reddit_behold_bot_retiring/) for details.** "); } return($@"This post appears to be a behold, but it doesn't follow the [subreddit rule](https://www.reddit.com/r/StarTrekTimelines/comments/cgf25y/new_subreddit_rule_regarding_behold_posts/) for Behold posts; your post title should be `Behold! {crew[0].name}, {crew[1].name}, {crew[2].name}`. You can delete it and repost if you want me to reply with details. I'll stop replying in {days} days."); }
private async Task ProcessImage(SocketUserMessage message, string url, bool debug) { var result = _searcher.SearchUrl(url); if (result == null) { if (debug) { await message.Channel.SendMessageAsync($"That was not a valid behold image (or I couldn't process it)."); } await ProcessImageVoy(message, url, debug); return; } bool isValidBehold = result.IsValid(9); _logger.LogInformation($"Processed an image url:'{url}' {result.GetLogString(9)} overall {(isValidBehold ? "VALID" : "INVALID")}"); // Not a behold, or couldn't find the crew if (!isValidBehold && !debug) { await ProcessImageVoy(message, url, debug); return; } if (!isValidBehold) { await message.Channel.SendMessageAsync($"That was not a valid behold image (or I couldn't process it). Image {result.GetLogString(9)}"); if (!result.IsValid(2)) { await ProcessImageVoy(message, url, debug); return; } } CrewData[] crew = { _botHelper.GetCrew(result.crew1.symbol), _botHelper.GetCrew(result.crew2.symbol), _botHelper.GetCrew(result.crew3.symbol) }; if ((crew[0] == null) || (crew[1] == null) || (crew[2] == null)) { // Not a behold, or couldn't find the crew if (debug) { await message.Channel.SendMessageAsync($"That was not a valid behold image (or I couldn't find the crew). Image {result.GetLogString(9)}"); } await ProcessImageVoy(message, url, debug); return; } if ((crew[0].max_rarity != crew[1].max_rarity) || (crew[1].max_rarity != crew[2].max_rarity)) { // Not a behold, or couldn't find the crew if (debug) { await message.Channel.SendMessageAsync($"That was not a valid behold image (or I couldn't find correct crew). Image {result.GetLogString(9)}"); } return; } string title; var best = BeholdFormatter.GetBest(result, crew, out title); var embed = new EmbedBuilder() { Title = title + " (but read the detailed comparison to see what makes sense for your roster).", Color = Color.DarkOrange, ThumbnailUrl = $"{_datacoreURL}media/assets/{best.imageUrlPortrait}" }; embed = embed.AddField("Behold helper", $"Hey {message.Author.Mention}, that looks like a behold. Here are some stats for your choices:") .AddField($"{crew[0].name}{((crew[0] == best) ? " - best bet" : "")}", FormatBeholdLine(message, crew[0])) .AddField($"{crew[1].name}{((crew[1] == best) ? " - best bet" : "")}", FormatBeholdLine(message, crew[1])) .AddField($"{crew[2].name}{((crew[2] == best) ? " - best bet" : "")}", FormatBeholdLine(message, crew[2])) .AddField("More stats", $"[In-depth comparison of all three choices]({_datacoreURL}behold/?crew={crew[0].symbol}&crew={crew[1].symbol}&crew={crew[2].symbol})") .WithFooter(footer => footer.Text = "Did I get the crew wrong? I'm still learning, please let @TemporalAgent7 know."); await message.Channel.SendMessageAsync("", false, embed.Build()); }