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:
@ -53,19 +53,24 @@ namespace TwitchChatTTS.Hermes.Socket.Handlers
|
||||
_user.VoicesEnabled = new HashSet<string>(message.EnabledTTSVoices);
|
||||
_user.TwitchConnection = message.Connections.FirstOrDefault(c => c.Default && c.Type == "twitch");
|
||||
_user.NightbotConnection = message.Connections.FirstOrDefault(c => c.Default && c.Type == "nightbot");
|
||||
|
||||
_bus.Send(this, "twitch id", _user.TwitchUserId);
|
||||
if (_user.TwitchConnection != null)
|
||||
{
|
||||
_logger.Information("Twitch connection: " + _user.TwitchConnection.Name + " / " + _user.TwitchConnection.AccessToken);
|
||||
}
|
||||
|
||||
var filters = message.WordFilters.Where(f => f.Search != null && f.Replace != null).ToList();
|
||||
foreach (var filter in filters)
|
||||
{
|
||||
try
|
||||
{
|
||||
var re = new Regex(filter.Search, ((RegexOptions) filter.Flag) | RegexOptions.Compiled);
|
||||
var re = new Regex(filter.Search, ((RegexOptions)filter.Flag) | RegexOptions.Compiled);
|
||||
re.Match(string.Empty);
|
||||
filter.Regex = re;
|
||||
}
|
||||
catch (Exception) { }
|
||||
catch (Exception)
|
||||
{
|
||||
_logger.Warning($"Failed to create a regular expression for a TTS filter [filter id: {filter.Search}]");
|
||||
}
|
||||
}
|
||||
_user.RegexFilters = filters;
|
||||
|
||||
@ -93,6 +98,7 @@ namespace TwitchChatTTS.Hermes.Socket.Handlers
|
||||
}
|
||||
|
||||
_logger.Information("TTS is now ready.");
|
||||
_bus.Send(this, "tts_connected", _user);
|
||||
client.Ready = true;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user