using System.Diagnostics;
namespace RegexBot.Modules.AutoResponder;
///
/// Provides the capability to define text responses to pattern-based triggers for fun or informational
/// purposes. Although in essence similar to , it is a better
/// fit for non-moderation use cases and has specific features suitable to that end.
///
[RegexbotModule]
public class AutoResponder : RegexbotModule {
public AutoResponder(RegexbotClient bot) : base(bot) {
DiscordClient.MessageReceived += DiscordClient_MessageReceived;
}
private async Task DiscordClient_MessageReceived(SocketMessage arg) {
if (arg.Channel is not SocketGuildChannel ch) return;
if (arg.Author.IsBot || arg.Author.IsWebhook) return;
var definitions = GetGuildState>(ch.Guild.Id);
if (definitions == null) return; // No configuration in this guild; do no further processing
var tasks = new List();
foreach (var def in definitions) {
tasks.Add(Task.Run(async () => await ProcessMessageAsync(arg, def)));
}
await Task.WhenAll(tasks);
}
public override Task