2024-06-16 20:19:31 -04:00
|
|
|
using System.Text.Json.Serialization;
|
2024-03-15 08:27:35 -04:00
|
|
|
using System.Text.RegularExpressions;
|
2024-06-16 20:19:31 -04:00
|
|
|
using HermesSocketLibrary.Requests.Messages;
|
2024-08-11 17:22:37 -04:00
|
|
|
using HermesSocketLibrary.Socket.Data;
|
2024-08-07 19:21:56 -04:00
|
|
|
using TwitchChatTTS.Twitch.Socket.Handlers;
|
2024-03-15 08:27:35 -04:00
|
|
|
|
|
|
|
namespace TwitchChatTTS
|
|
|
|
{
|
|
|
|
public class User
|
|
|
|
{
|
|
|
|
// Hermes user id
|
|
|
|
public string HermesUserId { get; set; }
|
2024-06-16 20:19:31 -04:00
|
|
|
public string HermesUsername { get; set; }
|
2024-03-15 08:27:35 -04:00
|
|
|
public long TwitchUserId { get; set; }
|
|
|
|
public string TwitchUsername { get; set; }
|
2024-06-16 20:19:31 -04:00
|
|
|
public string SevenEmoteSetId { get; set; }
|
2024-07-06 23:42:33 -04:00
|
|
|
public long? OwnerId { get; set; }
|
2024-06-16 20:19:31 -04:00
|
|
|
|
2024-08-11 17:22:37 -04:00
|
|
|
public Connection? TwitchConnection { get; set; }
|
|
|
|
public Connection? NightbotConnection { get; set; }
|
|
|
|
|
2024-03-15 08:27:35 -04:00
|
|
|
public string DefaultTTSVoice { get; set; }
|
|
|
|
// voice id -> voice name
|
2024-08-04 19:46:10 -04:00
|
|
|
public IDictionary<string, string> VoicesAvailable { get => _voicesAvailable; set { _voicesAvailable = value; VoiceNameRegex = GenerateEnabledVoicesRegex(); } }
|
2024-07-06 23:42:33 -04:00
|
|
|
// chatter/twitch id -> voice id
|
2024-03-15 08:27:35 -04:00
|
|
|
public IDictionary<long, string> VoicesSelected { get; set; }
|
2024-06-16 20:19:31 -04:00
|
|
|
// voice names
|
2024-08-04 19:46:10 -04:00
|
|
|
public HashSet<string> VoicesEnabled { get => _voicesEnabled; set { _voicesEnabled = value; VoiceNameRegex = GenerateEnabledVoicesRegex(); } }
|
2024-03-15 08:27:35 -04:00
|
|
|
|
2024-08-07 19:21:56 -04:00
|
|
|
public IDictionary<string, RaidInfo> Raids { get; set; } = new Dictionary<string, RaidInfo>();
|
2024-08-04 19:46:10 -04:00
|
|
|
public HashSet<long> Chatters { get; set; }
|
|
|
|
public TTSWordFilter[] RegexFilters { get; set; }
|
2024-06-16 20:19:31 -04:00
|
|
|
[JsonIgnore]
|
2024-08-04 19:46:10 -04:00
|
|
|
public Regex? VoiceNameRegex { get; set; }
|
2024-06-16 20:19:31 -04:00
|
|
|
|
|
|
|
private IDictionary<string, string> _voicesAvailable;
|
|
|
|
private HashSet<string> _voicesEnabled;
|
2024-03-15 08:27:35 -04:00
|
|
|
|
|
|
|
|
2024-06-16 20:19:31 -04:00
|
|
|
private Regex? GenerateEnabledVoicesRegex()
|
|
|
|
{
|
2024-03-15 08:27:35 -04:00
|
|
|
if (VoicesAvailable == null || VoicesAvailable.Count() <= 0)
|
|
|
|
return null;
|
|
|
|
|
2024-06-16 20:19:31 -04:00
|
|
|
var enabledVoicesString = string.Join("|", VoicesAvailable.Where(v => VoicesEnabled == null || !VoicesEnabled.Any() || VoicesEnabled.Contains(v.Value)).Select(v => v.Value));
|
2024-08-12 01:44:31 -04:00
|
|
|
return new Regex($@"(?:\A|\s)(?<voice>{enabledVoicesString}):(?<message>.*?)(?=\Z|\s(?:{enabledVoicesString})\:)", RegexOptions.IgnoreCase | RegexOptions.Compiled);
|
2024-03-15 08:27:35 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|