mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Nov 2017
Posts: 8
Y
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
Y
Joined: Nov 2017
Posts: 8
Hi there.

I'm trying to consolidate scripts I've found online so when someone Subscribes through any of the Sub options, Prime, Donation Sub and the paid versions that an Auto message will show.

Here's the script I've got to so far but it's not triggering.

I'm not sure what I'm missing ?

Quote:
ON *:CONNECT: {
raw CAP REQ :twitch.tv/membership
raw CAP REQ :twitch.tv/commands
raw CAP REQ :twitch.tv/tags
}


on *:text:*subscribed*:#CHANNELNAME: {
if ($chan == #CHANNELNAME) && ($nick == twitchnotify))
msg $chan Wooo! SUB HYPE!!! Nice one !!! INSERT EMOTES HERE
}

Last edited by YoureNowOnTV; 01/12/17 05:22 AM.
Joined: Sep 2015
Posts: 101
Vogon poet
Offline
Vogon poet
Joined: Sep 2015
Posts: 101
Quote:
Code:
on *:text:*subscribed*:#CHANNELNAME: { 
if ($chan == #CHANNELNAME) && ($nick == twitchnotify))
msg $chan Wooo! SUB HYPE!!! Nice one !!! INSERT EMOTES HERE 
}


replace with:

Code:
on *:text:*:#CHANNELNAME: { 
if (subscribed isin $1-) && ($nick == twitchnotify) msg # Wooo! SUB HYPE!!! Nice one !!! INSERT EMOTES HERE 
}

Joined: Nov 2017
Posts: 8
Y
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
Y
Joined: Nov 2017
Posts: 8
Awesome thank you! I’ll give that a try.

Questions for a base understanding of the parameters:

So does the remote identifier $1- refer to the whole entry from the $nick ?

So if anything in the twitchnotify comment is “subscribed” then it will go to the msg I set?

Does the # self refer to the #CHANNELNAME section?

Thanks again this information is greatly appreciated!

Joined: Jan 2004
Posts: 2,127
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 2,127
1. The $1- identifier in ON TEXT contains all the parameters from $1 through the end of the line. You can verify what is in these variables by inserting debug messages within the script like:

echo $chan nick $nick debug: 1- is: $1-

2. Yes, (subscribed isin $1-) is the same thing as searching for wildcard *subscribed* within the $1- string. This is not searching for a whole word, so this would also match a line containing unsubscribed.

If it's possible for nick twitchnotify to say the word unsubscribed, and if the word subscribed is never touching anything besides a space, you can match only the whole word subscribed with:

Code:
on *:text:*:#CHANNELNAME: { 
if ($istok($1-,subscribed,32)) && ($nick == twitchnotify) msg # Wooo! SUB HYPE!!! Nice one !!! INSERT EMOTES HERE 
}


32 is ASCII number of the space character, so $istok is looking for an exact match of the entire space-delimited word.

3. Inside the TEXT event, $chan and # both mean the same thing, and refers to the channel where the TEXT event happened. In the top line of the event where :#CHANNELNAME: is located, that decides which channels will cause this code to be triggered. If you changed that to :#: it would respond to all channels.

Joined: Nov 2017
Posts: 8
Y
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
Y
Joined: Nov 2017
Posts: 8
Hmmmm it's not triggering with the altered script.

Joined: Oct 2015
Posts: 112
B
Vogon poet
Offline
Vogon poet
B
Joined: Oct 2015
Posts: 112
Matching the word "subscribe" is not going to work for gifted subs. The system message is "User1 gifted a $4.99 sub to User2!"

I think it makes much more sense to just read the RAW data being sent from Twitch in your case. More info can be found here. Note that as of this writing the official Twitch docs linked here don't have the "subgift" message tag documented yet, but I did cover the new tags in a previous thread on here already.

Two examples. I prefer the first one because it will match exactly the following message tags in "msg-id": sub, resub, or subgift. The second example would work by matching the word "sub" in the "msg-id" tag because they all have "sub" in the tag.

Code:
RAW USERNOTICE:*: {
  IF (($1 == #CHANNELNAME) && (($msgtags(msg-id).key == sub) || ($msgtags(msg-id).key == resub) || ($msgtags(msg-id).key == subgift))) {
    MSG $1 Wooo! SUB HYPE!!! Nice one !!! INSERT EMOTES HERE
  }
}


Code:
RAW USERNOTICE:*: {
  IF (($1 == #CHANNELNAME) && (sub isin $msgtags(msg-id).key)) {
    MSG $1 Wooo! SUB HYPE!!! Nice one !!! INSERT EMOTES HERE
  }
}


Using the message tags you can figure out how to make your bot say things like "User1 just subscribed with a Tier 1 Sub!" Etc.

Joined: Nov 2017
Posts: 8
Y
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
Y
Joined: Nov 2017
Posts: 8
Thank you so much ! this is perfect. Just what I wanted to achieve.

Legend !

Thanks to all who have helped BTW smile

Joined: Dec 2018
Posts: 1
M
Mostly harmless
Offline
Mostly harmless
M
Joined: Dec 2018
Posts: 1
The problem now is:
when someone gifts 50 subs, it sends 50 messages xd
How to fix this?

Joined: Oct 2017
Posts: 14
K
Kex Offline
Pikka bird
Offline
Pikka bird
K
Joined: Oct 2017
Posts: 14
Link i think this can be a fix

Last edited by Kex; 19/12/18 04:33 PM.
Joined: Oct 2015
Posts: 112
B
Vogon poet
Offline
Vogon poet
B
Joined: Oct 2015
Posts: 112
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.

Code:
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!
    }
  }
}

Joined: Jan 2019
Posts: 2
L
Bowl of petunias
Offline
Bowl of petunias
L
Joined: Jan 2019
Posts: 2
Hi Blas, thanks that u share ur script. But i have a question about it. I have delete only the Points and the script doesn't react to anything.

Code:
on *:LOGON:*:{
  raw CAP REQ :twitch.tv/membership
  raw CAP REQ :twitch.tv/tags
  raw CAP REQ :twitch.tv/commands
  /debug @USERNOTICE
}

RAW USERNOTICE:*: {
  IF (($msgtags(room-id).key == 103495737) && ($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 ($msgtags(msg-id).key == submysterygift) {
      VAR %type submysterygift , %num_of_subs $msgtags(msg-param-mass-gift-count).key
      INC %submysterygift. $+ %name %num_of_subs
      MSG $1 shoxx91Herzz %name shoxx91Herzz Danke für deine %num_of_subs Subs im %tier . shoxx911bomb Bitte bedankt euch! shoxx911hype
      MSG $1 shoxx91Herzz shoxx91Herzz shoxx911bomb shoxx911bomb shoxx911bomb shoxx911bomb shoxx911bomb shoxx911bomb shoxx911hype shoxx91Herzz shoxx91Herzz
      MSG $1 shoxx91Herzz shoxx91Herzz shoxx911bomb shoxx911bomb shoxx911bomb shoxx911bomb shoxx911bomb shoxx911bomb shoxx911hype shoxx91Herzz shoxx91Herzz
    }
    ELSEIF ($msgtags(msg-id).key == sub) {
      VAR %type sub
      MSG $1 shoxx91Herzz shoxx91Herzz Danke %name für deinen Sub im Tier %tier $+ !
      MSG $1 shoxx91Herzz shoxx91Herzz shoxx911hype shoxx91SHype shoxx91SHype shoxx91SHype shoxx91SHype shoxx91SHype shoxx911hype shoxx91Herzz shoxx91Herzz
      MSG $1 shoxx91Herzz shoxx91Herzz shoxx911hype shoxx91SHype shoxx91SHype shoxx91SHype shoxx91SHype shoxx91SHype shoxx911hype shoxx91Herzz shoxx91Herzz
    }
    ELSEIF ($msgtags(msg-id).key == resub) {
      VAR %type resub
      MSG $1 shoxx91Herzz %name shoxx91Herzz Danke für deinen ReSub im Tier %tier $+ shoxx91Herzz shoxx91Herzz !
      MSG $1 shoxx91Herzz shoxx91Herzz shoxx911hype shoxx91SHype shoxx91SHype shoxx91SHype shoxx91SHype shoxx91SHype shoxx911hype shoxx91Herzz shoxx91Herzz
      MSG $1 shoxx91Herzz shoxx91Herzz shoxx911hype shoxx91SHype shoxx91SHype shoxx91SHype shoxx91SHype shoxx91SHype shoxx911hype shoxx91Herzz shoxx91Herzz
    }
    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
      IF (!$($+(%,submysterygift.,%name),2)) {
        VAR %resub_msg $IIF($msgtags(msg-param-months).key > 1, It is their $v1 month sub anniversary!, $null)
        MSG $1 🎁 shoxx91Herzz %name shoxx91Herzz Verschenkt einen Tier %tier Sub an %gifted_to_display_name $+ ! shoxx91Herzz shoxx91Herzz
        MSG $1 shoxx91Herzz shoxx91Herzz shoxx911hype shoxx91SHype shoxx91SHype shoxx91SHype shoxx91SHype shoxx91SHype shoxx911hype shoxx91Herzz shoxx91Herzz
        MSG $1 shoxx91Herzz shoxx91Herzz shoxx911hype shoxx91SHype shoxx91SHype shoxx91SHype shoxx91SHype shoxx91SHype shoxx911hype shoxx91Herzz shoxx91Herzz
      }
      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!
    }
  }
}


In line 32 "MSG $1 🎁" is this the channel id too? and can u help me to add a bits hype?

The other thing is. I wish me a output like that:
"Thanks USERNAME for your TIER resub in MONTH"

i have too add "$msgtags(msg-param-months).key"?

My Script have too look like this?
Code:
    ELSEIF ($msgtags(msg-id).key == resub) {
      VAR %type resub , $replace($msgtags(msg-param-sub-plan).key
      MSG $1 Thanks %name for your %tier ReSub in $msgtags(msg-param-sub-plan).key Monath $+ !
    }


or i'm totally wrong?


Link Copied to Clipboard