2024-08-04 19:46:10 -04:00
|
|
|
using Serilog;
|
2024-08-12 01:44:31 -04:00
|
|
|
using TwitchChatTTS.Chat.Messaging;
|
2024-08-04 19:46:10 -04:00
|
|
|
using TwitchChatTTS.Twitch.Socket.Messages;
|
|
|
|
|
|
|
|
namespace TwitchChatTTS.Twitch.Socket.Handlers
|
|
|
|
{
|
|
|
|
public class ChannelChatMessageHandler : ITwitchSocketHandler
|
|
|
|
{
|
|
|
|
public string Name => "channel.chat.message";
|
|
|
|
|
2024-08-12 01:44:31 -04:00
|
|
|
private readonly ChatMessageReader _reader;
|
2024-08-04 19:46:10 -04:00
|
|
|
private readonly Configuration _configuration;
|
|
|
|
private readonly ILogger _logger;
|
|
|
|
|
|
|
|
|
|
|
|
public ChannelChatMessageHandler(
|
2024-08-12 01:44:31 -04:00
|
|
|
ChatMessageReader reader,
|
2024-08-04 19:46:10 -04:00
|
|
|
Configuration configuration,
|
|
|
|
ILogger logger
|
|
|
|
)
|
|
|
|
{
|
2024-08-12 01:44:31 -04:00
|
|
|
_reader = reader;
|
2024-08-04 19:46:10 -04:00
|
|
|
_configuration = configuration;
|
|
|
|
_logger = logger;
|
|
|
|
}
|
|
|
|
|
2024-08-12 01:44:31 -04:00
|
|
|
|
2024-08-06 15:29:29 -04:00
|
|
|
public async Task Execute(TwitchWebsocketClient sender, object data)
|
2024-08-04 19:46:10 -04:00
|
|
|
{
|
|
|
|
if (sender == null)
|
|
|
|
return;
|
|
|
|
if (data is not ChannelChatMessage message)
|
|
|
|
return;
|
|
|
|
|
2024-08-12 01:44:31 -04:00
|
|
|
await _reader.Execute(sender, message);
|
2024-08-04 19:46:10 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|