using Discord.WebSocket;
using Newtonsoft.Json.Linq;
using System.Collections.Generic;
using System.Diagnostics;
using System.Threading.Tasks;
namespace Noikoio.RegexBot.Module.AutoRespond
{
///
/// Similar to , but lightweight.
/// Provides the capability to define autoresponses for fun or informational purposes.
///
/// The major differences between this and include:
///
/// Does not listen for message edits.
/// Moderators are not exempt from any defined triggers.
/// Responses are limited to the invoking channel.
/// Per-channel rate limiting.
///
///
///
partial class AutoRespond : BotModule
{
#region BotModule implementation
public override string Name => "AutoRespond";
public AutoRespond(DiscordSocketClient client) : base(client)
{
client.MessageReceived += Client_MessageReceived;
}
private async Task Client_MessageReceived(SocketMessage arg)
{
// Determine channel type - if not a guild channel, stop.
var ch = arg.Channel as SocketGuildChannel;
if (ch == null) return;
var defs = GetConfig(ch.Guild.Id) as IEnumerable;
if (defs == null) return;
foreach (var def in defs)
await Task.Run(async () => await ProcessMessage(arg, def));
}
[ConfigSection("autoresponses")]
public override async Task