Add sarcastic responses when someone says thanks or thank you

This commit is contained in:
Deukhoofd 2018-08-12 13:43:14 +02:00
parent 2787fab689
commit 6097515b5b
No known key found for this signature in database
GPG Key ID: B4C087AC81641654
2 changed files with 21 additions and 0 deletions

View File

@ -1,4 +1,6 @@
using System;
using System.Linq; using System.Linq;
using System.Text.RegularExpressions;
using System.Threading.Tasks; using System.Threading.Tasks;
using DeukBot4.APIHandlers; using DeukBot4.APIHandlers;
using DeukBot4.Utilities; using DeukBot4.Utilities;
@ -67,5 +69,23 @@ namespace DeukBot4.MessageHandlers
} }
private static readonly Regex ThanksMatcher = new Regex(@"(?i)((\b)thanks*(\W|$)+)");
private static readonly string[] ThanksResponses = {
"You're welcome!", "No problem",
"It was the least I could do, I always do the least I can do!",
"Yes, well, we'd be absolutely nowhere without me.",
"Yeah no problem, I'm the only one who does work around here anyway",
};
private static readonly Random Rand = new Random();
public static async Task ThanksHandler(SocketMessage message)
{
var content = message.Content;
if (ThanksMatcher.IsMatch(content))
{
var response = ThanksResponses[Rand.Next(0, ThanksResponses.Length)];
message.Channel.SendMessageAsync(response);
}
}
} }
} }

View File

@ -25,6 +25,7 @@ namespace DeukBot4.MessageHandlers
ImageBackupHandler.Backup(message); ImageBackupHandler.Backup(message);
JokeHandlers.DeltaHandler(message); JokeHandlers.DeltaHandler(message);
JokeHandlers.DadJokeHandler(message); JokeHandlers.DadJokeHandler(message);
JokeHandlers.ThanksHandler(message);
#pragma warning restore 4014 #pragma warning restore 4014
} }
catch (Exception e) catch (Exception e)