Chat v2 updated message tags
Home » Developers » BlushyFace.Twitch examples & updates » Chat v2 updated message tags

Chat v2 updated message tags

Updated the message tags for various IRC commands to return proper data types.

The old way to get the message tag values was to manually parse each tag individually for example when someone subscribes a USERNOTICE event gets fired and to get the streak months and sub plan you could either get it from the system message ( x.GetTagValue(“system-msg”) ) or individual tags x.GetTagValue(“msg-param-streak-months”) and x.GetTagValue(“msg-param-sub-plan”). This was not ideal so to do this now follow the example below.

Example #1 handle (re)subs
(re)sub are handled in USERNOTICE events. If there is a new subscriber, send a message in chat that a new sub has joined the sub club, if the subscriber has subbed between 2 and 12 months send a message in chat that they have subbed x months and finally if the subscriber has subbed for over a year tell them they have subbed for over a year.

The x.Tags.GetSubscriber(); method contains all the relevant (re)sub info such as the user who subbed, how many months, is it a sub streak, type of sub (prime, tier 1 / 2 / 3) etc.

var subscriber = e.Tags.GetSubscriber();
switch (subscriber.Months)
{
    case 1:
        await client.SendMessage(e.Channel, $"{subscriber.UserName} thanks for the {subscriber.PlanName} sub and welcome to the sub club!");
        break;
    case { } months when (months >= 2 && months < 12):
        await client.SendMessage(e.Channel, $"Wow {subscriber.UserName} thanks for subscribing for {subscriber.Months} months!");
        break;
    case { } months when (months >= 12):
        await client.SendMessage(e.Channel, $"Wow {subscriber.UserName} thanks for subscribing for over a year!");
        break;
}

 

Example #2 handle cheers
Cheers are handled in the PRIVMSG events. For example thank a viewer in chat that has cheered.

var bits = e.Tags.GetBits();
if (bits >= 10000)
    await client.SendMessage(e.Channel, $"Wow {e.UserName} thanks for cheering {bits} bits!");


 

USERNOTICE types that are handled
– Sub
– Resub
– Subgift
– Anonsubgift
– Submysterygift
– Giftpaidupgrade
– Rewardgift
– Anongiftpaidupgrade
– Raid
– Unraid
– Ritual
– Bitsbadgetier
– Primepaidupgrade
– Standardpayforward

I’m aware that not every type is handled (the ones from the Twitch doc are covered though) but I will add them when I encounter them.

 

Updated tag changes applies to
– CLEARCHAT
– CLEARMSG
– GLOBALUSERSTATE
– PRIVMSG
– ROOMSTATE
– USERNOTICE
– USERSTATE

 

Requires
– BlushyFace.Twitch.Chat.V2.Chat

BlushyFace

Herrow, I'm BlushyFace and here you can find things I've made for our awesome community.

Got an idea or suggestion that would be cool for me to draw / create and to add to the site? Let me know in our Discord!

Notify of
guest

This site uses Akismet to reduce spam. Learn how your comment data is processed.

0 Comments
Inline Feedbacks
View all comments
LIVE NOW! CLICK TO VIEW.
CURRENTLY OFFLINE