Fixed raid spam prevention. Gave a proper error message when connecting to Twitch websockets without linking Twitch account to Twitch.

This commit is contained in:
Tom
2024-08-07 22:01:04 +00:00
parent e4a11382ef
commit 6eb927ce5f
10 changed files with 162 additions and 84 deletions

View File

@@ -25,7 +25,8 @@ namespace TwitchChatTTS.Twitch.Socket.Handlers
if (data is not ChannelRaidMessage message)
return;
var chatters = await _api.GetChatters(message.ToBroadcasterUserId, message.ToBroadcasterUserLogin);
_logger.Information($"A raid has started. Starting raid spam prevention. [from: {message.FromBroadcasterUserLogin}][from id: {message.FromBroadcasterUserId}].");
var chatters = await _api.GetChatters(_user.TwitchUserId.ToString(), _user.TwitchUserId.ToString());
if (chatters?.Data == null)
{
_logger.Error("Could not fetch the list of chatters in chat.");
@@ -43,6 +44,11 @@ namespace TwitchChatTTS.Twitch.Socket.Handlers
}
}
Task.Run(async () => await EndOfRaidSpamProtection(date));
}
private async Task EndOfRaidSpamProtection(DateTime date)
{
await Task.Delay(TimeSpan.FromSeconds(30));
lock (_lock)