Implement MessageReceived delegate

This commit is contained in:
Noikoio 2017-08-11 08:23:20 -07:00
parent 262f77d82d
commit f19ef5a662
2 changed files with 35 additions and 2 deletions

View file

@ -21,13 +21,27 @@ namespace Noikoio.RegexBot.Feature.AutoRespond
/// </list>
/// </para>
/// </summary>
class AutoRespond : BotFeature
partial class AutoRespond : BotFeature
{
public override string Name => "AutoRespond";
public AutoRespond(DiscordSocketClient client) : base(client)
{
throw new NotImplementedException();
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;
// TODO either search server by name or remove server name support entirely
var defs = GetConfig(ch.Guild.Id) as IEnumerable<ResponseDefinition>;
if (defs == null) return;
foreach (var def in defs)
await Task.Run(async () => await ProcessMessage(arg, def));
}
[ConfigSection("autoresponses")]

View file

@ -0,0 +1,19 @@
using Discord.WebSocket;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
namespace Noikoio.RegexBot.Feature.AutoRespond
{
partial class AutoRespond
{
private async Task ProcessMessage(SocketMessage msg, ResponseDefinition def)
{
// Filtering checks
// Rate limit checks
}
}
}