diff --git a/src/Bot/Bot.csproj b/src/Bot/Bot.csproj index 2b1cdae..9312ac1 100644 --- a/src/Bot/Bot.csproj +++ b/src/Bot/Bot.csproj @@ -88,10 +88,6 @@ ResXFileCodeGenerator Corona.Designer.cs - - ResXFileCodeGenerator - Evergiven.Designer.cs - @@ -157,10 +153,5 @@ True Corona.resx - - True - True - Evergiven.resx - diff --git a/src/Bot/Commands/Utils/Evergiven.cs b/src/Bot/Commands/Utils/Evergiven.cs index 663fb0a..1115eaf 100644 --- a/src/Bot/Commands/Utils/Evergiven.cs +++ b/src/Bot/Commands/Utils/Evergiven.cs @@ -1,8 +1,9 @@ using System; using System.Linq; +using System.Text; using System.Threading.Tasks; +using System.Web; using Discord.Commands; -using Geekbot.Bot.Utils; using Geekbot.Core; using Geekbot.Core.ErrorHandling; using Geekbot.Core.GuildSettingsManager; @@ -29,17 +30,30 @@ namespace Geekbot.Bot.Commands.Utils var doc = new HtmlDocument(); doc.LoadHtml(stringResponse); - var yesOrNoNode = doc.DocumentNode.SelectNodes("//a").FirstOrDefault(); + var statusNode = doc.DocumentNode.SelectNodes("//a").FirstOrDefault(); - if (yesOrNoNode?.InnerHtml == "Yes.") + if (statusNode == null) { - var stuckSince = DateTime.Now - new DateTime(2021, 03, 23, 10, 39, 0); - var formatted = DateLocalization.FormatDateTimeAsRemaining(stuckSince); - await ReplyAsync(string.Format(Localization.Evergiven.StillStuck, formatted));// $"Ever Given is **still stuck** in the suez canal! It has been stuck for {formatted}"); + await ReplyAsync("Maybe, check "); return; } - await ReplyAsync(Localization.Evergiven.NotStuckAnymore); + 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)); + } + + await ReplyAsync(sb.ToString()); } catch (Exception e) { diff --git a/src/Bot/Localization/Evergiven.Designer.cs b/src/Bot/Localization/Evergiven.Designer.cs deleted file mode 100644 index 7f66fed..0000000 --- a/src/Bot/Localization/Evergiven.Designer.cs +++ /dev/null @@ -1,81 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.42000 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace Geekbot.Bot.Localization { - using System; - - - /// - /// A strongly-typed resource class, for looking up localized strings, etc. - /// - // This class was auto-generated by the StronglyTypedResourceBuilder - // class via a tool like ResGen or Visual Studio. - // To add or remove a member, edit your .ResX file then rerun ResGen - // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - internal class Evergiven { - - private static global::System.Resources.ResourceManager resourceMan; - - private static global::System.Globalization.CultureInfo resourceCulture; - - [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - internal Evergiven() { - } - - /// - /// Returns the cached ResourceManager instance used by this class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Resources.ResourceManager ResourceManager { - get { - if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Geekbot.Bot.Localization.Evergiven", typeof(Evergiven).Assembly); - resourceMan = temp; - } - return resourceMan; - } - } - - /// - /// Overrides the current thread's CurrentUICulture property for all - /// resource lookups using this strongly typed resource class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Globalization.CultureInfo Culture { - get { - return resourceCulture; - } - set { - resourceCulture = value; - } - } - - /// - /// Looks up a localized string similar to Seems like Ever Given has moved on, check https://istheshipstillstuck.com/. - /// - internal static string NotStuckAnymore { - get { - return ResourceManager.GetString("NotStuckAnymore", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Ever Given is **still stuck** in the suez canal! It has been stuck for {0}. - /// - internal static string StillStuck { - get { - return ResourceManager.GetString("StillStuck", resourceCulture); - } - } - } -} diff --git a/src/Bot/Localization/Evergiven.de-ch.resx b/src/Bot/Localization/Evergiven.de-ch.resx deleted file mode 100644 index b1563fc..0000000 --- a/src/Bot/Localization/Evergiven.de-ch.resx +++ /dev/null @@ -1,20 +0,0 @@ - - - text/microsoft-resx - - - 1.3 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - Ever Given **steckt immer no fescht** im Suez Kanal! Es isch derte siit {0} - - - Es gseht danach us das Ever Given wiiter gange isch, gsehne https://istheshipstillstuck.com/ - - \ No newline at end of file diff --git a/src/Bot/Localization/Evergiven.resx b/src/Bot/Localization/Evergiven.resx deleted file mode 100644 index 36fb012..0000000 --- a/src/Bot/Localization/Evergiven.resx +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - - - - - text/microsoft-resx - - - 1.3 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - Seems like Ever Given has moved on, check https://istheshipstillstuck.com/ - - - Ever Given is **still stuck** in the suez canal! It has been stuck for {0} - - \ No newline at end of file