Add !evergiven to see if the ship is still stuck in the suez canal
This commit is contained in:
parent
49870b6b91
commit
41e0a9f8d7
6 changed files with 192 additions and 1 deletions
|
@ -88,6 +88,10 @@
|
||||||
<Generator>ResXFileCodeGenerator</Generator>
|
<Generator>ResXFileCodeGenerator</Generator>
|
||||||
<LastGenOutput>Corona.Designer.cs</LastGenOutput>
|
<LastGenOutput>Corona.Designer.cs</LastGenOutput>
|
||||||
</EmbeddedResource>
|
</EmbeddedResource>
|
||||||
|
<EmbeddedResource Update="Localization\Evergiven.resx">
|
||||||
|
<Generator>ResXFileCodeGenerator</Generator>
|
||||||
|
<LastGenOutput>Evergiven.Designer.cs</LastGenOutput>
|
||||||
|
</EmbeddedResource>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Update="Localization\Ship.Designer.cs">
|
<Compile Update="Localization\Ship.Designer.cs">
|
||||||
|
@ -153,5 +157,10 @@
|
||||||
<AutoGen>True</AutoGen>
|
<AutoGen>True</AutoGen>
|
||||||
<DependentUpon>Corona.resx</DependentUpon>
|
<DependentUpon>Corona.resx</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
<Compile Update="Localization\Evergiven.Designer.cs">
|
||||||
|
<DesignTime>True</DesignTime>
|
||||||
|
<AutoGen>True</AutoGen>
|
||||||
|
<DependentUpon>Evergiven.resx</DependentUpon>
|
||||||
|
</Compile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
|
50
src/Bot/Commands/Utils/Evergiven.cs
Normal file
50
src/Bot/Commands/Utils/Evergiven.cs
Normal file
|
@ -0,0 +1,50 @@
|
||||||
|
using System;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Discord.Commands;
|
||||||
|
using Geekbot.Bot.Utils;
|
||||||
|
using Geekbot.Core;
|
||||||
|
using Geekbot.Core.ErrorHandling;
|
||||||
|
using Geekbot.Core.GuildSettingsManager;
|
||||||
|
using HtmlAgilityPack;
|
||||||
|
|
||||||
|
namespace Geekbot.Bot.Commands.Utils
|
||||||
|
{
|
||||||
|
public class Evergiven : GeekbotCommandBase
|
||||||
|
{
|
||||||
|
public Evergiven(IErrorHandler errorHandler, IGuildSettingsManager guildSettingsManager) : base(errorHandler, guildSettingsManager)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
[Command("evergiven", RunMode = RunMode.Async)]
|
||||||
|
[Summary("Check if the evergiven ship is still stuck in the suez canal")]
|
||||||
|
public async Task GetStatus()
|
||||||
|
{
|
||||||
|
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 yesOrNoNode = doc.DocumentNode.SelectNodes("//a").FirstOrDefault();
|
||||||
|
|
||||||
|
if (yesOrNoNode?.InnerHtml == "Yes.")
|
||||||
|
{
|
||||||
|
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}");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
await ReplyAsync(Localization.Evergiven.NotStuckAnymore);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
await ErrorHandler.HandleCommandException(e, Context);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
81
src/Bot/Localization/Evergiven.Designer.cs
generated
Normal file
81
src/Bot/Localization/Evergiven.Designer.cs
generated
Normal file
|
@ -0,0 +1,81 @@
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
// <auto-generated>
|
||||||
|
// 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.
|
||||||
|
// </auto-generated>
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
namespace Geekbot.Bot.Localization {
|
||||||
|
using System;
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A strongly-typed resource class, for looking up localized strings, etc.
|
||||||
|
/// </summary>
|
||||||
|
// 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() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns the cached ResourceManager instance used by this class.
|
||||||
|
/// </summary>
|
||||||
|
[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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Overrides the current thread's CurrentUICulture property for all
|
||||||
|
/// resource lookups using this strongly typed resource class.
|
||||||
|
/// </summary>
|
||||||
|
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||||
|
internal static global::System.Globalization.CultureInfo Culture {
|
||||||
|
get {
|
||||||
|
return resourceCulture;
|
||||||
|
}
|
||||||
|
set {
|
||||||
|
resourceCulture = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to Seems like Ever Given has moved on, check https://istheshipstillstuck.com/.
|
||||||
|
/// </summary>
|
||||||
|
internal static string NotStuckAnymore {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("NotStuckAnymore", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to Ever Given is **still stuck** in the suez canal! It has been stuck for {0}.
|
||||||
|
/// </summary>
|
||||||
|
internal static string StillStuck {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("StillStuck", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
20
src/Bot/Localization/Evergiven.de-ch.resx
Normal file
20
src/Bot/Localization/Evergiven.de-ch.resx
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
<root>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>1.3</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<data name="StillStuck" xml:space="preserve">
|
||||||
|
<value>Ever Given **steckt immer no fescht** im Suez Kanal! Es isch derte siit {0}</value>
|
||||||
|
</data>
|
||||||
|
<data name="NotStuckAnymore" xml:space="preserve">
|
||||||
|
<value>Es gseht danach us das Ever Given wiiter gange isch, gsehne https://istheshipstillstuck.com/</value>
|
||||||
|
</data>
|
||||||
|
</root>
|
27
src/Bot/Localization/Evergiven.resx
Normal file
27
src/Bot/Localization/Evergiven.resx
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
|
||||||
|
<root>
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>1.3</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<data name="NotStuckAnymore" xml:space="preserve">
|
||||||
|
<value>Seems like Ever Given has moved on, check https://istheshipstillstuck.com/</value>
|
||||||
|
</data>
|
||||||
|
<data name="StillStuck" xml:space="preserve">
|
||||||
|
<value>Ever Given is **still stuck** in the suez canal! It has been stuck for {0}</value>
|
||||||
|
</data>
|
||||||
|
</root>
|
|
@ -7,7 +7,11 @@ namespace Geekbot.Bot.Utils
|
||||||
{
|
{
|
||||||
public static string FormatDateTimeAsRemaining(DateTimeOffset dateTime)
|
public static string FormatDateTimeAsRemaining(DateTimeOffset dateTime)
|
||||||
{
|
{
|
||||||
var remaining = dateTime - DateTimeOffset.Now;
|
return FormatDateTimeAsRemaining(dateTime - DateTimeOffset.Now);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string FormatDateTimeAsRemaining(TimeSpan remaining)
|
||||||
|
{
|
||||||
const string formattable = "{0} {1}";
|
const string formattable = "{0} {1}";
|
||||||
var sb = new StringBuilder();
|
var sb = new StringBuilder();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue