diff --git a/TwitchLib.Client.Models/Announcement.cs b/TwitchLib.Client.Models/Announcement.cs
index e339d416..e531ff04 100644
--- a/TwitchLib.Client.Models/Announcement.cs
+++ b/TwitchLib.Client.Models/Announcement.cs
@@ -1,169 +1,81 @@
-#nullable disable
-#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
-using TwitchLib.Client.Enums;
-using TwitchLib.Client.Models.Interfaces;
+using TwitchLib.Client.Enums;
using TwitchLib.Client.Models.Internal;
-namespace TwitchLib.Client.Models
-{
- /// Class representing Announcement in a Twitch channel.
- public class Announcement : IHexColorProperty
- {
- /// Property representing announcement message id
- public string Id { get; }
-
- /// Property representing list of badges assigned.
- public List> Badges { get; }
-
- /// Metadata associated with each badge
- public List> BadgeInfo { get; }
-
- /// Property representing internal system message value.
- public string SystemMessage { get; }
-
- /// Property representing internal system message value, parsed.
- public string SystemMessageParsed { get; }
-
- /// Property representing whether or not the announcer is the broadcaster.
- public bool IsBroadcaster { get; }
-
- /// Property representing whether or not the announcer is a moderator.
- public bool IsModerator { get; }
-
- /// Property representing whether or not announcer is a partner.
- public bool IsPartner { get; }
-
- /// Property representing whether or not the announcer is a subscriber.
- public bool IsSubscriber { get; }
-
- /// Property representing whether or not the announcer is a twitch staff member.
- public bool IsStaff { get; }
-
- /// Property representing whether or not the announcer is a turbo member.
- public bool IsTurbo { get; }
-
- /// Property representing the user's login.
- public string Login { get; }
+namespace TwitchLib.Client.Models;
- /// Property representing the user's id.
- public string UserId { get; }
-
- /// Property representing the room id.
- public string RoomId { get; }
-
- /// Property representing the user type of the announcer.
- public UserType UserType { get; }
-
- /// Property representing the tmi-sent-ts value.
- public DateTimeOffset TmiSent { get; }
-
- /// Property representing emote set of announcement.
- public string EmoteSet { get; }
-
- /// Property representing the raw IRC message (for debugging/customized parsing)
- public string RawIrc { get; }
-
- /// Property representing the msg-id value.
- public string MsgId { get; }
-
- /// Property representing the color value of the announcement.
- public string MsgParamColor { get; }
+/// Class representing Announcement in a Twitch channel.
+public class Announcement : UserNoticeBase
+{
+ /// Property representing the color value of the announcement.
+ public string MsgParamColor { get; protected set; } = default!;
- ///
- public string HexColor { get; }
+ /// Property representing the message of the announcement.
+ public string Message { get; protected set; }
- /// Property representing the message of the announcement.
- public string Message { get; }
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The IRC message from Twitch to be processed.
+ public Announcement(IrcMessage ircMessage) : base(ircMessage)
+ {
+ Message = ircMessage.Message;
+ }
- ///
- /// Contains undocumented tags.
- ///
- public Dictionary? UndocumentedTags { get; }
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ public Announcement(
+ List> badgeInfo,
+ List> badges,
+ string hexColor,
+ string displayMame,
+ string emotes,
+ string id,
+ string login,
+ bool isModerator,
+ string msgId,
+ string roomId,
+ bool isSubscriber,
+ string systemMsg,
+ DateTimeOffset tmiSent,
+ bool isTurbo,
+ string userId,
+ UserType userType,
+ Dictionary? undocumentedTags,
+ string msgParamColor,
+ string message)
+ : base(badgeInfo,
+ badges,
+ hexColor,
+ displayMame,
+ emotes,
+ id,
+ login,
+ isModerator,
+ msgId, roomId,
+ isSubscriber,
+ systemMsg,
+ tmiSent,
+ isTurbo,
+ userId,
+ userType,
+ undocumentedTags)
+ {
+ MsgParamColor = msgParamColor;
+ Message = message;
+ }
- /// SAMPLE: @badge-info=;badges=broadcaster/1,ambassador/1;color=#033700;display-name=BarryCarlyon;emotes=;flags=;id=55d90904-e515-47d0-ac1d-879f7f1d7b01;login=barrycarlyon;mod=0;msg-id=announcement;msg-param-color=PRIMARY;room-id=15185913;subscriber=0;system-msg=;tmi-sent-ts=1648758023469;user-id=15185913;user-type= :tmi.twitch.tv USERNOTICE #barrycarlyon :test announcment main
- /// Announcement object constructor.
- /// The IRC message from Twitch to be processed.
- public Announcement(IrcMessage ircMessage)
+ ///
+ protected override bool TrySet(KeyValuePair tag)
+ {
+ switch (tag.Key)
{
- RawIrc = ircMessage.ToString();
- Message = ircMessage.Message;
- foreach (var tag in ircMessage.Tags)
- {
- var tagValue = tag.Value;
- switch (tag.Key)
- {
- case Tags.Badges:
- Badges = TagHelper.ToBadges(tagValue);
- foreach (var badge in Badges)
- {
- switch (badge.Key)
- {
- case "broadcaster":
- IsBroadcaster = true;
- break;
- case "turbo":
- IsTurbo = true;
- break;
- case "moderator":
- IsModerator = true;
- break;
- case "subscriber":
- IsSubscriber = true;
- break;
- case "admin":
- IsStaff = true;
- break;
- case "staff":
- IsStaff = true;
- break;
- case "partner":
- IsPartner = true;
- break;
- }
- }
- break;
- case Tags.BadgeInfo:
- BadgeInfo = TagHelper.ToBadges(tagValue);
- break;
- case Tags.Color:
- HexColor = tagValue;
- break;
- case Tags.MsgParamColor:
- MsgParamColor = tagValue;
- break;
- case Tags.Emotes:
- EmoteSet = tagValue;
- break;
- case Tags.Id:
- Id = tagValue;
- break;
- case Tags.Login:
- Login = tagValue;
- break;
- case Tags.MsgId:
- MsgId = tagValue;
- break;
- case Tags.RoomId:
- RoomId = tagValue;
- break;
- case Tags.SystemMsg:
- SystemMessage = tagValue;
- SystemMessageParsed = tagValue.Replace("\\s", " ");
- break;
- case Tags.TmiSentTs:
- TmiSent = TagHelper.ToDateTimeOffsetFromUnixMs(tagValue);
- break;
- case Tags.UserId:
- UserId = tagValue;
- break;
- case Tags.UserType:
- UserType = TagHelper.ToUserType(tag.Value);
- break;
- default:
- (UndocumentedTags = new()).Add(tag.Key, tag.Value);
- break;
- }
- }
+ case Tags.MsgParamColor:
+ MsgParamColor = tag.Value;
+ break;
+ default:
+ return false;
}
+ return true;
}
-}
\ No newline at end of file
+}
diff --git a/TwitchLib.Client.Models/AnonGiftPaidUpgrade.cs b/TwitchLib.Client.Models/AnonGiftPaidUpgrade.cs
new file mode 100644
index 00000000..6a6c1c63
--- /dev/null
+++ b/TwitchLib.Client.Models/AnonGiftPaidUpgrade.cs
@@ -0,0 +1,85 @@
+using TwitchLib.Client.Enums;
+using TwitchLib.Client.Models.Internal;
+
+namespace TwitchLib.Client.Models;
+
+public class AnonGiftPaidUpgrade : UserNoticeBase
+{
+ ///
+ /// The number of gifts the gifter has given during the promo indicated by .
+ ///
+ public int MsgParamPromoGiftTotal { get; protected set; }
+
+ ///
+ /// The subscriptions promo, if any, that is ongoing (for example, Subtember 2018).
+ ///
+ public string MsgParamPromoName { get; protected set; } = default!;
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ public AnonGiftPaidUpgrade(IrcMessage ircMessage) : base(ircMessage)
+ {
+ }
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ public AnonGiftPaidUpgrade(
+ List> badgeInfo,
+ List> badges,
+ string hexColor,
+ string displayMame,
+ string emotes,
+ string id,
+ string login,
+ bool isModerator,
+ string msgId,
+ string roomId,
+ bool isSubscriber,
+ string systemMsg,
+ DateTimeOffset tmiSent,
+ bool isTurbo,
+ string userId,
+ UserType userType,
+ Dictionary? undocumentedTags,
+ int msgParamPromoGiftTotal,
+ string msgParamPromoName)
+ : base(badgeInfo,
+ badges,
+ hexColor,
+ displayMame,
+ emotes,
+ id,
+ login,
+ isModerator,
+ msgId, roomId,
+ isSubscriber,
+ systemMsg,
+ tmiSent,
+ isTurbo,
+ userId,
+ userType,
+ undocumentedTags)
+ {
+ MsgParamPromoGiftTotal = msgParamPromoGiftTotal;
+ MsgParamPromoName = msgParamPromoName;
+ }
+
+ ///
+ protected override bool TrySet(KeyValuePair tag)
+ {
+ switch (tag.Key)
+ {
+ case Tags.MsgParamPromoGiftTotal:
+ MsgParamPromoGiftTotal = int.Parse(tag.Value);
+ break;
+ case Tags.MsgParamPromoName:
+ MsgParamPromoName = tag.Value;
+ break;
+ default:
+ return false;
+ }
+ return true;
+ }
+}
\ No newline at end of file
diff --git a/TwitchLib.Client.Models/BitsBadgeTier.cs b/TwitchLib.Client.Models/BitsBadgeTier.cs
new file mode 100644
index 00000000..c926c509
--- /dev/null
+++ b/TwitchLib.Client.Models/BitsBadgeTier.cs
@@ -0,0 +1,73 @@
+using TwitchLib.Client.Enums;
+using TwitchLib.Client.Models.Internal;
+
+namespace TwitchLib.Client.Models;
+
+public class BitsBadgeTier : UserNoticeBase
+{
+ ///
+ /// The tier of the Bits badge the user just earned. For example, 100, 1000, or 10000.
+ ///
+ public int MsgParamThreshold { get; protected set; }
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ public BitsBadgeTier(IrcMessage ircMessage) : base(ircMessage)
+ {
+ }
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ public BitsBadgeTier(
+ List> badgeInfo,
+ List> badges,
+ string hexColor,
+ string displayMame,
+ string emotes,
+ string id,
+ string login,
+ bool isModerator,
+ string msgId,
+ string roomId,
+ bool isSubscriber,
+ string systemMsg,
+ DateTimeOffset tmiSent,
+ bool isTurbo,
+ string userId,
+ UserType userType,
+ Dictionary? undocumentedTags,
+ int msgParamThreshold)
+ : base(badgeInfo,
+ badges,
+ hexColor,
+ displayMame,
+ emotes,
+ id,
+ login,
+ isModerator,
+ msgId, roomId,
+ isSubscriber,
+ systemMsg,
+ tmiSent,
+ isTurbo,
+ userId,
+ userType,
+ undocumentedTags)
+ {
+ MsgParamThreshold = msgParamThreshold;
+ }
+
+ ///
+ protected override bool TrySet(KeyValuePair tag)
+ {
+ switch (tag.Key)
+ {
+ case Tags.MsgParamThreshold:
+ MsgParamThreshold = int.Parse(tag.Value);
+ break;
+ }
+ return true;
+ }
+}
\ No newline at end of file
diff --git a/TwitchLib.Client.Models/Builders/GiftedSubscriptionBuilder.cs b/TwitchLib.Client.Models/Builders/GiftedSubscriptionBuilder.cs
deleted file mode 100644
index 14f4a53a..00000000
--- a/TwitchLib.Client.Models/Builders/GiftedSubscriptionBuilder.cs
+++ /dev/null
@@ -1,222 +0,0 @@
-#nullable disable
-#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
-
-using TwitchLib.Client.Enums;
-
-namespace TwitchLib.Client.Models.Builders
-{
- public sealed class GiftedSubscriptionBuilder : IBuilder, IFromIrcMessageBuilder
- {
- private readonly List> _badges = new List>();
- private readonly List> _badgeInfo = new List>();
- private string _color;
- private string _displayName;
- private string _emotes;
- private string _id;
- private bool _isModerator;
- private bool _isSubscriber;
- private bool _isTurbo;
- private string _login;
- private string _msgId;
- private string _msgParamMonths;
- private string _msgParamRecipientDisplayName;
- private string _msgParamRecipientId;
- private string _msgParamRecipientUserName;
- private string _msgParamSubPlanName;
- private string _msgParamMultiMonthGiftDuration;
- private SubscriptionPlan _msgParamSubPlan;
- private string _roomId;
- private string _systemMsg;
- private string _systemMsgParsed;
- private DateTimeOffset _tmiSent;
- private string _userId;
- private UserType _userType;
-
- private GiftedSubscriptionBuilder()
- {
- }
-
- public GiftedSubscriptionBuilder WithBadges(params KeyValuePair[] badges)
- {
- _badges.AddRange(badges);
- return this;
- }
-
- public GiftedSubscriptionBuilder WithBadgeInfos(params KeyValuePair[] badgeInfos)
- {
- _badgeInfo.AddRange(badgeInfos);
- return this;
- }
-
- public GiftedSubscriptionBuilder WithColor(string color)
- {
- _color = color;
- return this;
- }
-
- public GiftedSubscriptionBuilder WithDisplayName(string displayName)
- {
- _displayName = displayName;
- return this;
- }
-
- public GiftedSubscriptionBuilder WithEmotes(string emotes)
- {
- _emotes = emotes;
- return this;
- }
-
- public GiftedSubscriptionBuilder WithId(string id)
- {
- _id = id;
- return this;
- }
-
- public GiftedSubscriptionBuilder WithIsModerator(bool isModerator)
- {
- _isModerator = isModerator;
- return this;
- }
-
- public GiftedSubscriptionBuilder WithIsSubscriber(bool isSubscriber)
- {
- _isSubscriber = isSubscriber;
- return this;
- }
-
- public GiftedSubscriptionBuilder WithIsTurbo(bool isTurbo)
- {
- _isTurbo = isTurbo;
- return this;
- }
-
- public GiftedSubscriptionBuilder WithLogin(string login)
- {
- _login = login;
- return this;
- }
-
- public GiftedSubscriptionBuilder WithMessageId(string msgId)
- {
- _msgId = msgId;
- return this;
- }
-
- public GiftedSubscriptionBuilder WithMsgParamCumulativeMonths(string msgParamMonths)
- {
- _msgParamMonths = msgParamMonths;
- return this;
- }
-
- public GiftedSubscriptionBuilder WithMsgParamRecipientDisplayName(string msgParamRecipientDisplayName)
- {
- _msgParamRecipientDisplayName = msgParamRecipientDisplayName;
- return this;
- }
-
- public GiftedSubscriptionBuilder WithMsgParamRecipientId(string msgParamRecipientId)
- {
- _msgParamRecipientId = msgParamRecipientId;
- return this;
- }
-
- public GiftedSubscriptionBuilder WithMsgParamRecipientUserName(string msgParamRecipientUserName)
- {
- _msgParamRecipientUserName = msgParamRecipientUserName;
- return this;
- }
-
- public GiftedSubscriptionBuilder WithMsgParamSubPlanName(string msgParamSubPlanName)
- {
- _msgParamSubPlanName = msgParamSubPlanName;
- return this;
- }
-
- public GiftedSubscriptionBuilder WithMsgParamMultiMonthGiftDuration(string msgParamMultiMonthGiftDuration)
- {
- _msgParamMultiMonthGiftDuration = msgParamMultiMonthGiftDuration;
- return this;
- }
-
- public GiftedSubscriptionBuilder WithMsgParamSubPlan(SubscriptionPlan msgParamSubPlan)
- {
- _msgParamSubPlan = msgParamSubPlan;
- return this;
- }
-
- public GiftedSubscriptionBuilder WithRoomId(string roomId)
- {
- _roomId = roomId;
- return this;
- }
-
- public GiftedSubscriptionBuilder WithSystemMsg(string systemMsg)
- {
- _systemMsg = systemMsg;
- return this;
- }
-
- public GiftedSubscriptionBuilder WithSystemMsgParsed(string systemMsgParsed)
- {
- _systemMsgParsed = systemMsgParsed;
- return this;
- }
-
- public GiftedSubscriptionBuilder WithTmiSent(DateTimeOffset tmiSent)
- {
- _tmiSent = tmiSent;
- return this;
- }
-
- public GiftedSubscriptionBuilder WithUserId(string userId)
- {
- _userId = userId;
- return this;
- }
-
- public GiftedSubscriptionBuilder WithUserType(UserType userType)
- {
- _userType = userType;
- return this;
- }
-
- public static GiftedSubscriptionBuilder Create()
- {
- return new GiftedSubscriptionBuilder();
- }
-
- public GiftedSubscription Build()
- {
- return new GiftedSubscription(
- _badges,
- _badgeInfo,
- _color,
- _displayName,
- _emotes,
- _id,
- _login,
- _isModerator,
- _msgId,
- _msgParamMonths,
- _msgParamRecipientDisplayName,
- _msgParamRecipientId,
- _msgParamRecipientUserName,
- _msgParamSubPlanName,
- _msgParamMultiMonthGiftDuration,
- _msgParamSubPlan,
- _roomId,
- _isSubscriber,
- _systemMsg,
- _systemMsgParsed,
- _tmiSent,
- _isTurbo,
- _userType,
- _userId);
- }
-
- public GiftedSubscription BuildFromIrcMessage(FromIrcMessageBuilderDataObject fromIrcMessageBuilderDataObject)
- {
- return new GiftedSubscription(fromIrcMessageBuilderDataObject.Message);
- }
- }
-}
\ No newline at end of file
diff --git a/TwitchLib.Client.Models/Builders/RaidNotificationBuilder.cs b/TwitchLib.Client.Models/Builders/RaidNotificationBuilder.cs
deleted file mode 100644
index cc8688cf..00000000
--- a/TwitchLib.Client.Models/Builders/RaidNotificationBuilder.cs
+++ /dev/null
@@ -1,185 +0,0 @@
-#nullable disable
-#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
-
-using TwitchLib.Client.Enums;
-
-namespace TwitchLib.Client.Models.Builders
-{
- public sealed class RaidNotificationBuilder : IBuilder, IFromIrcMessageBuilder
- {
- private readonly List> _badges = new List>();
- private readonly List> _badgeInfo = new List>();
- private string _color;
- private string _displayName;
- private string _emotes;
- private string _id;
- private bool _isModerator;
- private bool _isSubscriber;
- private bool _isTurbo;
- private string _login;
- private string _msgId;
- private string _msgParamDisplayName;
- private string _msgParamLogin;
- private string _msgParamViewerCount;
- private string _roomId;
- private string _systemMsg;
- private string _systemMsgParsed;
- private DateTimeOffset _tmiSent;
- private string _userId;
- private UserType _userType;
-
- public RaidNotificationBuilder WithBadges(params KeyValuePair[] badges)
- {
- _badges.AddRange(badges);
- return this;
- }
-
- public RaidNotificationBuilder WithBadgeInfos(params KeyValuePair[] badgeInfos)
- {
- _badgeInfo.AddRange(badgeInfos);
- return this;
- }
-
- public RaidNotificationBuilder WithColor(string color)
- {
- _color = color;
- return this;
- }
-
- public RaidNotificationBuilder WithDisplayName(string displayName)
- {
- _displayName = displayName;
- return this;
- }
-
- public RaidNotificationBuilder WithEmotes(string emotes)
- {
- _emotes = emotes;
- return this;
- }
-
- public RaidNotificationBuilder WithId(string id)
- {
- _id = id;
- return this;
- }
-
- public RaidNotificationBuilder WithIsModerator(bool isModerator)
- {
- _isModerator = isModerator;
- return this;
- }
-
- public RaidNotificationBuilder WithIsSubscriber(bool isSubscriber)
- {
- _isSubscriber = isSubscriber;
- return this;
- }
-
- public RaidNotificationBuilder WithIsTurbo(bool isTurbo)
- {
- _isTurbo = isTurbo;
- return this;
- }
-
- public RaidNotificationBuilder WithLogin(string login)
- {
- _login = login;
- return this;
- }
-
- public RaidNotificationBuilder WithMessageId(string msgId)
- {
- _msgId = msgId;
- return this;
- }
-
- public RaidNotificationBuilder WithMsgParamDisplayName(string msgParamDisplayName)
- {
- _msgParamDisplayName = msgParamDisplayName;
- return this;
- }
-
- public RaidNotificationBuilder WithMsgParamLogin(string msgParamLogin)
- {
- _msgParamLogin = msgParamLogin;
- return this;
- }
-
- public RaidNotificationBuilder WithMsgParamViewerCount(string msgParamViewerCount)
- {
- _msgParamViewerCount = msgParamViewerCount;
- return this;
- }
-
- public RaidNotificationBuilder WithRoomId(string roomId)
- {
- _roomId = roomId;
- return this;
- }
-
- public RaidNotificationBuilder WithSystemMsg(string systemMsg)
- {
- _systemMsg = systemMsg;
- return this;
- }
-
- public RaidNotificationBuilder WithSystemMsgParsed(string systemMsgParsed)
- {
- _systemMsgParsed = systemMsgParsed;
- return this;
- }
-
- public RaidNotificationBuilder WithTmiSent(DateTimeOffset tmiSent)
- {
- _tmiSent = tmiSent;
- return this;
- }
-
- public RaidNotificationBuilder WithUserId(string userId)
- {
- _userId = userId;
- return this;
- }
-
- public RaidNotificationBuilder WithUserType(UserType userType)
- {
- _userType = userType;
- return this;
- }
-
- private RaidNotificationBuilder()
- {
- }
-
- public RaidNotification Build()
- {
- return new RaidNotification(
- _badges,
- _badgeInfo,
- _color,
- _displayName,
- _emotes,
- _id,
- _login,
- _isModerator,
- _msgId,
- _msgParamDisplayName,
- _msgParamLogin,
- _msgParamViewerCount,
- _roomId,
- _isSubscriber,
- _systemMsg,
- _systemMsgParsed,
- _tmiSent,
- _isTurbo,
- _userType,
- _userId);
- }
-
- public RaidNotification BuildFromIrcMessage(FromIrcMessageBuilderDataObject fromIrcMessageBuilderDataObject)
- {
- return new RaidNotification(fromIrcMessageBuilderDataObject.Message);
- }
- }
-}
\ No newline at end of file
diff --git a/TwitchLib.Client.Models/Builders/ReSubscriberBuilder.cs b/TwitchLib.Client.Models/Builders/ReSubscriberBuilder.cs
deleted file mode 100644
index 1c864c49..00000000
--- a/TwitchLib.Client.Models/Builders/ReSubscriberBuilder.cs
+++ /dev/null
@@ -1,59 +0,0 @@
-#nullable disable
-#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
-
-namespace TwitchLib.Client.Models.Builders
-{
- public sealed class ReSubscriberBuilder : SubscriberBaseBuilder, IBuilder, IFromIrcMessageBuilder
- {
- private ReSubscriberBuilder()
- {
- }
-
- public static new ReSubscriberBuilder Create()
- {
- return new ReSubscriberBuilder();
- }
-
- public ReSubscriber BuildFromIrcMessage(FromIrcMessageBuilderDataObject fromIrcMessageBuilderDataObject)
- {
- return new ReSubscriber(fromIrcMessageBuilderDataObject.Message);
- }
-
- ReSubscriber IBuilder.Build()
- {
- return (ReSubscriber)Build();
- }
-
- public override SubscriberBase Build()
- {
- return new ReSubscriber(
- Badges,
- BadgeInfo,
- HexColor,
- DisplayName,
- EmoteSet,
- Id,
- Login,
- SystemMessage,
- MessageId,
- MsgParamCumulativeMonths,
- MsgParamStreakMonths,
- MsgParamShouldShareStreak,
- ParsedSystemMessage,
- ResubMessage,
- SubscriptionPlan,
- SubscriptionPlanName,
- RoomId,
- UserId,
- IsModerator,
- IsTurbo,
- IsSubscriber,
- IsPartner,
- TmiSent,
- UserType,
- RawIrc,
- Channel,
- Months);
- }
- }
-}
diff --git a/TwitchLib.Client.Models/Builders/RitualNewChatterBuilder.cs b/TwitchLib.Client.Models/Builders/RitualNewChatterBuilder.cs
deleted file mode 100644
index fc65d9b3..00000000
--- a/TwitchLib.Client.Models/Builders/RitualNewChatterBuilder.cs
+++ /dev/null
@@ -1,13 +0,0 @@
-#nullable disable
-#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
-
-namespace TwitchLib.Client.Models.Builders
-{
- public sealed class RitualNewChatterBuilder : IFromIrcMessageBuilder
- {
- public RitualNewChatter BuildFromIrcMessage(FromIrcMessageBuilderDataObject fromIrcMessageBuilderDataObject)
- {
- return new RitualNewChatter(fromIrcMessageBuilderDataObject.Message);
- }
- }
-}
\ No newline at end of file
diff --git a/TwitchLib.Client.Models/Builders/SubscriberBaseBuilder.cs b/TwitchLib.Client.Models/Builders/SubscriberBaseBuilder.cs
deleted file mode 100644
index bca3443d..00000000
--- a/TwitchLib.Client.Models/Builders/SubscriberBaseBuilder.cs
+++ /dev/null
@@ -1,267 +0,0 @@
-#nullable disable
-#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
-
-using TwitchLib.Client.Enums;
-
-namespace TwitchLib.Client.Models.Builders
-{
- public class SubscriberBaseBuilder : IBuilder
- {
- protected List> Badges { get; } = new List>();
-
- public List> BadgeInfo { get; } = new List>();
-
- protected string HexColor { get; set; }
-
- protected string DisplayName { get; set; }
-
- protected string EmoteSet { get; set; }
-
- protected string Id { get; set; }
-
- protected bool IsModerator { get; set; }
-
- protected bool IsPartner { get; set; }
-
- protected bool IsSubscriber { get; set; }
-
- protected bool IsTurbo { get; set; }
-
- protected string Login { get; set; }
-
- protected string RawIrc { get; set; }
-
- protected string ResubMessage { get; set; }
-
- protected string RoomId { get; set; }
-
- protected SubscriptionPlan SubscriptionPlan { get; set; }
-
- protected string SubscriptionPlanName { get; set; }
-
- protected string SystemMessage { get; set; }
-
- protected string ParsedSystemMessage { get; set; }
-
- protected DateTimeOffset TmiSent { get; set; }
-
- protected string UserId { get; set; }
-
- protected UserType UserType { get; set; }
-
- protected string Channel { get; set; }
-
- protected string MessageId { get; set; }
-
- protected string MsgParamCumulativeMonths { get; set; }
-
- protected string MsgParamStreakMonths { get; set; }
-
- protected bool MsgParamShouldShareStreak { get; set; }
-
- protected int Months { get; set; }
-
- protected SubscriberBaseBuilder()
- {
- }
-
- public static SubscriberBaseBuilder Create()
- {
- return new SubscriberBaseBuilder();
- }
-
- public SubscriberBaseBuilder WithBadges(params KeyValuePair[] badges)
- {
- Badges.AddRange(badges);
- return this;
- }
-
- public SubscriberBaseBuilder WithBadgeInfos(params KeyValuePair[] badgeInfos)
- {
- BadgeInfo.AddRange(badgeInfos);
- return this;
- }
-
- public SubscriberBaseBuilder WithColor(string color)
- {
- HexColor = color;
- return this;
- }
-
- public SubscriberBaseBuilder WithDisplayName(string displayName)
- {
- DisplayName = displayName;
- return this;
- }
-
- public SubscriberBaseBuilder WithEmoteSet(string emoteSet)
- {
- EmoteSet = emoteSet;
- return this;
- }
-
- public SubscriberBaseBuilder WithId(string id)
- {
- Id = id;
- return this;
- }
-
- public SubscriberBaseBuilder WithIsModerator(bool isModerator)
- {
- IsModerator = isModerator;
- return this;
- }
-
- public SubscriberBaseBuilder WithIsPartner(bool isPartner)
- {
- IsPartner = isPartner;
- return this;
- }
-
- public SubscriberBaseBuilder WithIsSubscriber(bool isSubscriber)
- {
- IsSubscriber = isSubscriber;
- return this;
- }
-
- public SubscriberBaseBuilder WithIsTurbo(bool isTurbo)
- {
- IsTurbo = isTurbo;
- return this;
- }
-
- public SubscriberBaseBuilder WithLogin(string login)
- {
- Login = login;
- return this;
- }
-
- public SubscriberBaseBuilder WithRawIrc(string rawIrc)
- {
- RawIrc = rawIrc;
- return this;
- }
-
- public SubscriberBaseBuilder WithResubMessage(string resubMessage)
- {
- ResubMessage = resubMessage;
- return this;
- }
-
- public SubscriberBaseBuilder WithRoomId(string roomId)
- {
- RoomId = roomId;
- return this;
- }
-
- public SubscriberBaseBuilder WithSubscribtionPlan(SubscriptionPlan subscriptionPlan)
- {
- SubscriptionPlan = subscriptionPlan;
- return this;
- }
-
- public SubscriberBaseBuilder WithSubscriptionPlanName(string subscriptionPlanName)
- {
- SubscriptionPlanName = subscriptionPlanName;
- return this;
- }
-
- public SubscriberBaseBuilder WithSystemMessage(string systemMessage)
- {
- SystemMessage = systemMessage;
- return this;
- }
-
- public SubscriberBaseBuilder WithParsedSystemMessage(string parsedSystemMessage)
- {
- ParsedSystemMessage = parsedSystemMessage;
- return this;
- }
-
- public SubscriberBaseBuilder WithTmiSent(DateTimeOffset tmiSent)
- {
- TmiSent = tmiSent;
- return this;
- }
-
- public SubscriberBaseBuilder WithUserType(UserType userType)
- {
- UserType = userType;
- return this;
- }
-
- public SubscriberBaseBuilder WithUserId(string userId)
- {
- UserId = userId;
- return this;
- }
-
- public SubscriberBaseBuilder WithMonths(int months)
- {
- Months = months;
- return this;
- }
-
- public SubscriberBaseBuilder WithMessageId(string messageId)
- {
- MessageId = messageId;
- return this;
- }
-
- public SubscriberBaseBuilder WithMsgParamCumulativeMonths(string msgParamCumulativeMonths)
- {
- MsgParamCumulativeMonths = msgParamCumulativeMonths;
- return this;
- }
-
- public SubscriberBaseBuilder WithMsgParamStreakMonths(string msgParamStreakMonths)
- {
- MsgParamStreakMonths = msgParamStreakMonths;
- return this;
- }
-
- public SubscriberBaseBuilder WithMsgParamShouldShareStreak(bool msgParamShouldShareStreak)
- {
- MsgParamShouldShareStreak = msgParamShouldShareStreak;
- return this;
- }
-
- public SubscriberBaseBuilder WithChannel(string channel)
- {
- Channel = channel;
- return this;
- }
-
- public virtual SubscriberBase Build()
- {
- return new SubscriberBase(
- Badges,
- BadgeInfo,
- HexColor,
- DisplayName,
- EmoteSet,
- Id,
- Login,
- SystemMessage,
- MessageId,
- MsgParamCumulativeMonths,
- MsgParamStreakMonths,
- MsgParamShouldShareStreak,
- ParsedSystemMessage,
- ResubMessage,
- SubscriptionPlan,
- SubscriptionPlanName,
- RoomId,
- UserId,
- IsModerator,
- IsTurbo,
- IsSubscriber,
- IsPartner,
- TmiSent,
- UserType,
- RawIrc,
- Channel,
- Months);
- }
- }
-}
diff --git a/TwitchLib.Client.Models/Builders/SubscriberBuilder.cs b/TwitchLib.Client.Models/Builders/SubscriberBuilder.cs
deleted file mode 100644
index 3b23eebc..00000000
--- a/TwitchLib.Client.Models/Builders/SubscriberBuilder.cs
+++ /dev/null
@@ -1,58 +0,0 @@
-#nullable disable
-#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
-
-namespace TwitchLib.Client.Models.Builders
-{
- public sealed class SubscriberBuilder : SubscriberBaseBuilder, IBuilder, IFromIrcMessageBuilder
- {
- private SubscriberBuilder()
- {
- }
-
- public static new SubscriberBuilder Create()
- {
- return new SubscriberBuilder();
- }
-
- public Subscriber BuildFromIrcMessage(FromIrcMessageBuilderDataObject fromIrcMessageBuilderDataObject)
- {
- return new Subscriber(fromIrcMessageBuilderDataObject.Message);
- }
-
- Subscriber IBuilder.Build()
- {
- return (Subscriber)Build();
- }
-
- public override SubscriberBase Build()
- {
- return new Subscriber(
- Badges,
- BadgeInfo,
- HexColor,
- DisplayName,
- EmoteSet,
- Id,
- Login,
- SystemMessage,
- MessageId,
- MsgParamCumulativeMonths,
- MsgParamStreakMonths,
- MsgParamShouldShareStreak,
- ParsedSystemMessage,
- ResubMessage,
- SubscriptionPlan,
- SubscriptionPlanName,
- RoomId,
- UserId,
- IsModerator,
- IsTurbo,
- IsSubscriber,
- IsPartner,
- TmiSent,
- UserType,
- RawIrc,
- Channel);
- }
- }
-}
diff --git a/TwitchLib.Client.Models/ChatMessage.cs b/TwitchLib.Client.Models/ChatMessage.cs
index 3463014a..0b7f4a88 100644
--- a/TwitchLib.Client.Models/ChatMessage.cs
+++ b/TwitchLib.Client.Models/ChatMessage.cs
@@ -7,6 +7,9 @@ namespace TwitchLib.Client.Models
/// Class represents ChatMessage in a Twitch channel.
public class ChatMessage : TwitchLibMessage
{
+ readonly ChatReply? _chatReply;
+ readonly HypeChat? _hypeChat;
+
protected readonly MessageEmoteCollection? _emoteCollection;
/// Information associated with badges. Not all badges will be in this list. Use carefully.
@@ -79,10 +82,10 @@ public class ChatMessage : TwitchLibMessage
public DateTimeOffset TmiSent { get; }
/// Chat reply information. Will be null if it is not a reply.
- public ChatReply? ChatReply { get; }
+ public ChatReply? ChatReply => _chatReply;
/// Hype Chat information.
- public HypeChat? HypeChat { get; }
+ public HypeChat? HypeChat => _hypeChat;
//Example IRC message: @badges=moderator/1,warcraft/alliance;color=;display-name=Swiftyspiffyv4;emotes=;mod=1;room-id=40876073;subscriber=0;turbo=0;user-id=103325214;user-type=mod :swiftyspiffyv4!swiftyspiffyv4@swiftyspiffyv4.tmi.twitch.tv PRIVMSG #swiftyspiffy :asd
/// Constructor for ChatMessage object.
@@ -207,49 +210,6 @@ public ChatMessage(
case Tags.Noisy:
Noisy = TagHelper.ToBool(tagValue) ? Noisy.True : Noisy.False;
break;
- case Tags.PinnedChatPaidAmount:
- (HypeChat ??= new()).Amount = int.Parse(tagValue);
- break;
- case Tags.PinnedChatPaidCurrency:
- (HypeChat ??= new()).Currency = tagValue;
- break;
- case Tags.PinnedChatPaidExponent:
- (HypeChat ??= new()).Exponent = int.Parse(tagValue);
- break;
- case Tags.PinnedChatPaidLevel:
- (HypeChat ??= new()).Level = Enum.TryParse(tagValue, true, out var val)
- ? val
- : throw new ArgumentException($"Requested value '{tagValue}' was not found.");
- break;
- case Tags.PinnedChatPaidIsSystemMessage:
- (HypeChat ??= new()).IsSystemMessage = TagHelper.ToBool(tagValue);
- break;
- case Tags.ReplyParentDisplayName:
- ChatReply ??= new ChatReply(); // ChatReply is null if not reply
- ChatReply.ParentDisplayName = tagValue;
- break;
- case Tags.ReplyParentMsgBody:
- ChatReply ??= new ChatReply(); // ChatReply is null if not reply
- ChatReply.ParentMsgBody = tagValue;
- break;
- case Tags.ReplyParentMsgId:
- ChatReply ??= new ChatReply(); // ChatReply is null if not reply
- ChatReply.ParentMsgId = tagValue;
- break;
- case Tags.ReplyParentUserId:
- ChatReply ??= new ChatReply(); // ChatReply is null if not reply
- ChatReply.ParentUserId = tagValue;
- break;
- case Tags.ReplyParentUserLogin:
- ChatReply ??= new ChatReply(); // ChatReply is null if not reply
- ChatReply.ParentUserLogin = tagValue;
- break;
- case Tags.ReplyThreadParentMsgId:
- (ChatReply ??= new()).ThreadParentMsgId = tagValue;
- break;
- case Tags.ReplyThreadParentUserLogin:
- (ChatReply ??= new()).ThreadParentUserLogin = tagValue;
- break;
case Tags.RoomId:
RoomId = tagValue;
break;
@@ -270,7 +230,8 @@ public ChatMessage(
UserType = TagHelper.ToUserType(tagValue);
break;
default:
- (UndocumentedTags = new()).Add(tag.Key, tag.Value);
+ if (!(ChatReply.TrySetTag(ref _chatReply, tag) || HypeChat.TrySetTag(ref _hypeChat, tag)))
+ (UndocumentedTags = new()).Add(tag.Key, tag.Value);
break;
}
}
diff --git a/TwitchLib.Client.Models/ChatReply.cs b/TwitchLib.Client.Models/ChatReply.cs
index 9dfa0b23..7dd76a0a 100644
--- a/TwitchLib.Client.Models/ChatReply.cs
+++ b/TwitchLib.Client.Models/ChatReply.cs
@@ -1,4 +1,6 @@
-namespace TwitchLib.Client.Models
+using TwitchLib.Client.Models.Internal;
+
+namespace TwitchLib.Client.Models
{
/// Class representing a chat reply/thread
public class ChatReply
@@ -6,36 +8,67 @@ public class ChatReply
///
/// The display name of the sender of the direct parent message.
///
- public string ParentDisplayName { get; internal set; }
+ public string ParentDisplayName { get; internal set; } = default!;
///
/// The text of the direct parent message.
///
- public string ParentMsgBody { get; internal set; }
+ public string ParentMsgBody { get; internal set; } = default!;
///
/// An ID that uniquely identifies the direct parent message that this message is replying to.
///
- public string ParentMsgId { get; internal set; }
+ public string ParentMsgId { get; internal set; } = default!;
///
/// An ID that identifies the sender of the direct parent message.
///
- public string ParentUserId { get; internal set; }
+ public string ParentUserId { get; internal set; } = default!;
///
/// The login name of the sender of the direct parent message.
///
- public string ParentUserLogin { get; internal set; }
+ public string ParentUserLogin { get; internal set; } = default!;
///
/// An ID that uniquely identifies the top-level parent message of the reply thread that this message is replying to.
///
- public string ThreadParentMsgId { get; internal set; }
+ public string ThreadParentMsgId { get; internal set; } = default!;
///
/// The login name of the sender of the top-level parent message.
///
- public string ThreadParentUserLogin { get; internal set; }
+ public string ThreadParentUserLogin { get; internal set; } = default!;
+
+ internal static bool TrySetTag(ref ChatReply? reply, KeyValuePair tag)
+ {
+ switch (tag.Key)
+ {
+ case Tags.ReplyParentDisplayName:
+ (reply ??= new()).ParentDisplayName = tag.Value;
+ break;
+ case Tags.ReplyParentMsgBody:
+ (reply ??= new()).ParentMsgBody = tag.Value;
+ break;
+ case Tags.ReplyParentMsgId:
+ (reply ??= new()).ParentMsgId = tag.Value;
+ break;
+ case Tags.ReplyParentUserId:
+ (reply ??= new()).ParentUserId = tag.Value;
+ break;
+ case Tags.ReplyParentUserLogin:
+ (reply ??= new()).ParentUserLogin = tag.Value;
+ break;
+ case Tags.ReplyThreadParentMsgId:
+ (reply ??= new()).ThreadParentMsgId = tag.Value;
+ break;
+ case Tags.ReplyThreadParentUserLogin:
+ (reply ??= new()).ThreadParentUserLogin = tag.Value;
+ break;
+ default:
+ return false;
+ }
+ return true;
+ }
}
}
diff --git a/TwitchLib.Client.Models/CommunityPayForward.cs b/TwitchLib.Client.Models/CommunityPayForward.cs
new file mode 100644
index 00000000..9a79b771
--- /dev/null
+++ b/TwitchLib.Client.Models/CommunityPayForward.cs
@@ -0,0 +1,93 @@
+using TwitchLib.Client.Enums;
+using TwitchLib.Client.Models.Internal;
+
+namespace TwitchLib.Client.Models;
+
+public class CommunityPayForward : UserNoticeBase
+{
+ public bool MsgParamPriorGifterAnonymous { get; protected set; }
+
+ public string MsgParamPriorGifterDisplayName { get; protected set; } = default!;
+
+ public string MsgParamPriorGifterId { get; protected set; } = default!;
+
+ public string MsgParamPriorGifterUserName { get; protected set; } = default!;
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ public CommunityPayForward(IrcMessage ircMessage) : base(ircMessage)
+ {
+ }
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ public CommunityPayForward(
+ List> badgeInfo,
+ List> badges,
+ string hexColor,
+ string displayMame,
+ string emotes,
+ string id,
+ string login,
+ bool isModerator,
+ string msgId,
+ string roomId,
+ bool isSubscriber,
+ string systemMsg,
+ DateTimeOffset tmiSent,
+ bool isTurbo,
+ string userId,
+ UserType userType,
+ Dictionary? undocumentedTags,
+ bool msgParamPriorGifterAnonymous,
+ string msgParamPriorGifterDisplayName,
+ string msgParamPriorGifterId,
+ string msgParamPriorGifterUserName)
+ : base(badgeInfo,
+ badges,
+ hexColor,
+ displayMame,
+ emotes,
+ id,
+ login,
+ isModerator,
+ msgId, roomId,
+ isSubscriber,
+ systemMsg,
+ tmiSent,
+ isTurbo,
+ userId,
+ userType,
+ undocumentedTags)
+ {
+ MsgParamPriorGifterAnonymous = msgParamPriorGifterAnonymous;
+ MsgParamPriorGifterDisplayName = msgParamPriorGifterDisplayName;
+ MsgParamPriorGifterId = msgParamPriorGifterId;
+ MsgParamPriorGifterUserName = msgParamPriorGifterUserName;
+ }
+
+ ///
+ protected override bool TrySet(KeyValuePair tag)
+ {
+ switch (tag.Key)
+ {
+ case Tags.MsgParamPriorGifterAnonymous:
+ MsgParamPriorGifterAnonymous = bool.Parse(tag.Value);
+ break;
+ case Tags.MsgParamPriorGifterDisplayName:
+ MsgParamPriorGifterDisplayName = tag.Value;
+ break;
+ case Tags.MsgParamPriorGifterId:
+ MsgParamPriorGifterId = tag.Value;
+ break;
+ case Tags.MsgParamPriorGifterUserName:
+ MsgParamPriorGifterUserName = tag.Value;
+ break;
+ default:
+ return false;
+ }
+ return true;
+ }
+}
diff --git a/TwitchLib.Client.Models/CommunitySubscription.cs b/TwitchLib.Client.Models/CommunitySubscription.cs
index cfb86f52..0a6addcc 100644
--- a/TwitchLib.Client.Models/CommunitySubscription.cs
+++ b/TwitchLib.Client.Models/CommunitySubscription.cs
@@ -1,122 +1,111 @@
-#nullable disable
-#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
-using TwitchLib.Client.Enums;
-using TwitchLib.Client.Models.Interfaces;
+using TwitchLib.Client.Enums;
using TwitchLib.Client.Models.Internal;
-namespace TwitchLib.Client.Models
+namespace TwitchLib.Client.Models;
+
+//submysterygift
+public class CommunitySubscription : UserNoticeBase
{
- public class CommunitySubscription : IHexColorProperty
- {
- private const string AnonymousGifterUserId = "274598607";
+ private Goal? _goal;
+
+ public bool IsAnonymous { get; }
+
+ public Goal? MsgParamGoal { get => _goal; protected set => _goal = value; }
+
+ public string MsgParamGiftTheme { get; protected set; } = default!;
+
+ public int MsgParamMassGiftCount { get; protected set; }
+
+ public string MsgParamOriginId { get; protected set; } = default!;
- public List> Badges;
- public List> BadgeInfo;
-
- ///
- public string HexColor { get; }
- public string DisplayName;
- public string Emotes;
- public string Id;
- public string Login;
- public bool IsModerator;
- public bool IsAnonymous;
- public string MsgId;
- public int MsgParamMassGiftCount;
- public int MsgParamSenderCount;
- public SubscriptionPlan MsgParamSubPlan;
- public string RoomId;
- public bool IsSubscriber;
- public string SystemMsg;
- public string SystemMsgParsed;
- public DateTimeOffset TmiSent;
- public bool IsTurbo;
- public string UserId;
- public UserType UserType;
- public string MsgParamMultiMonthGiftDuration;
+ public int MsgParamSenderCount { get; protected set; }
- ///
- /// Contains undocumented tags.
- ///
- public Dictionary? UndocumentedTags { get; }
+ ///
+ /// The type of subscription plan being used.
+ ///
+ public SubscriptionPlan MsgParamSubPlan { get; protected set; }
- public CommunitySubscription(IrcMessage ircMessage)
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ public CommunitySubscription(IrcMessage ircMessage) : base(ircMessage)
+ {
+ IsAnonymous = UserId == AnonymousGifterUserId;
+ }
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ public CommunitySubscription(
+ List> badgeInfo,
+ List> badges,
+ string hexColor,
+ string displayMame,
+ string emotes,
+ string id,
+ string login,
+ bool isModerator,
+ string msgId,
+ string roomId,
+ bool isSubscriber,
+ string systemMsg,
+ DateTimeOffset tmiSent,
+ bool isTurbo,
+ string userId,
+ UserType userType,
+ Dictionary? undocumentedTags,
+ Goal? msgParamGoal,
+ string msgParamGiftTheme,
+ int msgParamMassGiftCount,
+ string msgParamOriginId,
+ int msgParamSenderCount,
+ SubscriptionPlan msgParamSubPlan)
+ : base(badgeInfo,
+ badges,
+ hexColor,
+ displayMame,
+ emotes,
+ id,
+ login,
+ isModerator,
+ msgId, roomId,
+ isSubscriber,
+ systemMsg,
+ tmiSent,
+ isTurbo,
+ userId,
+ userType,
+ undocumentedTags)
+ {
+ IsAnonymous = userId == AnonymousGifterUserId;
+ MsgParamGoal = msgParamGoal;
+ MsgParamGiftTheme = msgParamGiftTheme;
+ MsgParamMassGiftCount = msgParamMassGiftCount;
+ MsgParamOriginId = msgParamOriginId;
+ MsgParamSenderCount = msgParamSenderCount;
+ MsgParamSubPlan = msgParamSubPlan;
+ }
+
+ ///
+ protected override bool TrySet(KeyValuePair tag)
+ {
+ switch (tag.Key)
{
- foreach (var tag in ircMessage.Tags)
- {
- var (tagKey, tagValue) = (tag.Key, tag.Value);
- switch (tagKey)
- {
- case Tags.Badges:
- Badges = TagHelper.ToBadges(tagValue);
- break;
- case Tags.BadgeInfo:
- BadgeInfo = TagHelper.ToBadges(tagValue);
- break;
- case Tags.Color:
- HexColor = tagValue;
- break;
- case Tags.DisplayName:
- DisplayName = tagValue;
- break;
- case Tags.Emotes:
- Emotes = tagValue;
- break;
- case Tags.Id:
- Id = tagValue;
- break;
- case Tags.Login:
- Login = tagValue;
- break;
- case Tags.Mod:
- IsModerator = TagHelper.ToBool(tagValue);
- break;
- case Tags.MsgId:
- MsgId = tagValue;
- break;
- case Tags.MsgParamSubPlan:
- MsgParamSubPlan = TagHelper.ToSubscriptionPlan(tag.Value);
- break;
- case Tags.MsgParamMassGiftCount:
- MsgParamMassGiftCount = int.Parse(tag.Value);
- break;
- case Tags.MsgParamSenderCount:
- MsgParamSenderCount = int.Parse(tag.Value);
- break;
- case Tags.RoomId:
- RoomId = tagValue;
- break;
- case Tags.Subscriber:
- IsSubscriber = TagHelper.ToBool(tagValue);
- break;
- case Tags.SystemMsg:
- SystemMsg = tagValue;
- SystemMsgParsed = tagValue.Replace("\\s", " ").Replace("\\n", "");
- break;
- case Tags.TmiSentTs:
- TmiSent = TagHelper.ToDateTimeOffsetFromUnixMs(tagValue);
- break;
- case Tags.Turbo:
- IsTurbo = TagHelper.ToBool(tagValue);
- break;
- case Tags.UserId:
- UserId = tagValue;
- if(UserId == AnonymousGifterUserId)
- {
- IsAnonymous = true;
- }
- break;
- case Tags.UserType:
- UserType = TagHelper.ToUserType(tag.Value);
- break;
- case Tags.MsgParamMultiMonthGiftDuration:
- MsgParamMultiMonthGiftDuration = tagValue;
- break;
- default:
- (UndocumentedTags = new()).Add(tag.Key, tag.Value);
- break;
- }
- }
+ case Tags.MsgParamGiftTheme:
+ MsgParamGiftTheme = tag.Value;
+ break;
+ case Tags.MsgParamMassGiftCount:
+ MsgParamMassGiftCount = int.Parse(tag.Value);
+ break;
+ case Tags.MsgParamSenderCount:
+ MsgParamSenderCount = int.Parse(tag.Value);
+ break;
+ case Tags.MsgParamSubPlan:
+ MsgParamSubPlan = TagHelper.ToSubscriptionPlan(tag.Value);
+ break;
+ default:
+ return Goal.TrySetTag(ref _goal, tag);
}
+ return true;
}
}
diff --git a/TwitchLib.Client.Models/ContinuedGiftedSubscription.cs b/TwitchLib.Client.Models/ContinuedGiftedSubscription.cs
index c402684a..468e486e 100644
--- a/TwitchLib.Client.Models/ContinuedGiftedSubscription.cs
+++ b/TwitchLib.Client.Models/ContinuedGiftedSubscription.cs
@@ -1,124 +1,107 @@
-#nullable disable
-#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
-using TwitchLib.Client.Enums;
-using TwitchLib.Client.Models.Interfaces;
+using TwitchLib.Client.Enums;
using TwitchLib.Client.Models.Internal;
-namespace TwitchLib.Client.Models
+namespace TwitchLib.Client.Models;
+
+// giftpaidupgrade
+public class ContinuedGiftedSubscription : UserNoticeBase
{
- public class ContinuedGiftedSubscription : IHexColorProperty
+ ///
+ /// The number of gifts the gifter has given during the promo indicated by .
+ ///
+ public int MsgParamPromoGiftTotal { get; protected set; }
+
+ ///
+ /// The subscriptions promo, if any, that is ongoing (for example, Subtember 2018).
+ ///
+ public string MsgParamPromoName { get; protected set; } = default!;
+
+ ///
+ /// The login name of the user who gifted the subscription.
+ ///
+ public string MsgParamSenderLogin { get; protected set; } = default!;
+
+ ///
+ /// The display name of the user who gifted the subscription.
+ ///
+ public string MsgParamSenderName { get; protected set; } = default!;
+
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ public ContinuedGiftedSubscription(IrcMessage ircMessage) : base(ircMessage)
{
- //@badge-info=subscriber/11;badges=subscriber/9;color=#DAA520;display-name=Varanid;emotes=;flags=;id=a2d384c1-c30a-409e-8001-9e7d8f9c784d;login=varanid;mod=0;msg-id=giftpaidupgrade;msg-param-sender-login=cletusbueford;msg-param-sender-name=CletusBueford;room-id=44338537;subscriber=1;system-msg=Varanid\sis\scontinuing\sthe\sGift\sSub\sthey\sgot\sfrom\sCletusBueford!;tmi-sent-ts=1612497386372;user-id=67505836;user-type= :tmi.twitch.tv USERNOTICE #burkeblack
-
- public List> Badges { get; }
-
- public List> BadgeInfo { get; }
-
-
- ///
- public string HexColor { get; }
-
- public string DisplayName { get; }
-
- public string Emotes { get; }
-
- public string Flags { get; }
-
- public string Id { get; }
-
- public string Login { get; }
-
- public bool IsModerator { get; }
-
- public string MsgId { get; }
-
- public string MsgParamSenderLogin { get; }
-
- public string MsgParamSenderName { get; }
-
- public string RoomId { get; }
-
- public bool IsSubscriber { get; }
-
- public string SystemMsg { get; }
-
- public DateTimeOffset TmiSent { get; }
-
- public string UserId { get; }
-
- public UserType UserType { get; }
+ }
- ///
- /// Contains undocumented tags.
- ///
- public Dictionary? UndocumentedTags { get; }
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ public ContinuedGiftedSubscription(
+ List> badgeInfo,
+ List> badges,
+ string hexColor,
+ string displayMame,
+ string emotes,
+ string id,
+ string login,
+ bool isModerator,
+ string msgId,
+ string roomId,
+ bool isSubscriber,
+ string systemMsg,
+ DateTimeOffset tmiSent,
+ bool isTurbo,
+ string userId,
+ UserType userType,
+ Dictionary? undocumentedTags,
+ int msgParamPromoGiftTotal,
+ string msgParamPromoName,
+ string msgParamSenderLogin,
+ string msgParamSenderName)
+ : base(badgeInfo,
+ badges,
+ hexColor,
+ displayMame,
+ emotes,
+ id,
+ login,
+ isModerator,
+ msgId, roomId,
+ isSubscriber,
+ systemMsg,
+ tmiSent,
+ isTurbo,
+ userId,
+ userType,
+ undocumentedTags)
+ {
+ MsgParamPromoGiftTotal = msgParamPromoGiftTotal;
+ MsgParamPromoName = msgParamPromoName;
+ MsgParamSenderLogin = msgParamSenderLogin;
+ MsgParamSenderName = msgParamSenderName;
+ }
- public ContinuedGiftedSubscription(IrcMessage ircMessage)
+ ///
+ protected override bool TrySet(KeyValuePair tag)
+ {
+ switch (tag.Key)
{
- foreach (var tag in ircMessage.Tags)
- {
- var tagValue = tag.Value;
- switch (tag.Key)
- {
- case Tags.SystemMsg:
- SystemMsg = tagValue;
- break;
- case Tags.Flags:
- Flags = tagValue;
- break;
- case Tags.MsgParamSenderLogin:
- MsgParamSenderLogin = tagValue;
- break;
- case Tags.MsgParamSenderName:
- MsgParamSenderName = tagValue;
- break;
- case Tags.Badges:
- Badges = TagHelper.ToBadges(tagValue);
- break;
- case Tags.BadgeInfo:
- BadgeInfo = TagHelper.ToBadges(tagValue);
- break;
- case Tags.Color:
- HexColor = tagValue;
- break;
- case Tags.DisplayName:
- DisplayName = tagValue;
- break;
- case Tags.Emotes:
- Emotes = tagValue;
- break;
- case Tags.Id:
- Id = tagValue;
- break;
- case Tags.Login:
- Login = tagValue;
- break;
- case Tags.Mod:
- IsModerator = TagHelper.ToBool(tagValue);
- break;
- case Tags.MsgId:
- MsgId = tagValue;
- break;
- case Tags.RoomId:
- RoomId = tagValue;
- break;
- case Tags.Subscriber:
- IsSubscriber = TagHelper.ToBool(tagValue);
- break;
- case Tags.TmiSentTs:
- TmiSent = TagHelper.ToDateTimeOffsetFromUnixMs(tagValue);
- break;
- case Tags.UserId:
- UserId = tagValue;
- break;
- case Tags.UserType:
- UserType = TagHelper.ToUserType(tag.Value);
- break;
- default:
- (UndocumentedTags = new()).Add(tag.Key, tag.Value);
- break;
- }
- }
+ case Tags.MsgParamPromoGiftTotal:
+ MsgParamPromoGiftTotal = int.Parse(tag.Value);
+ break;
+ case Tags.MsgParamPromoName:
+ MsgParamPromoName = tag.Value;
+ break;
+ case Tags.MsgParamSenderLogin:
+ MsgParamSenderLogin = tag.Value;
+ break;
+ case Tags.MsgParamSenderName:
+ MsgParamSenderName = tag.Value;
+ break;
+ default:
+ return false;
}
+ return true;
}
}
diff --git a/TwitchLib.Client.Models/GiftedSubscription.cs b/TwitchLib.Client.Models/GiftedSubscription.cs
index 7175376e..9b26f2f3 100644
--- a/TwitchLib.Client.Models/GiftedSubscription.cs
+++ b/TwitchLib.Client.Models/GiftedSubscription.cs
@@ -1,209 +1,150 @@
-#nullable disable
-#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
-using TwitchLib.Client.Enums;
-using TwitchLib.Client.Models.Interfaces;
+using TwitchLib.Client.Enums;
using TwitchLib.Client.Models.Internal;
-namespace TwitchLib.Client.Models
-{
- public class GiftedSubscription : IHexColorProperty
- {
- private const string AnonymousGifterUserId = "274598607";
-
- public List> Badges { get; }
-
- public List> BadgeInfo { get; }
-
- ///
- public string HexColor { get; }
-
- public string DisplayName { get; }
-
- public string Emotes { get; }
-
- public string Id { get; }
-
- public bool IsModerator { get; }
-
- public bool IsSubscriber { get; }
-
- public bool IsTurbo { get; }
-
- public bool IsAnonymous { get; }
+namespace TwitchLib.Client.Models;
- public string Login { get; }
-
- public string MsgId { get; }
-
- public string MsgParamMonths { get; }
-
- public string MsgParamRecipientDisplayName { get; }
-
- public string MsgParamRecipientId { get; }
+//SubGift
+public class GiftedSubscription : UserNoticeBase
+{
+ private Goal? _goal;
- public string MsgParamRecipientUserName { get; }
+ public Goal? MsgParamGoal { get => _goal; protected set => _goal = value; }
- public string MsgParamSubPlanName { get; }
+ public bool IsAnonymous { get; }
- public SubscriptionPlan MsgParamSubPlan { get; }
+ ///
+ /// The total number of months the user has subscribed.
+ ///
+ public string MsgParamMonths { get; protected set; } = default!;
- public string RoomId { get; }
+ ///
+ /// The display name of the subscription gift recipient.
+ ///
+ public string MsgParamRecipientDisplayName { get; protected set; } = default!;
- public string SystemMsg { get; }
+ ///
+ /// The user ID of the subscription gift recipient.
+ ///
+ public string MsgParamRecipientId { get; protected set; } = default!;
- public string SystemMsgParsed { get; }
+ ///
+ /// The user name of the subscription gift recipient.
+ ///
+ public string MsgParamRecipientUserName { get; protected set; } = default!;
- public DateTimeOffset TmiSent { get; }
+ public int MsgParamSenderCount { get; protected set; }
- public string UserId { get; }
+ ///
+ /// The type of subscription plan being used.
+ ///
+ public SubscriptionPlan MsgParamSubPlan { get; protected set; }
- public UserType UserType { get; }
+ ///
+ /// The display name of the subscription plan. This may be a default name or one created by the channel owner.
+ ///
+ public string MsgParamSubPlanName { get; protected set; } = default!;
- public string MsgParamMultiMonthGiftDuration { get; }
+ ///
+ /// The number of months gifted as part of a single, multi-month gift.
+ ///
+ public int MsgParamMultiMonthGiftDuration { get; protected set; }
- ///
- /// Contains undocumented tags.
- ///
- public Dictionary? UndocumentedTags { get; }
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ public GiftedSubscription(IrcMessage ircMessage) : base(ircMessage)
+ {
+ IsAnonymous = UserId == AnonymousGifterUserId;
+ }
- public GiftedSubscription(IrcMessage ircMessage)
- {
- foreach (var tag in ircMessage.Tags)
- {
- var tagValue = tag.Value;
- switch (tag.Key)
- {
- case Tags.Badges:
- Badges = TagHelper.ToBadges(tagValue);
- break;
- case Tags.BadgeInfo:
- BadgeInfo = TagHelper.ToBadges(tagValue);
- break;
- case Tags.Color:
- HexColor = tagValue;
- break;
- case Tags.DisplayName:
- DisplayName = tagValue;
- break;
- case Tags.Emotes:
- Emotes = tagValue;
- break;
- case Tags.Id:
- Id = tagValue;
- break;
- case Tags.Login:
- Login = tagValue;
- break;
- case Tags.Mod:
- IsModerator = TagHelper.ToBool(tagValue);
- break;
- case Tags.MsgId:
- MsgId = tagValue;
- break;
- case Tags.MsgParamMonths:
- MsgParamMonths = tagValue;
- break;
- case Tags.MsgParamRecipientDisplayname:
- MsgParamRecipientDisplayName = tagValue;
- break;
- case Tags.MsgParamRecipientId:
- MsgParamRecipientId = tagValue;
- break;
- case Tags.MsgParamRecipientUsername:
- MsgParamRecipientUserName = tagValue;
- break;
- case Tags.MsgParamSubPlanName:
- MsgParamSubPlanName = tagValue;
- break;
- case Tags.MsgParamSubPlan:
- MsgParamSubPlan = TagHelper.ToSubscriptionPlan(tag.Value);
- break;
- case Tags.RoomId:
- RoomId = tagValue;
- break;
- case Tags.Subscriber:
- IsSubscriber = TagHelper.ToBool(tagValue);
- break;
- case Tags.SystemMsg:
- SystemMsg = tagValue;
- SystemMsgParsed = tagValue.Replace("\\s", " ").Replace("\\n", "");
- break;
- case Tags.TmiSentTs:
- TmiSent = TagHelper.ToDateTimeOffsetFromUnixMs(tagValue);
- break;
- case Tags.Turbo:
- IsTurbo = TagHelper.ToBool(tagValue);
- break;
- case Tags.UserId:
- UserId = tagValue;
- if (UserId == AnonymousGifterUserId)
- {
- IsAnonymous = true;
- }
- break;
- case Tags.UserType:
- UserType = TagHelper.ToUserType(tag.Value);
- break;
- case Tags.MsgParamMultiMonthGiftDuration:
- MsgParamMultiMonthGiftDuration = tagValue;
- break;
- default:
- (UndocumentedTags = new()).Add(tag.Key, tag.Value);
- break;
- }
- }
- }
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ public GiftedSubscription(
+ List> badgeInfo,
+ List> badges,
+ string hexColor,
+ string displayMame,
+ string emotes,
+ string id,
+ string login,
+ bool isModerator,
+ string msgId,
+ string roomId,
+ bool isSubscriber,
+ string systemMsg,
+ DateTimeOffset tmiSent,
+ bool isTurbo,
+ string userId,
+ UserType userType,
+ Dictionary? undocumentedTags,
+ Goal? msgParamGoal,
+ string msgParamMonths,
+ string msgParamRecipientDisplayName,
+ string msgParamRecipientId,
+ string msgParamRecipientUserName,
+ int msgParamSenderCount,
+ SubscriptionPlan msgParamSubPlan,
+ string msgParamSubPlanName,
+ int msgParamMultiMonthGiftDuration)
+ : base(badgeInfo,
+ badges,
+ hexColor,
+ displayMame,
+ emotes,
+ id,
+ login,
+ isModerator,
+ msgId, roomId,
+ isSubscriber,
+ systemMsg,
+ tmiSent,
+ isTurbo,
+ userId,
+ userType,
+ undocumentedTags)
+ {
+ MsgParamGoal = msgParamGoal;
+ IsAnonymous = userId == AnonymousGifterUserId;
+ MsgParamMonths = msgParamMonths;
+ MsgParamRecipientDisplayName = msgParamRecipientDisplayName;
+ MsgParamRecipientId = msgParamRecipientId;
+ MsgParamRecipientUserName = msgParamRecipientUserName;
+ MsgParamSenderCount = msgParamSenderCount;
+ MsgParamSubPlan = msgParamSubPlan;
+ MsgParamSubPlanName = msgParamSubPlanName;
+ MsgParamMultiMonthGiftDuration = msgParamMultiMonthGiftDuration;
+ }
- public GiftedSubscription(
- List> badges,
- List> badgeInfo,
- string hexColor,
- string displayName,
- string emotes,
- string id,
- string login,
- bool isModerator,
- string msgId,
- string msgParamMonths,
- string msgParamRecipientDisplayName,
- string msgParamRecipientId,
- string msgParamRecipientUserName,
- string msgParamSubPlanName,
- string msgMultiMonthDuration,
- SubscriptionPlan msgParamSubPlan,
- string roomId,
- bool isSubscriber,
- string systemMsg,
- string systemMsgParsed,
- DateTimeOffset tmiSent,
- bool isTurbo,
- UserType userType,
- string userId)
+ ///
+ protected override bool TrySet(KeyValuePair tag)
+ {
+ switch (tag.Key)
{
- Badges = badges;
- BadgeInfo = badgeInfo;
- HexColor = hexColor;
- DisplayName = displayName;
- Emotes = emotes;
- Id = id;
- Login = login;
- IsModerator = isModerator;
- MsgId = msgId;
- MsgParamMonths = msgParamMonths;
- MsgParamRecipientDisplayName = msgParamRecipientDisplayName;
- MsgParamRecipientId = msgParamRecipientId;
- MsgParamRecipientUserName = msgParamRecipientUserName;
- MsgParamSubPlanName = msgParamSubPlanName;
- MsgParamSubPlan = msgParamSubPlan;
- MsgParamMultiMonthGiftDuration = msgMultiMonthDuration;
- RoomId = roomId;
- IsSubscriber = isSubscriber;
- SystemMsg = systemMsg;
- SystemMsgParsed = systemMsgParsed;
- TmiSent = tmiSent;
- IsTurbo = isTurbo;
- UserType = userType;
- UserId = userId;
+ case Tags.MsgParamMonths:
+ MsgParamMonths = tag.Value;
+ break;
+ case Tags.MsgParamRecipientDisplayname:
+ MsgParamRecipientDisplayName = tag.Value;
+ break;
+ case Tags.MsgParamRecipientId:
+ MsgParamRecipientId = tag.Value;
+ break;
+ case Tags.MsgParamRecipientUsername:
+ MsgParamRecipientUserName = tag.Value;
+ break;
+ case Tags.MsgParamSubPlanName:
+ MsgParamSubPlanName = tag.Value;
+ break;
+ case Tags.MsgParamSubPlan:
+ MsgParamSubPlan = TagHelper.ToSubscriptionPlan(tag.Value);
+ break;
+ case Tags.MsgParamMultiMonthGiftDuration:
+ MsgParamMultiMonthGiftDuration = int.Parse(tag.Value);
+ break;
+ default:
+ return Goal.TrySetTag(ref _goal, tag);
}
+ return true;
}
}
diff --git a/TwitchLib.Client.Models/Goal.cs b/TwitchLib.Client.Models/Goal.cs
new file mode 100644
index 00000000..a86f26f6
--- /dev/null
+++ b/TwitchLib.Client.Models/Goal.cs
@@ -0,0 +1,41 @@
+using TwitchLib.Client.Models.Internal;
+
+namespace TwitchLib.Client.Models;
+
+public class Goal
+{
+ public string ContributionType { get; protected set; } = default!; //SUB_POINTS, SUB
+
+ public int CurrentContributions { get; protected set; }
+
+ public string? Description { get; protected set; }
+
+ public int TargetContributions { get; protected set; }
+
+ public int UserContributions { get; protected set; }
+
+ internal static bool TrySetTag(ref Goal? goal, KeyValuePair tag)
+ {
+ switch (tag.Key)
+ {
+ case Tags.MsgParamGoalContributionType:
+ (goal ??= new()).ContributionType = tag.Value;
+ break;
+ case Tags.MsgParamGoalCurrentContributions:
+ (goal ??= new()).CurrentContributions = int.Parse(tag.Value); ;
+ break;
+ case Tags.MsgParamGoalDescription:
+ (goal ??= new()).Description = tag.Value;
+ break;
+ case Tags.MsgParamGoalTargetContributions:
+ (goal ??= new()).TargetContributions = int.Parse(tag.Value);
+ break;
+ case Tags.MsgParamGoalUserContributions:
+ (goal ??= new()).UserContributions = int.Parse(tag.Value);
+ break;
+ default:
+ return false;
+ }
+ return true;
+ }
+}
diff --git a/TwitchLib.Client.Models/HypeChat.cs b/TwitchLib.Client.Models/HypeChat.cs
index 5fede783..984cbad5 100644
--- a/TwitchLib.Client.Models/HypeChat.cs
+++ b/TwitchLib.Client.Models/HypeChat.cs
@@ -1,4 +1,5 @@
using TwitchLib.Client.Enums;
+using TwitchLib.Client.Models.Internal;
public class HypeChat
{
@@ -34,4 +35,31 @@ public class HypeChat
/// If false (0), the user provided their own message to send with the Hype Chat.
///
public bool IsSystemMessage { get; internal set; }
+
+ internal static bool TrySetTag(ref HypeChat? hypeChat, KeyValuePair tag)
+ {
+ switch (tag.Key)
+ {
+ case Tags.PinnedChatPaidAmount:
+ (hypeChat ??= new()).Amount = int.Parse(tag.Value);
+ break;
+ case Tags.PinnedChatPaidCurrency:
+ (hypeChat ??= new()).Currency = tag.Value;
+ break;
+ case Tags.PinnedChatPaidExponent:
+ (hypeChat ??= new()).Exponent = int.Parse(tag.Value);
+ break;
+ case Tags.PinnedChatPaidLevel:
+ (hypeChat ??= new()).Level = Enum.TryParse(tag.Value, true, out var val)
+ ? val
+ : throw new ArgumentException($"Requested value '{tag.Value}' was not found.");
+ break;
+ case Tags.PinnedChatPaidIsSystemMessage:
+ (hypeChat ??= new()).IsSystemMessage = TagHelper.ToBool(tag.Value);
+ break;
+ default:
+ return false;
+ }
+ return true;
+ }
}
diff --git a/TwitchLib.Client.Models/Internal/Tags.cs b/TwitchLib.Client.Models/Internal/Tags.cs
index 394f96c7..49cfccd7 100644
--- a/TwitchLib.Client.Models/Internal/Tags.cs
+++ b/TwitchLib.Client.Models/Internal/Tags.cs
@@ -29,7 +29,17 @@ public static class Tags
public const string MsgParamDisplayname = "msg-param-displayName"; // Sent only on raid
public const string MsgParamLogin = "msg-param-login"; // Sent only on raid
public const string MsgParamCumulativeMonths = "msg-param-cumulative-months"; // Sent only on sub, resub
+ public const string MsgParamGiftTheme = "msg-param-gift-theme";
+ public const string MsgParamGoalContributionType = "msg-param-goal-contribution-type";
+ public const string MsgParamGoalCurrentContributions = "msg-param-goal-current-contributions";
+ public const string MsgParamGoalDescription = "msg-param-goal-description";
+ public const string MsgParamGoalTargetContributions = "msg-param-goal-target-contributions";
+ public const string MsgParamGoalUserContributions = "msg-param-goal-user-contributions";
public const string MsgParamMonths = "msg-param-months"; // Sent only on subgift, anonsubgift
+ public const string MsgParamPriorGifterAnonymous = "msg-param-prior-gifter-anonymous";
+ public const string MsgParamPriorGifterDisplayName = "msg-param-prior-gifter-display-name";
+ public const string MsgParamPriorGifterId = "msg-param-prior-gifter-id";
+ public const string MsgParamPriorGifterUserName = "msg-param-prior-gifter-user-name";
public const string MsgParamPromoGiftTotal = "msg-param-promo-gift-total"; // Sent only on anongiftpaidupgrade, giftpaidupgrade
public const string MsgParamPromoName = "msg-param-promo-name"; // Sent only on anongiftpaidupgrade, giftpaidupgrade
public const string MsgParamShouldShareStreak = "msg-param-should-share-streak"; // Sent only on sub, resub
diff --git a/TwitchLib.Client.Models/PrimePaidSubscriber.cs b/TwitchLib.Client.Models/PrimePaidSubscriber.cs
index 17daf3c0..3e942d27 100644
--- a/TwitchLib.Client.Models/PrimePaidSubscriber.cs
+++ b/TwitchLib.Client.Models/PrimePaidSubscriber.cs
@@ -1,70 +1,84 @@
using TwitchLib.Client.Enums;
using TwitchLib.Client.Models.Internal;
-namespace TwitchLib.Client.Models
+namespace TwitchLib.Client.Models;
+
+public class PrimePaidSubscriber : UserNoticeBase
{
- public class PrimePaidSubscriber : SubscriberBase
+ ///
+ /// The type of subscription plan being used.
+ ///
+ public SubscriptionPlan MsgParamSubPlan { get; protected set; }
+
+ ///
+ /// Property representing system message.
+ ///
+ public string ResubMessage { get; }
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The IRC message from Twitch to be processed.
+ public PrimePaidSubscriber(IrcMessage ircMessage) : base(ircMessage)
{
- public PrimePaidSubscriber(IrcMessage ircMessage) : base(ircMessage)
- {
- }
+ ResubMessage = ircMessage.Message;
+ }
- public PrimePaidSubscriber(
- List> badges,
- List> badgeInfo,
- string hexColor,
- string displayName,
- string emoteSet,
- string id,
- string login,
- string systemMessage,
- string msgId,
- string msgParamCumulativeMonths,
- string msgParamStreakMonths,
- bool msgParamShouldShareStreak,
- string systemMessageParsed,
- string resubMessage,
- SubscriptionPlan subscriptionPlan,
- string subscriptionPlanName,
- string roomId,
- string userId,
- bool isModerator,
- bool isTurbo,
- bool isSubscriber,
- bool isPartner,
- DateTimeOffset tmiSent,
- UserType userType,
- string rawIrc,
- string channel,
- int months = 0)
- : base(badges,
- badgeInfo,
- hexColor,
- displayName,
- emoteSet,
- id,
- login,
- systemMessage,
- msgId,
- msgParamCumulativeMonths,
- msgParamStreakMonths,
- msgParamShouldShareStreak,
- systemMessageParsed,
- resubMessage,
- subscriptionPlan,
- subscriptionPlanName,
- roomId,
- userId,
- isModerator,
- isTurbo,
- isSubscriber,
- isPartner,
- tmiSent,
- userType,
- rawIrc,
- channel,
- months)
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ public PrimePaidSubscriber(
+ List> badgeInfo,
+ List> badges,
+ string hexColor,
+ string displayMame,
+ string emotes,
+ string id,
+ string login,
+ bool isModerator,
+ string msgId,
+ string roomId,
+ bool isSubscriber,
+ string systemMsg,
+ DateTimeOffset tmiSent,
+ bool isTurbo,
+ string userId,
+ UserType userType,
+ Dictionary? undocumentedTags,
+ SubscriptionPlan msgParamSubPlan,
+ string resubMessage)
+ : base(badgeInfo,
+ badges,
+ hexColor,
+ displayMame,
+ emotes,
+ id,
+ login,
+ isModerator,
+ msgId, roomId,
+ isSubscriber,
+ systemMsg,
+ tmiSent,
+ isTurbo,
+ userId,
+ userType,
+ undocumentedTags)
+ {
+ MsgParamSubPlan = msgParamSubPlan;
+ ResubMessage = resubMessage;
+ }
+
+ ///
+ protected override bool TrySet(KeyValuePair tag)
+ {
+ switch (tag.Key)
{
+ case Tags.MsgParamSubPlan:
+ MsgParamSubPlan = TagHelper.ToSubscriptionPlan(tag.Value);
+ break;
+ default:
+ return false;
}
+ return true;
}
}
diff --git a/TwitchLib.Client.Models/RaidNotification.cs b/TwitchLib.Client.Models/RaidNotification.cs
index 5dee4737..3c9725b2 100644
--- a/TwitchLib.Client.Models/RaidNotification.cs
+++ b/TwitchLib.Client.Models/RaidNotification.cs
@@ -1,171 +1,95 @@
-#nullable disable
-#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
-using TwitchLib.Client.Enums;
-using TwitchLib.Client.Models.Interfaces;
+using TwitchLib.Client.Enums;
using TwitchLib.Client.Models.Internal;
-namespace TwitchLib.Client.Models
+namespace TwitchLib.Client.Models;
+
+public class RaidNotification : UserNoticeBase
{
- public class RaidNotification : IHexColorProperty
+ ///
+ /// The display name of the broadcaster raiding this channel.
+ ///
+ public string MsgParamDisplayName { get; protected set; } = default!;
+
+ ///
+ /// The login name of the broadcaster raiding this channel.
+ ///
+ public string MsgParamLogin { get; protected set; } = default!;
+
+ ///
+ /// The number of viewers raiding this channel from the broadcaster’s channel.
+ ///
+ public string MsgParamViewerCount { get; protected set; } = default!;
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ public RaidNotification(IrcMessage ircMessage) : base(ircMessage)
{
- public List> Badges { get; }
-
- public List> BadgeInfo { get; }
-
- ///
- public string HexColor { get; }
-
- public string DisplayName { get; }
-
- public string Emotes { get; }
-
- public string Id { get; }
-
- public string Login { get; }
-
- public bool Moderator { get; }
-
- public string MsgId { get; }
-
- public string MsgParamDisplayName { get; }
-
- public string MsgParamLogin { get; }
-
- public string MsgParamViewerCount { get; }
-
- public string RoomId { get; }
-
- public bool Subscriber { get; }
-
- public string SystemMsg { get; }
-
- public string SystemMsgParsed { get; }
-
- public DateTimeOffset TmiSent { get; }
-
- public bool Turbo { get; }
-
- public string UserId { get; }
-
- public UserType UserType { get; }
-
- ///
- /// Contains undocumented tags.
- ///
- public Dictionary? UndocumentedTags { get; }
+ }
- // @badges=;color=#FF0000;display-name=Heinki;emotes=;id=4fb7ab2d-aa2c-4886-a286-46e20443f3d6;login=heinki;mod=0;msg-id=raid;msg-param-displayName=Heinki;msg-param-login=heinki;msg-param-viewerCount=4;room-id=27229958;subscriber=0;system-msg=4\sraiders\sfrom\sHeinki\shave\sjoined\n!;tmi-sent-ts=1510249711023;turbo=0;user-id=44110799;user-type= :tmi.twitch.tv USERNOTICE #pandablack
- public RaidNotification(IrcMessage ircMessage)
- {
- foreach (var tag in ircMessage.Tags)
- {
- var tagValue = tag.Value;
- switch (tag.Key)
- {
- case Tags.Badges:
- Badges = TagHelper.ToBadges(tagValue);
- break;
- case Tags.BadgeInfo:
- BadgeInfo = TagHelper.ToBadges(tagValue);
- break;
- case Tags.Color:
- HexColor = tagValue;
- break;
- case Tags.DisplayName:
- DisplayName = tagValue;
- break;
- case Tags.Emotes:
- Emotes = tagValue;
- break;
- case Tags.Login:
- Login = tagValue;
- break;
- case Tags.Mod:
- Moderator = TagHelper.ToBool(tagValue);
- break;
- case Tags.MsgId:
- MsgId = tagValue;
- break;
- case Tags.MsgParamDisplayname:
- MsgParamDisplayName = tagValue;
- break;
- case Tags.MsgParamLogin:
- MsgParamLogin = tagValue;
- break;
- case Tags.MsgParamViewerCount:
- MsgParamViewerCount = tagValue;
- break;
- case Tags.RoomId:
- RoomId = tagValue;
- break;
- case Tags.Subscriber:
- Subscriber = TagHelper.ToBool(tagValue);
- break;
- case Tags.SystemMsg:
- SystemMsg = tagValue;
- SystemMsgParsed = tagValue.Replace("\\s", " ").Replace("\\n", "");
- break;
- case Tags.TmiSentTs:
- TmiSent = TagHelper.ToDateTimeOffsetFromUnixMs(tagValue);
- break;
- case Tags.Turbo:
- Turbo = TagHelper.ToBool(tagValue);
- break;
- case Tags.UserId:
- UserId = tagValue;
- break;
- case Tags.UserType:
- UserType = TagHelper.ToUserType(tag.Value);
- break;
- default:
- (UndocumentedTags = new()).Add(tag.Key, tag.Value);
- break;
- }
- }
- }
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ public RaidNotification(
+ List> badgeInfo,
+ List> badges,
+ string hexColor,
+ string displayMame,
+ string emotes,
+ string id,
+ string login,
+ bool isModerator,
+ string msgId,
+ string roomId,
+ bool isSubscriber,
+ string systemMsg,
+ DateTimeOffset tmiSent,
+ bool isTurbo,
+ string userId,
+ UserType userType,
+ Dictionary? undocumentedTags,
+ string msgParamDisplayName,
+ string msgParamLogin,
+ string msgParamViewerCount)
+ : base(badgeInfo,
+ badges,
+ hexColor,
+ displayMame,
+ emotes,
+ id,
+ login,
+ isModerator,
+ msgId, roomId,
+ isSubscriber,
+ systemMsg,
+ tmiSent,
+ isTurbo,
+ userId,
+ userType,
+ undocumentedTags)
+ {
+ MsgParamDisplayName = msgParamDisplayName;
+ MsgParamLogin = msgParamLogin;
+ MsgParamViewerCount = msgParamViewerCount;
+ }
- public RaidNotification(
- List> badges,
- List> badgeInfo,
- string hexColor,
- string displayName,
- string emotes,
- string id,
- string login,
- bool moderator,
- string msgId,
- string msgParamDisplayName,
- string msgParamLogin,
- string msgParamViewerCount,
- string roomId,
- bool subscriber,
- string systemMsg,
- string systemMsgParsed,
- DateTimeOffset tmiSent,
- bool turbo,
- UserType userType,
- string userId)
+ ///
+ protected override bool TrySet(KeyValuePair tag)
+ {
+ switch (tag.Key)
{
- Badges = badges;
- BadgeInfo = badgeInfo;
- HexColor = hexColor;
- DisplayName = displayName;
- Emotes = emotes;
- Id = id;
- Login = login;
- Moderator = moderator;
- MsgId = msgId;
- MsgParamDisplayName = msgParamDisplayName;
- MsgParamLogin = msgParamLogin;
- MsgParamViewerCount = msgParamViewerCount;
- RoomId = roomId;
- Subscriber = subscriber;
- SystemMsg = systemMsg;
- SystemMsgParsed = systemMsgParsed;
- TmiSent = tmiSent;
- Turbo = turbo;
- UserType = userType;
- UserId = userId;
+ case Tags.MsgParamDisplayname:
+ MsgParamDisplayName = tag.Value;
+ break;
+ case Tags.MsgParamLogin:
+ MsgParamLogin = tag.Value;
+ break;
+ case Tags.MsgParamViewerCount:
+ MsgParamViewerCount = tag.Value;
+ break;
+ default:
+ return false;
}
+ return true;
}
}
diff --git a/TwitchLib.Client.Models/ReSubscriber.cs b/TwitchLib.Client.Models/ReSubscriber.cs
index 7cae3141..c3e98035 100644
--- a/TwitchLib.Client.Models/ReSubscriber.cs
+++ b/TwitchLib.Client.Models/ReSubscriber.cs
@@ -1,72 +1,120 @@
using TwitchLib.Client.Enums;
using TwitchLib.Client.Models.Internal;
-namespace TwitchLib.Client.Models
+namespace TwitchLib.Client.Models;
+
+public class ReSubscriber : UserNoticeBase
{
- public class ReSubscriber : SubscriberBase
+ ///
+ /// The total number of months the user has subscribed.
+ ///
+ public int MsgParamCumulativeMonths { get; protected set; }
+
+ ///
+ /// A Boolean value that indicates whether the user wants their streaks shared.
+ ///
+ public bool MsgParamShouldShareStreak { get; protected set; }
+
+ ///
+ /// The number of consecutive months the user has subscribed.
+ ///
+ public int MsgParamStreakMonths { get; protected set; }
+
+ ///
+ /// The type of subscription plan being used.
+ ///
+ public SubscriptionPlan MsgParamSubPlan { get; protected set; }
+
+ ///
+ /// The display name of the subscription plan. This may be a default name or one created by the channel owner.
+ ///
+ public string MsgParamSubPlanName { get; protected set; } = default!;
+
+ public string ResubMessage { get; }
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ public ReSubscriber(IrcMessage ircMessage) : base(ircMessage)
{
- public int Months => monthsInternal;
+ ResubMessage = ircMessage.Message;
+ }
- public ReSubscriber(IrcMessage ircMessage) : base(ircMessage)
- {
- }
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ public ReSubscriber(
+ List> badgeInfo,
+ List> badges,
+ string hexColor,
+ string displayMame,
+ string emotes,
+ string id,
+ string login,
+ bool isModerator,
+ string msgId,
+ string roomId,
+ bool isSubscriber,
+ string systemMsg,
+ DateTimeOffset tmiSent,
+ bool isTurbo,
+ string userId,
+ UserType userType,
+ Dictionary? undocumentedTags,
+ int msgParamCumulativeMonths,
+ bool msgParamShouldShareStreak,
+ int msgParamStreakMonths,
+ SubscriptionPlan msgParamSubPlan,
+ string msgParamSubPlanName,
+ string resubMessage)
+ : base(badgeInfo,
+ badges,
+ hexColor,
+ displayMame,
+ emotes,
+ id,
+ login,
+ isModerator,
+ msgId, roomId,
+ isSubscriber,
+ systemMsg,
+ tmiSent,
+ isTurbo,
+ userId,
+ userType,
+ undocumentedTags)
+ {
+ MsgParamCumulativeMonths = msgParamCumulativeMonths;
+ MsgParamShouldShareStreak = msgParamShouldShareStreak;
+ MsgParamStreakMonths = msgParamStreakMonths;
+ MsgParamSubPlan = msgParamSubPlan;
+ MsgParamSubPlanName = msgParamSubPlanName;
+ ResubMessage = resubMessage;
+ }
- public ReSubscriber(
- List> badges,
- List> badgeInfo,
- string hexColor,
- string displayName,
- string emoteSet,
- string id,
- string login,
- string systemMessage,
- string msgId,
- string msgParamCumulativeMonths,
- string msgParamStreakMonths,
- bool msgParamShouldShareStreak,
- string systemMessageParsed,
- string resubMessage,
- SubscriptionPlan subscriptionPlan,
- string subscriptionPlanName,
- string roomId,
- string userId,
- bool isModerator,
- bool isTurbo,
- bool isSubscriber,
- bool isPartner,
- DateTimeOffset tmiSent,
- UserType userType,
- string rawIrc,
- string channel,
- int months = 0)
- : base(badges,
- badgeInfo,
- hexColor,
- displayName,
- emoteSet,
- id,
- login,
- systemMessage,
- msgId,
- msgParamCumulativeMonths,
- msgParamStreakMonths,
- msgParamShouldShareStreak,
- systemMessageParsed,
- resubMessage,
- subscriptionPlan,
- subscriptionPlanName,
- roomId,
- userId,
- isModerator,
- isTurbo,
- isSubscriber,
- isPartner,
- tmiSent,
- userType,
- rawIrc,
- channel,
- months)
+ ///
+ protected override bool TrySet(KeyValuePair tag)
+ {
+ switch (tag.Key)
{
+ case Tags.MsgParamCumulativeMonths:
+ MsgParamCumulativeMonths = int.Parse(tag.Value);
+ break;
+ case Tags.MsgParamShouldShareStreak:
+ MsgParamShouldShareStreak = TagHelper.ToBool(tag.Value);
+ break;
+ case Tags.MsgParamStreakMonths:
+ MsgParamStreakMonths = int.Parse(tag.Value);
+ break;
+ case Tags.MsgParamSubPlan:
+ MsgParamSubPlan = TagHelper.ToSubscriptionPlan(tag.Value);
+ break;
+ case Tags.MsgParamSubPlanName:
+ MsgParamSubPlanName = tag.Value;
+ break;
+ default:
+ return false;
}
+ return true;
}
}
diff --git a/TwitchLib.Client.Models/Ritual.cs b/TwitchLib.Client.Models/Ritual.cs
new file mode 100644
index 00000000..aefbf4d0
--- /dev/null
+++ b/TwitchLib.Client.Models/Ritual.cs
@@ -0,0 +1,80 @@
+using TwitchLib.Client.Enums;
+using TwitchLib.Client.Models.Internal;
+
+namespace TwitchLib.Client.Models;
+
+public class Ritual : UserNoticeBase
+{
+ ///
+ /// The name of the ritual being celebrated.
+ ///
+ public string MsgParamRitualName { get; protected set; } = default!;
+
+ public string Message { get; protected set; }
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ public Ritual(IrcMessage ircMessage) : base(ircMessage)
+ {
+ Message = ircMessage.Message;
+ }
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ public Ritual(
+ List> badgeInfo,
+ List> badges,
+ string hexColor,
+ string displayMame,
+ string emotes,
+ string id,
+ string login,
+ bool isModerator,
+ string msgId,
+ string roomId,
+ bool isSubscriber,
+ string systemMsg,
+ DateTimeOffset tmiSent,
+ bool isTurbo,
+ string userId,
+ UserType userType,
+ Dictionary? undocumentedTags,
+ string msgParamRitualName,
+ string message)
+ : base(badgeInfo,
+ badges,
+ hexColor,
+ displayMame,
+ emotes,
+ id,
+ login,
+ isModerator,
+ msgId, roomId,
+ isSubscriber,
+ systemMsg,
+ tmiSent,
+ isTurbo,
+ userId,
+ userType,
+ undocumentedTags)
+ {
+ MsgParamRitualName = msgParamRitualName;
+ Message = message;
+ }
+
+ ///
+ protected override bool TrySet(KeyValuePair tag)
+ {
+ switch (tag.Key)
+ {
+ case Tags.MsgParamRitualName:
+ MsgParamRitualName = tag.Value;
+ break;
+ default:
+ return false;
+ }
+ return true;
+ }
+}
\ No newline at end of file
diff --git a/TwitchLib.Client.Models/RitualNewChatter.cs b/TwitchLib.Client.Models/RitualNewChatter.cs
deleted file mode 100644
index aa34cdd1..00000000
--- a/TwitchLib.Client.Models/RitualNewChatter.cs
+++ /dev/null
@@ -1,124 +0,0 @@
-#nullable disable
-#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
-using TwitchLib.Client.Enums;
-using TwitchLib.Client.Models.Internal;
-
-namespace TwitchLib.Client.Models
-{
- public class RitualNewChatter
- {
- public List> Badges { get; }
-
- public List> BadgeInfo { get; }
-
- public string Color { get; }
-
- public string DisplayName { get; }
-
- public string Emotes { get; }
-
- public string Id { get; }
-
- public bool IsModerator { get; }
-
- public bool IsSubscriber { get; }
-
- public bool IsTurbo { get; }
-
- public string Login { get; }
-
- public string Message { get; }
-
- public string MsgId { get; }
-
- public string MsgParamRitualName { get; }
-
- public string RoomId { get; }
-
- public string SystemMsgParsed { get; }
-
- public string SystemMsg { get; }
-
- public DateTimeOffset TmiSent { get; }
-
- public string UserId { get; }
-
- public UserType UserType { get; }
-
- ///
- /// Contains undocumented tags.
- ///
- public Dictionary? UndocumentedTags { get; }
-
- // badges=subscriber/0;color=#0000FF;display-name=KittyJinxu;emotes=30259:0-6;id=1154b7c0-8923-464e-a66b-3ef55b1d4e50;
- // login=kittyjinxu;mod=0;msg-id=ritual;msg-param-ritual-name=new_chatter;room-id=35740817;subscriber=1;
- // system-msg=@KittyJinxu\sis\snew\shere.\sSay\shello!;tmi-sent-ts=1514387871555;turbo=0;user-id=187446639;
- // user-type= USERNOTICE #thorlar kittyjinxu > #thorlar: HeyGuys
- public RitualNewChatter(IrcMessage ircMessage)
- {
- Message = ircMessage.Message;
- foreach (var tag in ircMessage.Tags)
- {
- var tagValue = tag.Value;
- switch (tag.Key)
- {
- case Tags.Badges:
- Badges = TagHelper.ToBadges(tagValue);
- break;
- case Tags.BadgeInfo:
- BadgeInfo = TagHelper.ToBadges(tagValue);
- break;
- case Tags.Color:
- Color = tagValue;
- break;
- case Tags.DisplayName:
- DisplayName = tagValue;
- break;
- case Tags.Emotes:
- Emotes = tagValue;
- break;
- case Tags.Id:
- Id = tagValue;
- break;
- case Tags.Login:
- Login = tagValue;
- break;
- case Tags.Mod:
- IsModerator = TagHelper.ToBool(tagValue);
- break;
- case Tags.MsgId:
- MsgId = tagValue;
- break;
- case Tags.MsgParamRitualName:
- MsgParamRitualName = tagValue;
- break;
- case Tags.RoomId:
- RoomId = tagValue;
- break;
- case Tags.Subscriber:
- IsSubscriber = TagHelper.ToBool(tagValue);
- break;
- case Tags.SystemMsg:
- SystemMsg = tagValue;
- SystemMsgParsed = tagValue.Replace("\\s", " ").Replace("\\n", "");
- break;
- case Tags.TmiSentTs:
- TmiSent = TagHelper.ToDateTimeOffsetFromUnixMs(tagValue);
- break;
- case Tags.Turbo:
- IsTurbo = TagHelper.ToBool(tagValue);
- break;
- case Tags.UserId:
- UserId = tagValue;
- break;
- case Tags.UserType:
- UserType = TagHelper.ToUserType(tag.Value);
- break;
- default:
- (UndocumentedTags = new()).Add(tag.Key, tag.Value);
- break;
- }
- }
- }
- }
-}
diff --git a/TwitchLib.Client.Models/StandardPayForward.cs b/TwitchLib.Client.Models/StandardPayForward.cs
new file mode 100644
index 00000000..a2c9db4d
--- /dev/null
+++ b/TwitchLib.Client.Models/StandardPayForward.cs
@@ -0,0 +1,114 @@
+using TwitchLib.Client.Enums;
+using TwitchLib.Client.Models.Internal;
+
+namespace TwitchLib.Client.Models;
+
+public class StandardPayForward : UserNoticeBase
+{
+ public bool MsgParamPriorGifterAnonymous { get; protected set; }
+
+ public string MsgParamPriorGifterDisplayName { get; protected set; } = default!;
+
+ public long MsgParamPriorGifterId { get; protected set; }
+
+ public string MsgParamPriorGifterUserName { get; protected set; } = default!;
+
+ public string? MsgParamRecipientDisplayName { get; protected set; }
+
+ public long? MsgParamRecipientId { get; protected set; }
+
+ public string? MsgParamRecipientUserName { get; protected set; }
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ public StandardPayForward(IrcMessage ircMessage) : base(ircMessage)
+ {
+ }
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ public StandardPayForward(
+ List> badgeInfo,
+ List> badges,
+ string hexColor,
+ string displayMame,
+ string emotes,
+ string id,
+ string login,
+ bool isModerator,
+ string msgId,
+ string roomId,
+ bool isSubscriber,
+ string systemMsg,
+ DateTimeOffset tmiSent,
+ bool isTurbo,
+ string userId,
+ UserType userType,
+ Dictionary? undocumentedTags,
+ bool msgParamPriorGifterAnonymous,
+ string msgParamPriorGifterDisplayName,
+ long msgParamPriorGifterId,
+ string msgParamPriorGifterUserName,
+ string? msgParamRecipientDisplayName,
+ long? msgParamRecipientId,
+ string? msgParamRecipientUserName)
+ : base(badgeInfo,
+ badges,
+ hexColor,
+ displayMame,
+ emotes,
+ id,
+ login,
+ isModerator,
+ msgId, roomId,
+ isSubscriber,
+ systemMsg,
+ tmiSent,
+ isTurbo,
+ userId,
+ userType,
+ undocumentedTags)
+ {
+ MsgParamPriorGifterAnonymous = msgParamPriorGifterAnonymous;
+ MsgParamPriorGifterDisplayName = msgParamPriorGifterDisplayName;
+ MsgParamPriorGifterId = msgParamPriorGifterId;
+ MsgParamPriorGifterUserName = msgParamPriorGifterUserName;
+ MsgParamRecipientDisplayName = msgParamRecipientDisplayName;
+ MsgParamRecipientId = msgParamRecipientId;
+ MsgParamRecipientUserName = msgParamRecipientUserName;
+ }
+
+ ///
+ protected override bool TrySet(KeyValuePair tag)
+ {
+ switch (tag.Key)
+ {
+ case Tags.MsgParamPriorGifterAnonymous:
+ MsgParamPriorGifterAnonymous = bool.Parse(tag.Value);
+ break;
+ case Tags.MsgParamPriorGifterDisplayName:
+ MsgParamPriorGifterDisplayName = tag.Value;
+ break;
+ case Tags.MsgParamPriorGifterId:
+ MsgParamPriorGifterId = long.Parse(tag.Value);
+ break;
+ case Tags.MsgParamPriorGifterUserName:
+ MsgParamPriorGifterUserName = tag.Value;
+ break;
+ case Tags.MsgParamRecipientDisplayname:
+ MsgParamRecipientDisplayName = tag.Value;
+ break;
+ case Tags.MsgParamRecipientId:
+ MsgParamRecipientId = long.Parse(tag.Value);
+ break;
+ case Tags.MsgParamRecipientUsername:
+ MsgParamRecipientUserName = tag.Value;
+ break;
+ default:
+ return false;
+ }
+ return true;
+ }
+}
\ No newline at end of file
diff --git a/TwitchLib.Client.Models/Subscriber.cs b/TwitchLib.Client.Models/Subscriber.cs
index 3e6bc8d5..244eba58 100644
--- a/TwitchLib.Client.Models/Subscriber.cs
+++ b/TwitchLib.Client.Models/Subscriber.cs
@@ -1,70 +1,120 @@
using TwitchLib.Client.Enums;
using TwitchLib.Client.Models.Internal;
-namespace TwitchLib.Client.Models
+namespace TwitchLib.Client.Models;
+
+public class Subscriber : UserNoticeBase
{
- public class Subscriber : SubscriberBase
+ ///
+ /// The total number of months the user has subscribed.
+ ///
+ public int MsgParamCumulativeMonths { get; protected set; }
+
+ ///
+ /// A Boolean value that indicates whether the user wants their streaks shared.
+ ///
+ public bool MsgParamShouldShareStreak { get; protected set; }
+
+ ///
+ /// The number of consecutive months the user has subscribed.
+ ///
+ public int MsgParamStreakMonths { get; protected set; }
+
+ ///
+ /// The type of subscription plan being used.
+ ///
+ public SubscriptionPlan MsgParamSubPlan { get; protected set; }
+
+ ///
+ /// The display name of the subscription plan. This may be a default name or one created by the channel owner.
+ ///
+ public string MsgParamSubPlanName { get; protected set; } = default!;
+
+ public string ResubMessage { get; }
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ public Subscriber(IrcMessage ircMessage) : base(ircMessage)
{
- public Subscriber(IrcMessage ircMessage)
- : base(ircMessage)
- {
- }
+ ResubMessage = ircMessage.Message;
+ }
- public Subscriber(
- List> badges,
- List> badgeInfo,
- string hexColor,
- string displayName,
- string emoteSet,
- string id,
- string login,
- string systemMessage,
- string msgId,
- string msgParamCumulativeMonths,
- string msgParamStreakMonths,
- bool msgParamShouldShareStreak,
- string systemMessageParsed,
- string resubMessage,
- SubscriptionPlan subscriptionPlan,
- string subscriptionPlanName,
- string roomId,
- string userId,
- bool isModerator,
- bool isTurbo,
- bool isSubscriber,
- bool isPartner,
- DateTimeOffset tmiSent,
- UserType userType,
- string rawIrc,
- string channel)
- : base(badges,
- badgeInfo,
- hexColor,
- displayName,
- emoteSet,
- id,
- login,
- systemMessage,
- msgId,
- msgParamCumulativeMonths,
- msgParamStreakMonths,
- msgParamShouldShareStreak,
- systemMessageParsed,
- resubMessage,
- subscriptionPlan,
- subscriptionPlanName,
- roomId,
- userId,
- isModerator,
- isTurbo,
- isSubscriber,
- isPartner,
- tmiSent,
- userType,
- rawIrc,
- channel,
- months: 0)
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ public Subscriber(
+ List> badgeInfo,
+ List> badges,
+ string hexColor,
+ string displayMame,
+ string emotes,
+ string id,
+ string login,
+ bool isModerator,
+ string msgId,
+ string roomId,
+ bool isSubscriber,
+ string systemMsg,
+ DateTimeOffset tmiSent,
+ bool isTurbo,
+ string userId,
+ UserType userType,
+ Dictionary? undocumentedTags,
+ int msgParamCumulativeMonths,
+ bool msgParamShouldShareStreak,
+ int msgParamStreakMonths,
+ SubscriptionPlan msgParamSubPlan,
+ string msgParamSubPlanName,
+ string resubMessage)
+ : base(badgeInfo,
+ badges,
+ hexColor,
+ displayMame,
+ emotes,
+ id,
+ login,
+ isModerator,
+ msgId, roomId,
+ isSubscriber,
+ systemMsg,
+ tmiSent,
+ isTurbo,
+ userId,
+ userType,
+ undocumentedTags)
+ {
+ MsgParamCumulativeMonths = msgParamCumulativeMonths;
+ MsgParamShouldShareStreak = msgParamShouldShareStreak;
+ MsgParamStreakMonths = msgParamStreakMonths;
+ MsgParamSubPlan = msgParamSubPlan;
+ MsgParamSubPlanName = msgParamSubPlanName;
+ ResubMessage = resubMessage;
+ }
+
+ ///
+ protected override bool TrySet(KeyValuePair tag)
+ {
+ switch (tag.Key)
{
+ case Tags.MsgParamCumulativeMonths:
+ MsgParamCumulativeMonths = int.Parse(tag.Value);
+ break;
+ case Tags.MsgParamShouldShareStreak:
+ MsgParamShouldShareStreak = TagHelper.ToBool(tag.Value);
+ break;
+ case Tags.MsgParamStreakMonths:
+ MsgParamStreakMonths = int.Parse(tag.Value);
+ break;
+ case Tags.MsgParamSubPlan:
+ MsgParamSubPlan = TagHelper.ToSubscriptionPlan(tag.Value);
+ break;
+ case Tags.MsgParamSubPlanName:
+ MsgParamSubPlanName = tag.Value;
+ break;
+ default:
+ return false;
}
+ return true;
}
}
diff --git a/TwitchLib.Client.Models/SubscriberBase.cs b/TwitchLib.Client.Models/SubscriberBase.cs
deleted file mode 100644
index 27f7253a..00000000
--- a/TwitchLib.Client.Models/SubscriberBase.cs
+++ /dev/null
@@ -1,247 +0,0 @@
-#nullable disable
-using TwitchLib.Client.Enums;
-using TwitchLib.Client.Models.Interfaces;
-using TwitchLib.Client.Models.Internal;
-
-namespace TwitchLib.Client.Models
-{
- /// Class representing a resubscriber.
- public class SubscriberBase : IHexColorProperty
- {
- /// Property representing list of badges assigned.
- public List> Badges { get; }
-
- /// Metadata associated with each badge
- public List> BadgeInfo { get; }
-
- /// Property representing HEX color as a System.Drawing.Color object.
- public string HexColor { get; }
-
- /// Property representing resubscriber's customized display name.
- public string DisplayName { get; }
-
- /// Property representing emote set of resubscriber.
- public string EmoteSet { get; }
-
- /// Property representing resub message id
- public string Id { get; }
-
- /// Property representing whether or not the resubscriber is a moderator.
- public bool IsModerator { get; }
-
- /// Property representing whether or not person is a partner.
- public bool IsPartner { get; }
-
- /// Property representing whether or not the resubscriber is a subscriber (YES).
- public bool IsSubscriber { get; }
-
- /// Property representing whether or not the resubscriber is a turbo member.
- public bool IsTurbo { get; }
-
- /// Property representing login of resubscription event.
- public string Login { get; }
-
- public string MsgId { get; }
-
- public string MsgParamCumulativeMonths { get; }
-
- public bool MsgParamShouldShareStreak { get; }
-
- public string MsgParamStreakMonths { get; }
-
- /// Property representing the raw IRC message (for debugging/customized parsing)
- public string RawIrc { get; }
-
- /// Property representing system message.
- public string ResubMessage { get; }
-
- /// Property representing the room id.
- public string RoomId { get; }
-
- /// Property representing the plan a user is on.
- public SubscriptionPlan SubscriptionPlan { get; } = SubscriptionPlan.NotSet;
-
- /// Property representing the subscription plan name.
- public string SubscriptionPlanName { get; }
-
- /// Property representing internval system message value.
- public string SystemMessage { get; }
-
- /// Property representing internal system message value, parsed.
- public string SystemMessageParsed { get; }
-
- /// Property representing the tmi-sent-ts value.
- public DateTimeOffset TmiSent { get; }
-
- /// Property representing the user's id.
- public string UserId { get; }
-
- /// Property representing the user type of the resubscriber.
- public UserType UserType { get; }
-
- public string Channel { get; }
-
- // @badges=subscriber/1,turbo/1;color=#2B119C;display-name=JustFunkIt;emotes=;id=9dasn-asdibas-asdba-as8as;login=justfunkit;mod=0;msg-id=resub;msg-param-months=2;room-id=44338537;subscriber=1;system-msg=JustFunkIt\ssubscribed\sfor\s2\smonths\sin\sa\srow!;turbo=1;user-id=26526370;user-type= :tmi.twitch.tv USERNOTICE #burkeblack :AVAST YEE SCURVY DOG
-
- protected readonly int monthsInternal;
-
- ///
- /// Contains undocumented tags.
- ///
- public Dictionary? UndocumentedTags { get; }
-
- /// Subscriber object constructor.
- protected SubscriberBase(IrcMessage ircMessage)
- {
- RawIrc = ircMessage.ToString();
- ResubMessage = ircMessage.Message;
-
- foreach (var tag in ircMessage.Tags)
- {
- var tagValue = tag.Value;
- switch (tag.Key)
- {
- case Tags.Badges:
- Badges = TagHelper.ToBadges(tagValue);
- // iterate through badges for special circumstances
- foreach (var badge in Badges)
- {
- if (badge.Key == "partner")
- IsPartner = true;
- }
- break;
- case Tags.BadgeInfo:
- BadgeInfo = TagHelper.ToBadges(tagValue);
- break;
- case Tags.Color:
- HexColor = tagValue;
- break;
- case Tags.DisplayName:
- DisplayName = tagValue;
- break;
- case Tags.Emotes:
- EmoteSet = tagValue;
- break;
- case Tags.Id:
- Id = tagValue;
- break;
- case Tags.Login:
- Login = tagValue;
- break;
- case Tags.Mod:
- IsModerator = TagHelper.ToBool(tagValue);
- break;
- case Tags.MsgId:
- MsgId = tagValue;
- break;
- case Tags.MsgParamCumulativeMonths:
- MsgParamCumulativeMonths = tagValue;
- break;
- case Tags.MsgParamStreakMonths:
- MsgParamStreakMonths = tagValue;
- break;
- case Tags.MsgParamShouldShareStreak:
- MsgParamShouldShareStreak = TagHelper.ToBool(tagValue);
- break;
- case Tags.MsgParamSubPlan:
- SubscriptionPlan = TagHelper.ToSubscriptionPlan(tag.Value);
- break;
- case Tags.MsgParamSubPlanName:
- SubscriptionPlanName = tagValue.Replace("\\s", " ");
- break;
- case Tags.RoomId:
- RoomId = tagValue;
- break;
- case Tags.Subscriber:
- IsSubscriber = TagHelper.ToBool(tagValue);
- break;
- case Tags.SystemMsg:
- SystemMessage = tagValue;
- SystemMessageParsed = tagValue.Replace("\\s", " ");
- break;
- case Tags.TmiSentTs:
- TmiSent = TagHelper.ToDateTimeOffsetFromUnixMs(tagValue);
- break;
- case Tags.Turbo:
- IsTurbo = TagHelper.ToBool(tagValue);
- break;
- case Tags.UserId:
- UserId = tagValue;
- break;
- case Tags.UserType:
- UserType = TagHelper.ToUserType(tag.Value);
- break;
- default:
- (UndocumentedTags = new()).Add(tag.Key, tag.Value);
- break;
- }
- }
- }
-
- internal SubscriberBase(
- List> badges,
- List> badgeInfo,
- string hexColor,
- string displayName,
- string emoteSet,
- string id,
- string login,
- string systemMessage,
- string msgId,
- string msgParamCumulativeMonths,
- string msgParamStreakMonths,
- bool msgParamShouldShareStreak,
- string systemMessageParsed,
- string resubMessage,
- SubscriptionPlan subscriptionPlan,
- string subscriptionPlanName,
- string roomId,
- string userId,
- bool isModerator,
- bool isTurbo,
- bool isSubscriber,
- bool isPartner,
- DateTimeOffset tmiSent,
- UserType userType,
- string rawIrc,
- string channel,
- int months)
- {
- Badges = badges;
- BadgeInfo = badgeInfo;
- HexColor = hexColor;
- DisplayName = displayName;
- EmoteSet = emoteSet;
- Id = id;
- Login = login;
- MsgId = msgId;
- MsgParamCumulativeMonths = msgParamCumulativeMonths;
- MsgParamStreakMonths = msgParamStreakMonths;
- MsgParamShouldShareStreak = msgParamShouldShareStreak;
- SystemMessage = systemMessage;
- SystemMessageParsed = systemMessageParsed;
- ResubMessage = resubMessage;
- SubscriptionPlan = subscriptionPlan;
- SubscriptionPlanName = subscriptionPlanName;
- RoomId = roomId;
- UserId = UserId;
- IsModerator = isModerator;
- IsTurbo = isTurbo;
- IsSubscriber = isSubscriber;
- IsPartner = isPartner;
- TmiSent = tmiSent;
- UserType = userType;
- RawIrc = rawIrc;
- monthsInternal = months;
- UserId = userId;
- Channel = channel;
- }
-
- /// Overriden ToString method, prints out all properties related to resub.
- public override string ToString()
- {
- return $"Badges: {Badges.Count}, color: {HexColor}, display name: {DisplayName}, emote set: {EmoteSet}, login: {Login}, system message: {SystemMessage}, msgId: {MsgId}, msgParamCumulativeMonths: {MsgParamCumulativeMonths}" +
- $"msgParamStreakMonths: {MsgParamStreakMonths}, msgParamShouldShareStreak: {MsgParamShouldShareStreak}, resub message: {ResubMessage}, months: {monthsInternal}, room id: {RoomId}, user id: {UserId}, mod: {IsModerator}, turbo: {IsTurbo}, sub: {IsSubscriber}, user type: {UserType}, raw irc: {RawIrc}";
- }
- }
-}
diff --git a/TwitchLib.Client.Models/UnraidNotification.cs b/TwitchLib.Client.Models/UnraidNotification.cs
new file mode 100644
index 00000000..0147d464
--- /dev/null
+++ b/TwitchLib.Client.Models/UnraidNotification.cs
@@ -0,0 +1,60 @@
+using TwitchLib.Client.Enums;
+using TwitchLib.Client.Models.Internal;
+
+namespace TwitchLib.Client.Models;
+
+public class UnraidNotification : UserNoticeBase
+{
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ public UnraidNotification(IrcMessage ircMessage) : base(ircMessage)
+ {
+ }
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ public UnraidNotification(
+ List> badgeInfo,
+ List> badges,
+ string hexColor,
+ string displayMame,
+ string emotes,
+ string id,
+ string login,
+ bool isModerator,
+ string msgId,
+ string roomId,
+ bool isSubscriber,
+ string systemMsg,
+ DateTimeOffset tmiSent,
+ bool isTurbo,
+ string userId,
+ UserType userType,
+ Dictionary? undocumentedTags)
+ : base(badgeInfo,
+ badges,
+ hexColor,
+ displayMame,
+ emotes,
+ id,
+ login,
+ isModerator,
+ msgId, roomId,
+ isSubscriber,
+ systemMsg,
+ tmiSent,
+ isTurbo,
+ userId,
+ userType,
+ undocumentedTags)
+ {
+ }
+
+ ///
+ protected override bool TrySet(KeyValuePair tag)
+ {
+ return false;
+ }
+}
\ No newline at end of file
diff --git a/TwitchLib.Client.Models/UserNoticeBase.cs b/TwitchLib.Client.Models/UserNoticeBase.cs
new file mode 100644
index 00000000..254072a7
--- /dev/null
+++ b/TwitchLib.Client.Models/UserNoticeBase.cs
@@ -0,0 +1,198 @@
+using TwitchLib.Client.Enums;
+using TwitchLib.Client.Models.Interfaces;
+using TwitchLib.Client.Models.Internal;
+
+namespace TwitchLib.Client.Models;
+
+public abstract class UserNoticeBase : IHexColorProperty
+{
+ internal const string AnonymousGifterUserId = "274598607";
+
+ ///
+ /// Contains metadata related to the chat badges in the tag.
+ ///
+ public List> BadgeInfo { get; protected set; } = default!;
+
+ ///
+ /// List of chat badges.
+ ///
+ public List> Badges { get; protected set; } = default!;
+
+ ///
+ public string HexColor { get; protected set; } = default!;
+
+ ///
+ /// The user’s display name, escaped as described in the IRCv3 spec.
+ ///
+ public string DisplayName { get; protected set; } = default!;
+
+ ///
+ /// List of emotes and their positions in the message.
+ ///
+ public string Emotes { get; protected set; } = default!;
+
+ ///
+ /// An ID that uniquely identifies this message.
+ ///
+ public string Id { get; protected set; } = default!;
+
+ ///
+ /// The login name of the user whose action generated the message.
+ ///
+ public string Login { get; protected set; } = default!;
+
+ ///
+ /// A Boolean value that determines whether the user is a moderator.
+ ///
+ public bool IsModerator { get; protected set; }
+
+ ///
+ /// The type of notice (not the ID).
+ ///
+ public string MsgId { get; protected set; } = default!;
+
+ ///
+ /// An ID that identifies the chat room (channel).
+ ///
+ public string RoomId { get; protected set; } = default!;
+
+ ///
+ /// A Boolean value that determines whether the user is a subscriber.
+ ///
+ public bool IsSubscriber { get; protected set; }
+
+ ///
+ /// The message Twitch shows in the chat room for this notice.
+ ///
+ public string SystemMsg { get; protected set; } = default!;
+
+ ///
+ /// The time for when the Twitch IRC server received the message.
+ ///
+ public DateTimeOffset TmiSent { get; protected set; }
+
+ ///
+ /// A Boolean value that indicates whether the user has site-wide commercial free mode enabled.
+ ///
+ public bool IsTurbo { get; protected set; } //todo HasTurbo?
+
+ ///
+ /// The user’s ID.
+ ///
+ public string UserId { get; protected set; } = default!;
+
+ ///
+ /// he type of user sending the whisper message.
+ ///
+ public UserType UserType { get; protected set; }
+
+ public Dictionary? UndocumentedTags { get; protected set; }
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ protected UserNoticeBase(IrcMessage ircMessage)
+ {
+ foreach (var tag in ircMessage.Tags)
+ {
+ switch (tag.Key)
+ {
+ case Tags.BadgeInfo:
+ BadgeInfo = TagHelper.ToBadges(tag.Value);
+ break;
+ case Tags.Badges:
+ Badges = TagHelper.ToBadges(tag.Value);
+ break;
+ case Tags.Color:
+ HexColor = tag.Value;
+ break;
+ case Tags.DisplayName:
+ DisplayName = tag.Value;
+ break;
+ case Tags.Emotes:
+ Emotes = tag.Value;
+ break;
+ case Tags.Id:
+ Id = tag.Value;
+ break;
+ case Tags.Login:
+ Login = tag.Value;
+ break;
+ case Tags.Mod:
+ IsModerator = TagHelper.ToBool(tag.Value);
+ break;
+ case Tags.MsgId:
+ MsgId = tag.Value;
+ break;
+ case Tags.RoomId:
+ RoomId = tag.Value;
+ break;
+ case Tags.Subscriber:
+ IsSubscriber = TagHelper.ToBool(tag.Value);
+ break;
+ case Tags.SystemMsg:
+ SystemMsg = tag.Value.Replace("\\s", " ");
+ break;
+ case Tags.TmiSentTs:
+ TmiSent = TagHelper.ToDateTimeOffsetFromUnixMs(tag.Value);
+ break;
+ case Tags.Turbo:
+ IsTurbo = TagHelper.ToBool(tag.Value);
+ break;
+ case Tags.UserId:
+ UserId = tag.Value;
+ break;
+ case Tags.UserType:
+ UserType = TagHelper.ToUserType(tag.Value);
+ break;
+ default:
+ if (!TrySet(tag))
+ (UndocumentedTags ??= new()).Add(tag.Key, tag.Value);
+ break;
+ }
+ }
+ }
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ protected UserNoticeBase(
+ List> badgeInfo,
+ List> badges,
+ string hexColor,
+ string displayName,
+ string emotes,
+ string id,
+ string login,
+ bool isModerator,
+ string msgId,
+ string roomId,
+ bool isSubscriber,
+ string systemMsg,
+ DateTimeOffset tmiSent,
+ bool isTurbo,
+ string userId,
+ UserType userType,
+ Dictionary? undocumentedTags)
+ {
+ BadgeInfo = badgeInfo;
+ Badges = badges;
+ HexColor = hexColor;
+ DisplayName = displayName;
+ Emotes = emotes;
+ Id = id;
+ Login = login;
+ IsModerator = isModerator;
+ MsgId = msgId;
+ RoomId = roomId;
+ IsSubscriber = isSubscriber;
+ SystemMsg = systemMsg;
+ TmiSent = tmiSent;
+ IsTurbo = isTurbo;
+ UserId = userId;
+ UserType = userType;
+ UndocumentedTags = undocumentedTags;
+ }
+
+ protected abstract bool TrySet(KeyValuePair tag);
+}