Get recipient and months of masssubgift recipients

Hi, short question:
On a mass subgift event, is there a way to get the recipients names and months? I would need that data for an extension module.
Thanks ^^

Not reliably. Twitch sends a single message saying User has just sent # gift subs! and then sends individual User just gifted a sub to X! messages. While you could try to correlate them as best as you can, there is no guarantee that the # gift messages occurring after the first message is actually part of that mass-gift event, especially if it’s anonymous.

But how do the other Services managed to handle Stream-Mass-Gifts? At least for the Activity-History

Ok, thats fine for me, because I don’t need to correlate the recipients with the specific mass-gift event. But it seems like I can’t get the correct months value on normal sub gift events too.

I noticed that the line for the getMonths() method in TwitchSubscriptionGiftEvent.java is different from the other sub events scripts.

For resubs and also for regular/prime subs (for which I added the getMonths() method, my pull request was merged a couple months ago) it looks like this:

public String getMonths() {
    return this.months;
}

while in TwitchSubscriptionGiftEvent.java it looks like this:

public String getMonths() {
    return (this.months == null) ? "1" : this.months;
}

Could that be the problem and be solved by changing this line? I’m still new to this stuff, sorry if thats a dumb question.

They just take the events in order and assume that the next X gift subs that have giver Y’s name are from the same event. Nobody can guarantee that the correlation is correct

The getMonths in TwitchSubscriptionGiftEvent is fine. It will return the number of months Twitch gives the bot whenever possible. The null check is just to ensure something valid is returned if Twitch fails to provide a number. Therefore, if you are getting the wrong number of months for a Gifted sub, it is 100% Twitch’s fault.

See:

Twitch IRCv3 Tags Documentation, scroll about halfway down and find the entry about msg-param-months

But can I easily get the months or sub-status of a user, if he types in a command? That would help me for my custom script.

If the user types in chat you can pull the IRCv3 tag badge-info to get the total months subscribed.

In a ircChannelMessage or command hook on the bot you can pull this with event.getTags().get('badge-info')

Thanks, that would work too. I knew about badge-info, but I thought it would just return the badge type (1, 3, 6, 9, 12,… month), not the actual accurate number of months. Thanks for clearing that up.

The badge tag is the one that indicates badge type

Very Cool :slight_smile: thanks.