Fixed explicit TTS voices in messages when there is text before the first voice name.
This commit is contained in:
@ -84,6 +84,7 @@ namespace TwitchChatTTS.Chat.Messaging
|
|||||||
var msg = FilterMessage(fragments, reply);
|
var msg = FilterMessage(fragments, reply);
|
||||||
string voiceSelected = chatterId == null ? _user.DefaultTTSVoice : GetSelectedVoiceFor(chatterId.Value);
|
string voiceSelected = chatterId == null ? _user.DefaultTTSVoice : GetSelectedVoiceFor(chatterId.Value);
|
||||||
var messages = GetPartialTTSMessages(msg, voiceSelected).ToList();
|
var messages = GetPartialTTSMessages(msg, voiceSelected).ToList();
|
||||||
|
_logger.Debug("TTS messages separated as: " + string.Join(" || ", messages.Select(m => m.Message ?? "<" + m.File + ">")));
|
||||||
var groupedMessage = new TTSGroupedMessage(broadcasterId, chatterId, messageId, messages, DateTime.UtcNow, priority);
|
var groupedMessage = new TTSGroupedMessage(broadcasterId, chatterId, messageId, messages, DateTime.UtcNow, priority);
|
||||||
_player.Add(groupedMessage, groupedMessage.Priority);
|
_player.Add(groupedMessage, groupedMessage.Priority);
|
||||||
|
|
||||||
@ -223,7 +224,7 @@ namespace TwitchChatTTS.Chat.Messaging
|
|||||||
}];
|
}];
|
||||||
}
|
}
|
||||||
|
|
||||||
return matches.Cast<Match>().SelectMany(match =>
|
var messages = matches.Cast<Match>().SelectMany(match =>
|
||||||
{
|
{
|
||||||
var m = match.Groups["message"].Value;
|
var m = match.Groups["message"].Value;
|
||||||
if (string.IsNullOrWhiteSpace(m))
|
if (string.IsNullOrWhiteSpace(m))
|
||||||
@ -233,6 +234,13 @@ namespace TwitchChatTTS.Chat.Messaging
|
|||||||
voiceSelected = voiceSelected[0].ToString().ToUpper() + voiceSelected.Substring(1).ToLower();
|
voiceSelected = voiceSelected[0].ToString().ToUpper() + voiceSelected.Substring(1).ToLower();
|
||||||
return HandlePartialMessage(voiceSelected, m);
|
return HandlePartialMessage(voiceSelected, m);
|
||||||
});
|
});
|
||||||
|
string beforeMatch = message.Substring(0, matches.First().Index);
|
||||||
|
if (!string.IsNullOrEmpty(beforeMatch))
|
||||||
|
messages = HandlePartialMessage(defaultVoice, beforeMatch).Union(messages);
|
||||||
|
|
||||||
|
_logger.Debug("TTS message matches: " + string.Join(" || ", matches.Select(m => "(" + m.Length + " / " + m.Index + "): " + m.Value + " ")));
|
||||||
|
|
||||||
|
return messages;
|
||||||
}
|
}
|
||||||
|
|
||||||
private string GetSelectedVoiceFor(long chatterId)
|
private string GetSelectedVoiceFor(long chatterId)
|
||||||
|
@ -70,6 +70,7 @@ namespace TwitchChatTTS.Twitch.Socket.Handlers
|
|||||||
}
|
}
|
||||||
|
|
||||||
string permission = GetPermissionPath(message.ChannelPointsCustomRewardId, bits);
|
string permission = GetPermissionPath(message.ChannelPointsCustomRewardId, bits);
|
||||||
|
_logger.Information(chatterId + " / " + permission + " / groups: " + string.Join(" | ", groups));
|
||||||
if (!HasPermission(chatterId, groups, permission))
|
if (!HasPermission(chatterId, groups, permission))
|
||||||
{
|
{
|
||||||
_logger.Debug($"Blocked message [chatter: {chatterLogin}][message: {message}]");
|
_logger.Debug($"Blocked message [chatter: {chatterLogin}][message: {message}]");
|
||||||
@ -136,7 +137,7 @@ namespace TwitchChatTTS.Twitch.Socket.Handlers
|
|||||||
|
|
||||||
private bool HasPermission(long chatterId, IEnumerable<string> groups, string permissionPath)
|
private bool HasPermission(long chatterId, IEnumerable<string> groups, string permissionPath)
|
||||||
{
|
{
|
||||||
return chatterId == _user.OwnerId ? true : _permissionManager.CheckIfAllowed(groups, permissionPath) == true;
|
return chatterId == _user.OwnerId || _permissionManager.CheckIfAllowed(groups, permissionPath) == true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Reference in New Issue
Block a user