Evergiven is free once again

This commit is contained in:
Daan Boerlage 2021-03-29 17:45:43 +02:00
parent 9ad39058ac
commit 5b99ee951b
Signed by: daan
GPG key ID: FCE070E1E4956606

View file

@ -23,35 +23,12 @@ namespace Geekbot.Bot.Commands.Utils
{
try
{
var httpClient = HttpAbstractions.CreateDefaultClient();
var response = await httpClient.GetAsync("https://istheshipstillstuck.com/");
response.EnsureSuccessStatusCode();
var stringResponse = await response.Content.ReadAsStringAsync();
var doc = new HtmlDocument();
doc.LoadHtml(stringResponse);
var statusNode = doc.DocumentNode.SelectNodes("//a").FirstOrDefault();
if (statusNode == null)
{
await ReplyAsync("Maybe, check <https://istheshipstillstuck.com/>");
return;
}
var sb = new StringBuilder();
sb.Append($"Is that ship still stuck? {statusNode.InnerHtml}");
if (statusNode.Attributes.Contains("href"))
{
sb.Append($" {statusNode.Attributes["href"].Value}");
}
var stuckTimer = doc.DocumentNode.SelectNodes("//p")?.First(node => node.Attributes.First(attr => attr.Name == "style")?.Value == "text-align:center");
if (stuckTimer != null)
{
sb.AppendLine();
sb.AppendLine(HttpUtility.HtmlDecode(stuckTimer.InnerText));
}
sb.AppendLine("Is that ship still stuck?");
sb.AppendLine("**No!**");
sb.AppendLine("It was stuck for 6 days, 3 hours and 38 minutes. It (probably) cost \"us\" $59 billion.");
sb.AppendLine("You can follow it here: <https://www.vesselfinder.com/?imo=9811000>");
await ReplyAsync(sb.ToString());
}