2018-11-12 23:37:13 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Threading.Tasks;
|
2019-04-28 14:06:27 +00:00
|
|
|
|
using CompatApiClient.Utils;
|
2019-02-24 21:05:29 +00:00
|
|
|
|
using CompatBot.Utils;
|
2019-04-28 14:06:27 +00:00
|
|
|
|
using DSharpPlus.Entities;
|
2018-11-12 23:37:13 +00:00
|
|
|
|
using DSharpPlus.EventArgs;
|
|
|
|
|
|
|
|
|
|
namespace CompatBot.EventHandlers
|
|
|
|
|
{
|
|
|
|
|
internal static class TableFlipMonitor
|
|
|
|
|
{
|
|
|
|
|
private static readonly char[] OpenParen = {'(', '(', 'ʕ'};
|
|
|
|
|
|
|
|
|
|
public static async Task OnMessageCreated(MessageCreateEventArgs args)
|
|
|
|
|
{
|
2019-02-24 21:05:29 +00:00
|
|
|
|
if (DefaultHandlerFilter.IsFluff(args.Message))
|
2018-11-12 23:37:13 +00:00
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* (╯°□°)╯︵ ┻━┻
|
|
|
|
|
* (ノ ゜Д゜)ノ ︵ ┻━┻
|
|
|
|
|
* (ノಠ益ಠ)ノ彡┻━┻
|
|
|
|
|
* (ノಥ益ಥ)ノ ┻━┻
|
|
|
|
|
* (ノಥДಥ)ノ︵┻━┻・/
|
|
|
|
|
* (ノ^_^)ノ┻━┻
|
|
|
|
|
* (/¯◡ ‿ ◡)/¯ ~ ┻━┻
|
|
|
|
|
*
|
2018-11-16 14:27:20 +00:00
|
|
|
|
* this might look the same, but only because of the font choice
|
|
|
|
|
*
|
2018-11-12 23:37:13 +00:00
|
|
|
|
* ┻━┻
|
|
|
|
|
* ┻━┻
|
|
|
|
|
*/
|
|
|
|
|
try
|
|
|
|
|
{
|
2019-02-24 21:05:29 +00:00
|
|
|
|
var content = args.Message.Content;
|
2018-11-12 23:37:13 +00:00
|
|
|
|
if (!(content.Contains("┻━┻") ||
|
|
|
|
|
content.Contains("┻━┻")))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
var tableIdx = content.IndexOf("┻━┻");
|
|
|
|
|
if (tableIdx < 0)
|
|
|
|
|
tableIdx = content.IndexOf("┻━┻");
|
2019-11-05 22:45:31 +00:00
|
|
|
|
var faceIdx = content[..tableIdx].LastIndexOfAny(OpenParen);
|
2018-11-12 23:37:13 +00:00
|
|
|
|
var face = content.Substring(faceIdx, tableIdx - faceIdx);
|
2019-04-28 14:11:45 +00:00
|
|
|
|
if (face.Length > 30)
|
2019-04-28 14:06:27 +00:00
|
|
|
|
return;
|
|
|
|
|
|
2018-11-12 23:37:13 +00:00
|
|
|
|
var reverseFace = face
|
|
|
|
|
.Replace("(╯", "╯(").Replace("(ノ", "ノ(").Replace("(ノ", "ノ(").Replace("(/¯", @"\_/(")
|
|
|
|
|
.Replace(")╯", "╯)").Replace(")ノ", "ノ)").Replace(")ノ", "ノ)").Replace(")/¯", @"\_/)")
|
|
|
|
|
|
|
|
|
|
.Replace("(╯", "╯(").Replace("(ノ", "ノ(").Replace("(ノ", "ノ(").Replace("(/¯", @"\_/(")
|
|
|
|
|
.Replace(")╯", "╯)").Replace(")ノ", "ノ)").Replace(")ノ", "ノ)").Replace(")/¯", @"\_/)")
|
|
|
|
|
|
|
|
|
|
.Replace("ʕ╯", "╯ʕ").Replace("ʕノ", "ノʕ").Replace("ʕノ", "ノʕ").Replace("ʕ/¯", @"\_/ʕ")
|
|
|
|
|
.Replace("ʔ╯", "╯ʔ").Replace("ʔノ", "ノʔ").Replace("ʔノ", "ノʔ").Replace("ʔ/¯", @"\_/ʔ")
|
|
|
|
|
|
|
|
|
|
.TrimEnd('︵', '彡', ' ', ' ', '~', '~');
|
|
|
|
|
if (reverseFace == face)
|
|
|
|
|
return;
|
|
|
|
|
|
2019-04-28 14:06:27 +00:00
|
|
|
|
var faceLength = reverseFace.Length;
|
2019-11-05 22:45:31 +00:00
|
|
|
|
if (faceLength > 5 + 4)
|
|
|
|
|
reverseFace = $"{reverseFace[..2]}ಠ益ಠ{reverseFace[^2..]}";
|
2019-04-28 14:06:27 +00:00
|
|
|
|
await args.Channel.SendMessageAsync("┬─┬ " + reverseFace.Sanitize()).ConfigureAwait(false);
|
2018-11-12 23:37:13 +00:00
|
|
|
|
}
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
{
|
|
|
|
|
Config.Log.Warn(e);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|