Twitch connection now relies on events to connect. Added logging for when TTS filter is not a regex. Minor code clean up.
This commit is contained in:
@ -29,18 +29,9 @@ namespace TwitchChatTTS.Twitch.Socket.Handlers
|
||||
return;
|
||||
}
|
||||
|
||||
int waited = 0;
|
||||
while ((_user.TwitchUserId <= 0 || _user.TwitchConnection == null) && ++waited < 5)
|
||||
await Task.Delay(TimeSpan.FromSeconds(1));
|
||||
|
||||
if (_user.TwitchConnection == null)
|
||||
{
|
||||
_logger.Error("Ensure you have linked either your Twitch account or TTS' bot to your TTS account. Twitch client will not be connecting.");
|
||||
return;
|
||||
}
|
||||
|
||||
_api.Initialize(_user.TwitchConnection.ClientId, _user.TwitchConnection.AccessToken);
|
||||
var span = _user.TwitchConnection.ExpiresAt - DateTime.Now;
|
||||
var twitchConnection = _user.TwitchConnection!;
|
||||
_api.Initialize(twitchConnection.ClientId, twitchConnection.AccessToken);
|
||||
var span = twitchConnection.ExpiresAt - DateTime.Now;
|
||||
var timeLeft = span.Days >= 2 ? span.Days + " days" : (span.Hours >= 2 ? span.Hours + " hours" : span.Minutes + " minutes");
|
||||
if (span.Days >= 3)
|
||||
_logger.Information($"Twitch connection has {timeLeft} before it is revoked.");
|
||||
@ -48,7 +39,7 @@ namespace TwitchChatTTS.Twitch.Socket.Handlers
|
||||
_logger.Warning($"Twitch connection has {timeLeft} before it is revoked. Refreshing the token is soon required.");
|
||||
else
|
||||
{
|
||||
_logger.Error("Twitch connection has its permissions revoked. Refresh the token. Twith client will not be connecting.");
|
||||
_logger.Error("Twitch connection has its permissions revoked. Refresh the token. Twitch client will not be connecting.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user