From c39047931abf883f028bb1d57e1984d6e114d73a Mon Sep 17 00:00:00 2001 From: SuperPenguinTV Date: Wed, 31 Jan 2024 14:15:19 -0700 Subject: [PATCH 1/3] Add websocket chat message types --- .../Models/Chat/ChatCheer.cs | 7 ++ .../Models/Chat/ChatReply.cs | 15 ++++ .../Channel/ChannelChatMessage.cs | 87 +++++++++++++++++++ 3 files changed, 109 insertions(+) create mode 100644 TwitchLib.EventSub.Core/Models/Chat/ChatCheer.cs create mode 100644 TwitchLib.EventSub.Core/Models/Chat/ChatReply.cs create mode 100644 TwitchLib.EventSub.Core/SubscriptionTypes/Channel/ChannelChatMessage.cs diff --git a/TwitchLib.EventSub.Core/Models/Chat/ChatCheer.cs b/TwitchLib.EventSub.Core/Models/Chat/ChatCheer.cs new file mode 100644 index 0000000..6d09190 --- /dev/null +++ b/TwitchLib.EventSub.Core/Models/Chat/ChatCheer.cs @@ -0,0 +1,7 @@ +namespace TwitchLib.EventSub.Core.Models.Chat +{ + public sealed class ChatCheer + { + public int Bits { get; set; } + } +} diff --git a/TwitchLib.EventSub.Core/Models/Chat/ChatReply.cs b/TwitchLib.EventSub.Core/Models/Chat/ChatReply.cs new file mode 100644 index 0000000..6d9118f --- /dev/null +++ b/TwitchLib.EventSub.Core/Models/Chat/ChatReply.cs @@ -0,0 +1,15 @@ +namespace TwitchLib.EventSub.Core.Models.Chat +{ + public sealed class ChatReply + { + public string ParentMessageId { get; set; } = string.Empty; + public string ParentMessageBody { get; set; } = string.Empty; + public string ParentUserId { get; set; } = string.Empty; + public string ParentUserName { get; set; } = string.Empty; + public string ParentUserLogin { get; set; } = string.Empty; + public string ThreadMessageId { get; set; } = string.Empty; + public string ThreadUserId { get; set; } = string.Empty; + public string ThreadUserName { get; set; } = string.Empty; + public string ThreadUserLogin { get; set; } = string.Empty; + } +} diff --git a/TwitchLib.EventSub.Core/SubscriptionTypes/Channel/ChannelChatMessage.cs b/TwitchLib.EventSub.Core/SubscriptionTypes/Channel/ChannelChatMessage.cs new file mode 100644 index 0000000..feec806 --- /dev/null +++ b/TwitchLib.EventSub.Core/SubscriptionTypes/Channel/ChannelChatMessage.cs @@ -0,0 +1,87 @@ +using System; +using System.Linq; +using TwitchLib.EventSub.Core.Models.Chat; + +namespace TwitchLib.EventSub.Core.SubscriptionTypes.Channel +{ + public sealed class ChannelChatMessage + { + /// + /// The broadcaster user ID. + /// + public string BroadcasterUserId { get; set; } = string.Empty; + /// + /// The broadcaster display name. + /// + public string BroadcasterUserName { get; set; } = string.Empty; + /// + /// The broadcaster login. + /// + public string BroadcasterUserLogin { get; set; } = string.Empty; + /// + /// The user ID of the user that sent the message. + /// + public string ChatterUserId { get; set; } = string.Empty; + /// + /// The user name of the user that sent the message. + /// + public string ChatterUserName { get; set; } = string.Empty; + /// + /// The user login of the user that sent the message. + /// + public string ChatterUserLogin { get; set; } = string.Empty; + /// + /// A UUID that identifies the message. + /// + public string MessageId { get; set; } = string.Empty; + /// + /// The structured chat message + /// + public ChatMessage Message { get; set; } = new(); + /// + /// The color of the user’s name in the chat room. + /// + public string Color { get; set; } = string.Empty; + /// + /// Array of chat badges. + /// + public ChatBadge[] Badges { get; set; } = []; + + /// The type of message. Possible values: + /// text + /// channel_points_highlighted + /// channel_points_sub_only + /// user_intro + public string MessageType { get; set; } = string.Empty; + + /// + /// Metadata if this message is a cheer. + /// + public ChatCheer? Cheer { get; set; } + + /// Metadata if this message is a reply. + public ChatReply? Reply { get; set; } + + /// + /// Optional. The ID of a channel points custom reward that was redeemed. + /// + public string ChannelPointsCustomRewardId { get; set; } = string.Empty; + + /// + /// Returns true if viewer is a subscriber + /// + public bool IsSubscriber => Badges.Where(x => x.SetId.Equals("subscriber", StringComparison.OrdinalIgnoreCase)).Any(); + /// + /// Returns true if viewer is a moderator + /// + public bool IsModerator => Badges.Where(x => x.SetId.Equals("moderator", StringComparison.OrdinalIgnoreCase)).Any(); + /// + /// Returns true if viewer is a broadcaster + /// + public bool IsBroadcaster => Badges.Where(x => x.SetId.Equals("broadcaster", StringComparison.OrdinalIgnoreCase)).Any(); + /// + /// Returns true if viewer is a vip + /// + public bool IsVip => Badges.Where(x => x.SetId.Equals("vip", StringComparison.OrdinalIgnoreCase)).Any(); + } +} From e582544a7b20aca100abe9ebe7de7c746740a40e Mon Sep 17 00:00:00 2001 From: SuperPenguinTV Date: Thu, 11 Apr 2024 11:26:19 -0700 Subject: [PATCH 2/3] Removed Where().Any() to just .Any() --- .../SubscriptionTypes/Channel/ChannelChatMessage.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/TwitchLib.EventSub.Core/SubscriptionTypes/Channel/ChannelChatMessage.cs b/TwitchLib.EventSub.Core/SubscriptionTypes/Channel/ChannelChatMessage.cs index feec806..f4cbb95 100644 --- a/TwitchLib.EventSub.Core/SubscriptionTypes/Channel/ChannelChatMessage.cs +++ b/TwitchLib.EventSub.Core/SubscriptionTypes/Channel/ChannelChatMessage.cs @@ -70,18 +70,18 @@ public sealed class ChannelChatMessage /// /// Returns true if viewer is a subscriber /// - public bool IsSubscriber => Badges.Where(x => x.SetId.Equals("subscriber", StringComparison.OrdinalIgnoreCase)).Any(); + public bool IsSubscriber => Badges.Any(x => x.SetId.Equals("subscriber", StringComparison.OrdinalIgnoreCase)); /// /// Returns true if viewer is a moderator /// - public bool IsModerator => Badges.Where(x => x.SetId.Equals("moderator", StringComparison.OrdinalIgnoreCase)).Any(); + public bool IsModerator => Badges.Any(x => x.SetId.Equals("moderator", StringComparison.OrdinalIgnoreCase)); /// /// Returns true if viewer is a broadcaster /// - public bool IsBroadcaster => Badges.Where(x => x.SetId.Equals("broadcaster", StringComparison.OrdinalIgnoreCase)).Any(); + public bool IsBroadcaster => Badges.Any(x => x.SetId.Equals("broadcaster", StringComparison.OrdinalIgnoreCase)); /// /// Returns true if viewer is a vip /// - public bool IsVip => Badges.Where(x => x.SetId.Equals("vip", StringComparison.OrdinalIgnoreCase)).Any(); + public bool IsVip => Badges.Any(x => x.SetId.Equals("vip", StringComparison.OrdinalIgnoreCase)); } } From 7658429ea6540008c24af45c791eb01e6ce44be8 Mon Sep 17 00:00:00 2001 From: Syzuna Date: Thu, 11 Apr 2024 22:01:04 +0200 Subject: [PATCH 3/3] Bump Version --- TwitchLib.EventSub.Core/TwitchLib.EventSub.Core.csproj | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/TwitchLib.EventSub.Core/TwitchLib.EventSub.Core.csproj b/TwitchLib.EventSub.Core/TwitchLib.EventSub.Core.csproj index 1b4e8ed..ec0e145 100644 --- a/TwitchLib.EventSub.Core/TwitchLib.EventSub.Core.csproj +++ b/TwitchLib.EventSub.Core/TwitchLib.EventSub.Core.csproj @@ -5,10 +5,10 @@ TwitchLib.EventSub.Core TwitchLib.EventSub.Core swiftyspiffy, Prom3theu5, Syzuna, LuckyNoS7evin - 2.5.1 + 2.5.2 $(VersionSuffix) - 2.5.1 - 2.5.1 + 2.5.2 + 2.5.2 Contains Subscription Types and Models for Twitch's EventSub system https://cdn.syzuna-programs.de/images/twitchlib.png https://github.com/TwitchLib/TwitchLib.EventSub.Websockets