; A Basic Script for Subscriber Notifications in mIRC (May 17, 2019)
; by twitch.tv/Blasman13
; $MSGTAG HELP: https://dev.twitch.tv/docs/irc/tags/#usernotice-twitch-tags
; You can find your Twitch User ID that is needed on the the third line (YOUR_TWITCH_USERID) of the actual script below here: https://bashtech.net/twitch/profile.php
; note that some rarer sub alerts aren't covered here (giftpaidupgrade, rewardgift, anongiftpaidupgrade)
RAW USERNOTICE:*: {
; look for any notices directed at your Twitch channel && are subscription related
IF (($msgtags(room-id).key == YOUR_TWITCH_USERID) && ($istok(sub resub subgift submysterygift, $msgtags(msg-id).key, 32))) {
; gather variables for the rest of your script
VAR %run_extras $true
VAR %name $IIF($regex($msgtags(display-name).key, /^[a-z\d_]+$/ig), $msgtags(display-name).key, $msgtags(login).key)
VAR %msg-id $msgtags(msg-id).key
VAR %msg-param-cumulative-months $msgtags(msg-param-cumulative-months).key
VAR %msg-param-months $msgtags(msg-param-months).key
VAR %msg-param-streak-months $msgtags(msg-param-streak-months).key
VAR %msg-param-sub-plan $IIF($msgtags(msg-param-sub-plan).key isnum, $calc($msgtags(msg-param-sub-plan).key/1000), $msgtags(msg-param-sub-plan).key)
; MASS SUB GIFTER ALERT: thank the person who gifted the subs and prevent messages for each individual sub
IF (%msg-id == submysterygift) {
VAR %msg-param-mass-gift-count $msgtags(msg-param-mass-gift-count).key
INC %submysterygift. $+ %name %msg-param-mass-gift-count
MSG $1 %name just gifted %msg-param-mass-gift-count tier %msg-param-sub-plan subscriptions to the community!
}
; NEW SUBSCRIBER ALERT
ELSEIF (%msg-id == sub) {
IF (%msg-param-sub-plan isnum) MSG $1 %name just subscribed at tier %msg-param-sub-plan $+ !
ELSEIF (%msg-param-sub-plan == Prime) MSG $1 %name just subscribed with Twitch Prime!
}
; RE-SUBSCRIBER ALERT
ELSEIF (%msg-id == resub) {
IF (%msg-param-sub-plan isnum) VAR %msg_resub %name just re-subscribed at tier %msg-param-sub-plan $+ $chr(44)
ELSEIF (%msg-param-sub-plan == Prime) VAR %msg_resub %name just re-subscribed using Twitch Prime $+ $chr(44)
IF (%msg-param-cumulative-months > 1) VAR %msg_resub %msg_resub and has been subscribed for a total of %msg-param-cumulative-months months $+ $chr(44)
IF (%msg-param-streak-months > 1) VAR %msg_resub %msg_resub and is on a %msg-param-streak-months month sub streak $+ $chr(44)
MSG $1 $left(%msg_resub,-1) $+ !
}
; GIFTED SUB (single only) ALERT
ELSEIF (%msg-id == subgift) {
; if the Twitch notice is NOT the result of a MASS SUB GIFT
IF (!$($+(%,submysterygift.,%name),2)) {
VAR %name_gifted_to $IIF($regex($msgtags(msg-param-recipient-display-name).key, /^[a-z\d_]+$/ig), $msgtags(msg-param-recipient-display-name).key, $msgtags(msg-param-recipient-user-name).key)
MSG $1 %name just GIFTED a tier %tier subscription to %gifted_to_display_name $+ ! $IIF(%msg-param-months > 1, It is their %msg-param-months month sub anniversary!, $null)
}
; if the Twitch notice IS the result of a MASS SUB GIFT, then we display NOTHING for each individual sub
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!
}
}
}