2018-10-08 17:51:19 +00:00
|
|
|
using System.Linq;
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
using DeukBot4.APIHandlers;
|
|
|
|
using DeukBot4.Utilities;
|
|
|
|
using Discord.WebSocket;
|
|
|
|
|
|
|
|
namespace DeukBot4.MessageHandlers.JokeHandling
|
|
|
|
{
|
|
|
|
internal class DeltaJoke : IJokeController
|
|
|
|
{
|
|
|
|
public string Id => "delta";
|
|
|
|
public string Name => "No deltas, it's called Origin";
|
2019-01-29 22:28:52 +00:00
|
|
|
public async Task Run(ReceivedMessage message)
|
2018-10-08 17:51:19 +00:00
|
|
|
{
|
2019-01-29 22:28:52 +00:00
|
|
|
var lowerCasedContent = message.Message.Content.ToLowerInvariant().RemoveSpecialCharacters();
|
2018-10-08 17:51:19 +00:00
|
|
|
if (lowerCasedContent.Contains("origin"))
|
|
|
|
return;
|
|
|
|
|
2019-01-29 22:28:52 +00:00
|
|
|
if (message.IsHandled)
|
|
|
|
return;
|
2018-10-08 17:51:19 +00:00
|
|
|
var lowerSplit = lowerCasedContent.Split(' ');
|
|
|
|
if (lowerSplit.Select(s => Lehvenstein.LevenshteinDistance(s, "delta")).Any(diff => diff <= 1))
|
|
|
|
{
|
2019-01-29 22:28:52 +00:00
|
|
|
if (message.IsHandled)
|
|
|
|
return;
|
|
|
|
message.IsHandled = true;
|
2018-10-08 17:51:19 +00:00
|
|
|
var warning = "uhh excuse me it's called\n Origin and it's an art";
|
2019-01-29 22:28:52 +00:00
|
|
|
await message.Message.Channel.SendFileAsync(await CatPicHandler.GetCatPicture(warning), "cat_pic.png");
|
2018-10-08 17:51:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|