Enum UserNoticeEvent

Source
#[non_exhaustive]
pub enum UserNoticeEvent { SubOrResub { is_resub: bool, cumulative_months: u64, streak_months: Option<u64>, sub_plan: String, sub_plan_name: String, }, Raid { viewer_count: u64, profile_image_url: String, }, SubGift { is_sender_anonymous: bool, cumulative_months: u64, recipient: TwitchUserBasics, sub_plan: String, sub_plan_name: String, num_gifted_months: u64, }, SubMysteryGift { mass_gift_count: u64, sender_total_gifts: u64, sub_plan: String, }, AnonSubMysteryGift { mass_gift_count: u64, sub_plan: String, }, GiftPaidUpgrade { gifter_login: String, gifter_name: String, promotion: Option<SubGiftPromo>, }, AnonGiftPaidUpgrade { promotion: Option<SubGiftPromo>, }, Ritual { ritual_name: String, }, BitsBadgeTier { threshold: u64, }, }
Expand description

A type of event that a UserNoticeMessage represents.

The USERNOTICE command is used for a wide variety of different “rich events” on the Twitch platform. This enum provides parsed variants for a variety of documented type of events.

However Twitch has been known to often add new events without prior notice or even documenting them. For this reason, one should never expect this list to be exhaustive. All events that don’t have a more concrete representation inside this enum get parsed as a UserNoticeEvent::Unknown (which is hidden from the documentation on purpose): You should always use the _ rest-branch and event_id when manually parsing other events.

let message = UserNoticeMessage::try_from(IRCMessage::parse("@badge-info=subscriber/2;badges=subscriber/2,bits/1000;color=#FF4500;display-name=whoopiix;emotes=;flags=;id=d2b32a02-3071-4c52-b2ce-bc3716acdc44;login=whoopiix;mod=0;msg-id=bitsbadgetier;msg-param-threshold=1000;room-id=71092938;subscriber=1;system-msg=bits\\sbadge\\stier\\snotification;tmi-sent-ts=1594520403813;user-id=104252055;user-type= :tmi.twitch.tv USERNOTICE #xqcow").unwrap()).unwrap();
match &message.event {
    UserNoticeEvent::BitsBadgeTier { threshold } => println!("{} just unlocked the {} bits badge!", message.sender.name, threshold),
    _ => println!("some other type of event: {}", message.event_id)
}

This enum is also marked as #[non_exhaustive] to signify that more events may be added to it in the future, without the need for a breaking release.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

SubOrResub

Emitted when a user subscribes or resubscribes to a channel. The user sending this USERNOTICE is the user subscribing/resubscribing.

For brevity this event captures both sub and resub events because they both carry the exact same parameters. You can differentiate between the two events using is_resub, which is false for sub and true for resub events.

Fields

§is_resub: bool

Indicates whether this is a first-time sub or a resub.

§cumulative_months: u64

Cumulative number of months the sending user has subscribed to this channel.

§streak_months: Option<u64>

Consecutive number of months the sending user has subscribed to this channel.

§sub_plan: String

Prime, 1000, 2000 or 3000, referring to Prime or tier 1, 2 or 3 subs respectively.

§sub_plan_name: String

A name the broadcaster configured for this sub plan, e.g. The Ninjas or Channel subscription (nymn_hs)

§

Raid

Incoming raid to a channel. The user sending this USERNOTICE message is the user raiding this channel.

Fields

§viewer_count: u64

How many viewers participated in the raid and just raided this channel.

§profile_image_url: String

A link to the profile image of the raiding user. This is not officially documented Empirical evidence suggests this is always the 70x70 version of the full profile picture.

E.g. https://static-cdn.jtvnw.net/jtv_user_pictures/cae3ca63-510d-4715-b4ce-059dcf938978-profile_image-70x70.png

§

SubGift

Indicates a gifted subscription.

This event combines subgift and anonsubgift. In case of anonsubgift the sending user of the USERNOTICE carries no useful information, it can be e.g. the channel owner or a service user like AnAnonymousGifter. You should always check for is_sender_anonymous before using the sender of the USERNOTICE.

Fields

§is_sender_anonymous: bool

Indicates whether the user sending this USERNOTICE is a dummy or a real gifter. If this is true the gift comes from an anonymous user, and the user sending the USERNOTICE carries no useful information and should be ignored.

§cumulative_months: u64

Cumulative number of months the recipient has subscribed to this channel.

§recipient: TwitchUserBasics

The user that received this gifted subscription or resubscription.

§sub_plan: String

1000, 2000 or 3000, referring to tier 1, 2 or 3 subs respectively.

§sub_plan_name: String

A name the broadcaster configured for this sub plan, e.g. The Ninjas or Channel subscription (nymn_hs)

§num_gifted_months: u64

number of months in a single multi-month gift.

§

SubMysteryGift

This event precedes a wave of subgift/anonsubgift messages. (<User> is gifting <mass_gift_count> Tier 1 Subs to <Channel>'s community! They've gifted a total of <sender_total_gifts> in the channel!)

This event combines submysterygift and anonsubmysterygift. In case of anonsubmysterygift the sending user of the USERNOTICE carries no useful information, it can be e.g. the channel owner or a service user like AnAnonymousGifter. You should always check for is_sender_anonymous before using the sender of the USERNOTICE.

Fields

§mass_gift_count: u64

Indicates whether the user sending this USERNOTICE is a dummy or a real gifter. If this is true the gift comes from an anonymous user, and the user sending the USERNOTICE carries no useful information and should be ignored. Number of gifts the sender just gifted.

§sender_total_gifts: u64

Total number of gifts the sender has gifted in this channel. This includes the number of gifts in this submysterygift or anonsubmysterygift. Note tha

§sub_plan: String

The type of sub plan the recipients were gifted. 1000, 2000 or 3000, referring to tier 1, 2 or 3 subs respectively.

§

AnonSubMysteryGift

This event precedes a wave of subgift/anonsubgift messages. (An anonymous user is gifting <mass_gift_count> Tier 1 Subs to <Channel>'s community!)

This is a variant of submysterygift where the sending user is not known. Not that even though every USERNOTICE carries a sending user, the sending user of this type of USERNOTICE carries no useful information, it can be e.g. the channel owner or a service user like AnAnonymousGifter.

Compared to submysterygift this does not provide sender_total_gifts.

Fields

§mass_gift_count: u64

Number of gifts the sender just gifted.

§sub_plan: String

The type of sub plan the recipients were gifted. 1000, 2000 or 3000, referring to tier 1, 2 or 3 subs respectively.

§

GiftPaidUpgrade

Occurs when a user continues their gifted subscription they got from a non-anonymous gifter.

The sending user of this USERNOTICE is the user upgrading their sub. The user that gifted the original gift sub is specified by these params.

Fields

§gifter_login: String

User that originally gifted the sub to this user. This is the login name, see TwitchUserBasics for more info about the difference between id, login and name.

§gifter_name: String

User that originally gifted the sub to this user. This is the (display) name name, see TwitchUserBasics for more info about the difference between id, login and name.

§promotion: Option<SubGiftPromo>

Present if this gift/upgrade is part of a Twitch gift sub promotion, e.g. Subtember or similar.

§

AnonGiftPaidUpgrade

Occurs when a user continues their gifted subscription they got from an anonymous gifter.

The sending user of this USERNOTICE is the user upgrading their sub.

Fields

§promotion: Option<SubGiftPromo>

Present if this gift/upgrade is part of a Twitch gift sub promotion, e.g. Subtember or similar.

§

Ritual

A user is new in a channel and uses the rituals feature to send a message letting the chat know they are new. <Sender> is new to <Channel>'s chat! Say hello!

Fields

§ritual_name: String

currently only valid value: new_chatter

§

BitsBadgeTier

When a user cheers and earns himself a new bits badge with that cheer (e.g. they just cheered more than/exactly 10000 bits in total, and just earned themselves the 10k bits badge)

Fields

§threshold: u64

tier of bits badge the user just earned themselves, e.g. 10000 if they just earned the 10k bits badge.

Trait Implementations§

Source§

impl Clone for UserNoticeEvent

Source§

fn clone(&self) -> UserNoticeEvent

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for UserNoticeEvent

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for UserNoticeEvent

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for UserNoticeEvent

Source§

fn eq(&self, other: &UserNoticeEvent) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for UserNoticeEvent

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Eq for UserNoticeEvent

Source§

impl StructuralPartialEq for UserNoticeEvent

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> ErasedDestructor for T
where T: 'static,