I fixed this problem a while back on my own bot. I crudely striped down my own code and pasted here for sharing. Hopefully you can figure out some of this and apply it to your own bot. I'll try to explain some of it to help.
Basically, the way the code works here is that your bot will only reply
once for mass sub gifting. The way it achieves this is as follows. When a user performs a mass sub gift on Twitch, a message tag of
submysterygift is sent in the message from Twitch saying that a user has mass sub gifted. This message also contains the number of gifted subs in the message tag of
msg-param-mass-gift-count. This script keeps track of that number. Using this info, for each individual sub gift message from Twitch (gifted from the user who mass sub gifted), we reduce this number by one until it reaches zero. This way, the bot knows to only reply once for the mass sub gift message and
not for each individual sub gift message.
If your bot usually performs other tasks when a sub/resub/gift sub happens, you can put that code under the line beginning with "IF (%run_extras) {" near the end of the script. Likewise, any code here will also only run once per sub/resub/gift sub and only once for a mass sub gift.
Of course change the ???????? on line 2 with your own room-id if you use that part of the code. Hope this helps.
RAW USERNOTICE:*: {
IF (($msgtags(room-id).key == ????????) && ($istok(sub resub subgift submysterygift, $msgtags(msg-id).key, 32))) {
VAR %login $msgtags(login).key , %user_id $msgtags(user-id).key , %run_extras $true
IF ($regex($msgtags(display-name).key, /^[a-z\d_]+$/ig)) VAR %name $msgtags(display-name).key
ELSE VAR %name %login
IF ($msgtags(msg-param-sub-plan).key isnum) VAR %tier $calc(($msgtags(msg-param-sub-plan).key)/1000)
ELSE VAR %tier 1
IF (%tier == 1) VAR %points 5000
ELSEIF (%tier == 2) VAR %points 10000
ELSEIF (%tier == 3) VAR %points 25000
IF ($msgtags(msg-id).key == submysterygift) {
VAR %type submysterygift , %num_of_subs $msgtags(msg-param-mass-gift-count).key , %points_per_user %points , %points = %points * %num_of_subs
INC %submysterygift. $+ %name %num_of_subs
MSG $1 blasmaHYPE Successfully added $bytes(%points, b) %curname to %name for gifting %num_of_subs Tier %tier Subscriptions to the community! All gifted users have also received $bytes(%points_per_user, b) %curname each!
ADDPOINTS %name %points
}
ELSEIF ($msgtags(msg-id).key == sub) {
VAR %type sub
MSG $1 blasmaHYPE Successfully added $bytes(%points, b) %curname to %name for their Twitch Subscription at Tier %tier $+ !
ADDPOINTS %name %points
}
ELSEIF ($msgtags(msg-id).key == resub) {
VAR %type resub
MSG $1 blasmaHYPE Successfully added $bytes(%points, b) %curname to %name for their Twitch re-Subscription at Tier %tier $+ !
ADDPOINTS %name %points
}
ELSEIF ($msgtags(msg-id).key == subgift) {
VAR %type subgift , %gifted_to $msgtags(msg-param-recipient-user-name).key , %gifted_to_display_name $msgtags(msg-param-recipient-display-name).key , %gifted_to_id $msgtags(msg-param-recipient-id).key
ADDPOINTS %gifted_to %points
IF (!$($+(%,submysterygift.,%name),2)) {
VAR %resub_msg $IIF($msgtags(msg-param-months).key > 1, It is their $v1 month sub anniversary!, $null)
MSG $1 🎁 %name just GIFTED a Tier %tier Twitch Subscription to %gifted_to_display_name $+ ! %resub_msg $bytes(%points, b) %curname have been added to BOTH %name and %gifted_to_display_name $+ !
ADDPOINTS %name %points
}
ELSE {
VAR %run_extras $false
DEC %submysterygift. [ $+ [ %name ] ]
IF (!$($+(%,submysterygift.,%name),2)) UNSET %submysterygift. [ $+ [ %name ] ]
}
}
IF (%run_extras) {
; extra stuff to do whenever a sub, resub, single gifted sub, or mass sub gift happens (only runs once!)... in other words, this WON'T run for every individual sub during a mass sub gift!
}
}
}