Fixed command permissions. Moved to using Twitch's EventSub via websockets. Cleaned some code up. Added detection for subscription messages (no TTS), message deletion, full or partial chat clear. Removes messages from TTS queue if applicable. Added command aliases for static parameters. Word filters use compiled regex if possible. Fixed TTS voice deletion.
This commit is contained in:
19
Twitch/Socket/Messages/ChannelBanMessage.cs
Normal file
19
Twitch/Socket/Messages/ChannelBanMessage.cs
Normal file
@ -0,0 +1,19 @@
|
||||
namespace TwitchChatTTS.Twitch.Socket.Messages
|
||||
{
|
||||
public class ChannelBanMessage
|
||||
{
|
||||
public string UserId { get; set; }
|
||||
public string UserLogin { get; set; }
|
||||
public string UserName { get; set; }
|
||||
public string BroadcasterUserId { get; set; }
|
||||
public string BroadcasterUserLogin { get; set; }
|
||||
public string BroadcasterUserName { get; set; }
|
||||
public string ModeratorUserId { get; set; }
|
||||
public string ModeratorUserLogin { get; set; }
|
||||
public string ModeratorUserName { get; set; }
|
||||
public string Reason { get; set; }
|
||||
public DateTime BannedAt { get; set; }
|
||||
public DateTime? EndsAt { get; set; }
|
||||
public bool IsPermanent { get; set; }
|
||||
}
|
||||
}
|
9
Twitch/Socket/Messages/ChannelChatClearMessage.cs
Normal file
9
Twitch/Socket/Messages/ChannelChatClearMessage.cs
Normal file
@ -0,0 +1,9 @@
|
||||
namespace TwitchChatTTS.Twitch.Socket.Messages
|
||||
{
|
||||
public class ChannelChatClearMessage
|
||||
{
|
||||
public string BroadcasterUserId { get; set; }
|
||||
public string BroadcasterUserLogin { get; set; }
|
||||
public string BroadcasterUserName { get; set; }
|
||||
}
|
||||
}
|
9
Twitch/Socket/Messages/ChannelChatClearUserMessage.cs
Normal file
9
Twitch/Socket/Messages/ChannelChatClearUserMessage.cs
Normal file
@ -0,0 +1,9 @@
|
||||
namespace TwitchChatTTS.Twitch.Socket.Messages
|
||||
{
|
||||
public class ChannelChatClearUserMessage : ChannelChatClearMessage
|
||||
{
|
||||
public string TargetUserId { get; set; }
|
||||
public string TargetUserLogin { get; set; }
|
||||
public string TargetUserName { get; set; }
|
||||
}
|
||||
}
|
7
Twitch/Socket/Messages/ChannelChatDeleteMessage.cs
Normal file
7
Twitch/Socket/Messages/ChannelChatDeleteMessage.cs
Normal file
@ -0,0 +1,7 @@
|
||||
namespace TwitchChatTTS.Twitch.Socket.Messages
|
||||
{
|
||||
public class ChannelChatDeleteMessage : ChannelChatClearUserMessage
|
||||
{
|
||||
public string MessageId { get; set; }
|
||||
}
|
||||
}
|
75
Twitch/Socket/Messages/ChannelChatMessage.cs
Normal file
75
Twitch/Socket/Messages/ChannelChatMessage.cs
Normal file
@ -0,0 +1,75 @@
|
||||
namespace TwitchChatTTS.Twitch.Socket.Messages
|
||||
{
|
||||
public class ChannelChatMessage
|
||||
{
|
||||
public string BroadcasterUserId { get; set; }
|
||||
public string BroadcasterUserLogin { get; set; }
|
||||
public string BroadcasterUserName { get; set; }
|
||||
public string ChatterUserId { get; set; }
|
||||
public string ChatterUserLogin { get; set; }
|
||||
public string ChatterUserName { get; set; }
|
||||
public string MessageId { get; set; }
|
||||
public TwitchChatMessageInfo Message { get; set; }
|
||||
public string MessageType { get; set; }
|
||||
public TwitchBadge[] Badges { get; set; }
|
||||
public TwitchReplyInfo? Reply { get; set; }
|
||||
public string? ChannelPointsCustomRewardId { get; set; }
|
||||
public string? ChannelPointsAnimationId { get; set; }
|
||||
}
|
||||
|
||||
public class TwitchChatMessageInfo
|
||||
{
|
||||
public string Text { get; set; }
|
||||
public TwitchChatFragment[] Fragments { get; set; }
|
||||
}
|
||||
|
||||
public class TwitchChatFragment
|
||||
{
|
||||
public string Type { get; set; }
|
||||
public string Text { get; set; }
|
||||
public TwitchCheerInfo? Cheermote { get; set; }
|
||||
public TwitchEmoteInfo? Emote { get; set; }
|
||||
public TwitchMentionInfo? Mention { get; set; }
|
||||
}
|
||||
|
||||
public class TwitchCheerInfo
|
||||
{
|
||||
public string Prefix { get; set; }
|
||||
public int Bits { get; set; }
|
||||
public int Tier { get; set; }
|
||||
}
|
||||
|
||||
public class TwitchEmoteInfo
|
||||
{
|
||||
public string Id { get; set; }
|
||||
public string EmoteSetId { get; set; }
|
||||
public string OwnerId { get; set; }
|
||||
public string[] Format { get; set; }
|
||||
}
|
||||
|
||||
public class TwitchMentionInfo
|
||||
{
|
||||
public string UserId { get; set; }
|
||||
public string UserName { get; set; }
|
||||
public string UserLogin { get; set; }
|
||||
}
|
||||
|
||||
public class TwitchBadge
|
||||
{
|
||||
public string SetId { get; set; }
|
||||
public string Id { get; set; }
|
||||
public string Info { get; set; }
|
||||
}
|
||||
|
||||
public class TwitchReplyInfo
|
||||
{
|
||||
public string ParentMessageId { get; set; }
|
||||
public string ParentMessageBody { get; set; }
|
||||
public string ParentUserId { get; set; }
|
||||
public string ParentUserName { get; set; }
|
||||
public string ParentUserLogin { get; set; }
|
||||
public string ThreadMessageId { get; set; }
|
||||
public string ThreadUserName { get; set; }
|
||||
public string ThreadUserLogin { get; set; }
|
||||
}
|
||||
}
|
24
Twitch/Socket/Messages/ChannelCustomRedemptionMessage.cs
Normal file
24
Twitch/Socket/Messages/ChannelCustomRedemptionMessage.cs
Normal file
@ -0,0 +1,24 @@
|
||||
namespace TwitchChatTTS.Twitch.Socket.Messages
|
||||
{
|
||||
public class ChannelCustomRedemptionMessage
|
||||
{
|
||||
public string BroadcasterUserId { get; set; }
|
||||
public string BroadcasterUserLogin { get; set; }
|
||||
public string BroadcasterUserName { get; set; }
|
||||
public string Id { get; set; }
|
||||
public string UserId { get; set; }
|
||||
public string UserLogin { get; set; }
|
||||
public string UserName { get; set; }
|
||||
public string Status { get; set; }
|
||||
public DateTime RedeemedAt { get; set; }
|
||||
public RedemptionReward Reward { get; set; }
|
||||
}
|
||||
|
||||
public class RedemptionReward
|
||||
{
|
||||
public string Id { get; set; }
|
||||
public string Title { get; set; }
|
||||
public string Prompt { get; set; }
|
||||
public int Cost { get; set; }
|
||||
}
|
||||
}
|
17
Twitch/Socket/Messages/ChannelSubscriptionMessage.cs
Normal file
17
Twitch/Socket/Messages/ChannelSubscriptionMessage.cs
Normal file
@ -0,0 +1,17 @@
|
||||
namespace TwitchChatTTS.Twitch.Socket.Messages
|
||||
{
|
||||
public class ChannelSubscriptionMessage
|
||||
{
|
||||
public string BroadcasterUserId { get; set; }
|
||||
public string BroadcasterUserLogin { get; set; }
|
||||
public string BroadcasterUserName { get; set; }
|
||||
public string ChatterUserId { get; set; }
|
||||
public string ChatterUserLogin { get; set; }
|
||||
public string ChatterUserName { get; set; }
|
||||
public string Tier { get; set; }
|
||||
public TwitchChatMessageInfo Message { get; set; }
|
||||
public int CumulativeMonths { get; set; }
|
||||
public int StreakMonths { get; set; }
|
||||
public int DurationMonths { get; set; }
|
||||
}
|
||||
}
|
10
Twitch/Socket/Messages/EventResponse.cs
Normal file
10
Twitch/Socket/Messages/EventResponse.cs
Normal file
@ -0,0 +1,10 @@
|
||||
namespace TwitchChatTTS.Twitch.Socket.Messages
|
||||
{
|
||||
public class EventResponse<T>
|
||||
{
|
||||
public T[]? Data { get; set; }
|
||||
public int Total { get; set; }
|
||||
public int TotalCost { get; set; }
|
||||
public int MaxTotalCost { get; set; }
|
||||
}
|
||||
}
|
66
Twitch/Socket/Messages/EventSubscriptionMessage.cs
Normal file
66
Twitch/Socket/Messages/EventSubscriptionMessage.cs
Normal file
@ -0,0 +1,66 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace TwitchChatTTS.Twitch.Socket.Messages
|
||||
{
|
||||
public class EventSubscriptionMessage : IVersionedMessage
|
||||
{
|
||||
public string Type { get; set; }
|
||||
public string Version { get; set; }
|
||||
public IDictionary<string, string> Condition { get; set; }
|
||||
public EventSubTransport Transport { get; set; }
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public int? Cost { get; set; }
|
||||
|
||||
public EventSubscriptionMessage() {
|
||||
Type = string.Empty;
|
||||
Version = string.Empty;
|
||||
Condition = new Dictionary<string, string>();
|
||||
Transport = new EventSubTransport();
|
||||
}
|
||||
|
||||
public EventSubscriptionMessage(string type, string version, string callback, string secret, IDictionary<string, string>? conditions = null)
|
||||
{
|
||||
Type = type;
|
||||
Version = version;
|
||||
Condition = conditions ?? new Dictionary<string, string>();
|
||||
Transport = new EventSubTransport("webhook", callback, secret);
|
||||
}
|
||||
|
||||
public EventSubscriptionMessage(string type, string version, string sessionId, IDictionary<string, string>? conditions = null)
|
||||
{
|
||||
Type = type;
|
||||
Version = version;
|
||||
Condition = conditions ?? new Dictionary<string, string>();
|
||||
Transport = new EventSubTransport("websocket", sessionId);
|
||||
}
|
||||
|
||||
|
||||
public class EventSubTransport
|
||||
{
|
||||
public string Method { get; }
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public string? Callback { get; }
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public string? Secret { get; }
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public string? SessionId { get; }
|
||||
|
||||
public EventSubTransport() {
|
||||
Method = string.Empty;
|
||||
}
|
||||
|
||||
public EventSubTransport(string method, string callback, string secret)
|
||||
{
|
||||
Method = method;
|
||||
Callback = callback;
|
||||
Secret = secret;
|
||||
}
|
||||
|
||||
public EventSubTransport(string method, string sessionId)
|
||||
{
|
||||
Method = method;
|
||||
SessionId = sessionId;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
16
Twitch/Socket/Messages/NotificationMessage.cs
Normal file
16
Twitch/Socket/Messages/NotificationMessage.cs
Normal file
@ -0,0 +1,16 @@
|
||||
namespace TwitchChatTTS.Twitch.Socket.Messages
|
||||
{
|
||||
public class NotificationMessage
|
||||
{
|
||||
public NotificationInfo Subscription { get; set; }
|
||||
public object Event { get; set; }
|
||||
}
|
||||
|
||||
public class NotificationInfo : EventSubscriptionMessage
|
||||
{
|
||||
public string Id { get; set; }
|
||||
public string Status { get; set; }
|
||||
public DateTime CreatedAt { get; set; }
|
||||
public object Event { get; set; }
|
||||
}
|
||||
}
|
16
Twitch/Socket/Messages/SessionWelcomeMessage.cs
Normal file
16
Twitch/Socket/Messages/SessionWelcomeMessage.cs
Normal file
@ -0,0 +1,16 @@
|
||||
namespace TwitchChatTTS.Twitch.Socket.Messages
|
||||
{
|
||||
public class SessionWelcomeMessage
|
||||
{
|
||||
public TwitchSocketSession Session { get; set; }
|
||||
|
||||
public class TwitchSocketSession {
|
||||
public string Id { get; set; }
|
||||
public string Status { get; set; }
|
||||
public DateTime ConnectedAt { get; set; }
|
||||
public int KeepaliveTimeoutSeconds { get; set; }
|
||||
public string? ReconnectUrl { get; set; }
|
||||
public string? RecoveryUrl { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
18
Twitch/Socket/Messages/TwitchWebsocketMessage.cs
Normal file
18
Twitch/Socket/Messages/TwitchWebsocketMessage.cs
Normal file
@ -0,0 +1,18 @@
|
||||
namespace TwitchChatTTS.Twitch.Socket.Messages
|
||||
{
|
||||
public class TwitchWebsocketMessage
|
||||
{
|
||||
public TwitchMessageMetadata Metadata { get; set; }
|
||||
public object? Payload { get; set; }
|
||||
}
|
||||
|
||||
public class TwitchMessageMetadata {
|
||||
public string MessageId { get; set; }
|
||||
public string MessageType { get; set; }
|
||||
public DateTime MessageTimestamp { get; set; }
|
||||
}
|
||||
|
||||
public interface IVersionedMessage {
|
||||
string Version { get; set; }
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user