mIRC Home    About    Download    Register    News    Help

Print Thread
#264611 20/12/18 10:12 PM
Joined: Dec 2018
Posts: 53
T
TroyL Offline OP
Babel fish
OP Offline
Babel fish
T
Joined: Dec 2018
Posts: 53
So to sum it up i have the following code in a channel on Twitch
Code:
raw USERNOTICE:*:{
  if (($msgtags(msg-id).key == sub) && ($msgtags(room-id).key == 30084163)) {
    var %nick $iif($msgtags(display-name).key, $v1, $msgtags(login).key)
    var %sub-plan $replace($msgtags(msg-param-sub-plan).key, 1000, $chr(36) $+ 4.99, 2000, $chr(36) $+ 9.99, 3000, $chr(36) $+ 24.99, Prime, Prime)
    msg $1 /me agonySUB NEW SUB!! agonySUB Thank You %nick For Subscribing With A %sub-plan Sub! Welcome To The Legends! agonyHYPERS bingAw
    
  }
if (($msgtags(msg-id).key == resub) && ($msgtags(room-id).key == 30084163)) {
    var %nick $iif($msgtags(display-name).key, $v1, $msgtags(login).key)
    VAR %sub-plan $replace($msgtags(msg-param-sub-plan).key, 1000, $chr(36) $+ 4.99, 2000, $chr(36) $+ 9.99, 3000, $chr(36) $+ 24.99, Prime, Prime) 
    msg $1 /me bingAw RESUB!! rooAww %nick Has Just Resubscribed For $msgtags(msg-param-months).key Months In A Row With A %sub-plan Sub! Welcome Back To The Legends! bingAw rooAww
    
  }
if (($msgtags(msg-id).key == subgift) && ($msgtags(room-id).key == 30084163)) {  
    var %nick_from $iif($msgtags(display-name).key, $v1, $msgtags(login).key) , %nick_to $iif($msgtags(msg-param-recipient-display-name).key, $v1, $msgtags(msg-param-recipient-user-name).key)
    VAR %sub-plan $replace($msgtags(msg-param-sub-plan).key, 1000, $chr(36) $+ 4.99, 2000, $chr(36) $+ 9.99, 3000, $chr(36) $+ 24.99)
    msg $1 /me rooGift GIFTED SUB!! rooGift Thank you %nick_from For Gifting A %sub-plan Sub To %nick_to $+ ! Welcome To The Legends! rooGift rooGift
    
  }

And it works perfectly at announcing subs but the problem is it doesnt announce mass gifted sub. For example last night someone gifted 40 subs and my bot only announced 30. Any help?

Joined: Jan 2004
Posts: 2,127
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 2,127
I altered your code slightly.

1. I added 1 check at the top which makes this handler ignore everything without the correct room key. This avoids the need to keep checking if the room key is correct.

2. I then added something that displays incoming messages to a @Subs window. If I didn't add everything, you can easily add additional debug display info. I don't know the format, but it would be nice to show the entire USERNOTICE as well, as a separate echo to @Subs. This should allow you to see whether there was a problem with the script, or in fact you did not receive a server message showing the other subs.

3. I changed the format of the event handler into having the later IF statements using the ELSE logic. It looks like your handler is looking for 3 specific values for the msg-id.key, so this way you can identify any usermessages that had a different string which should be handled but did not.

4. The code you pasted was missing the brace at the very end, so I added it. Hopefully it's already there in your code, which you can verify by either pressing Ctrl+H in the scripts editor, or clicking the checkmark icon in the upper right corner.

5. I vaguely recall forum posts mentioning certain situations where twitch blocks flooding messages, but I'm not sure whether that was messages received-by the channel owner or messages made-by the owner. Instead of using the -t switch where echo would use the 'timestamp' format, I used $time which shows the seconds. This lets you see if subs messages come in a burst or are spaced seconds apart.


Code:
raw USERNOTICE:*:{
  if ($msgtags(room-id).key != 30084163) return
  if (!$window(@Subs)) window @Subs
  echo $+([,$time,]) @Subs msg-id.key $msgtags(msg-id).key display-name.key: $msgtags(display-name).key msg-param-sub-plan.key: $msgtags(msg-param-sub-plan).key

  if ($msgtags(msg-id).key == sub) {
    var %nick $iif($msgtags(display-name).key, $v1, $msgtags(login).key)
    var %sub-plan $replace($msgtags(msg-param-sub-plan).key, 1000, $chr(36) $+ 4.99, 2000, $chr(36) $+ 9.99, 3000, $chr(36) $+ 24.99, Prime, Prime)
    msg $1 /me agonySUB NEW SUB!! agonySUB Thank You %nick For Subscribing With A %sub-plan Sub! Welcome To The Legends! agonyHYPERS bingAw

  }
  elseif ($msgtags(msg-id).key == resub) {
    var %nick $iif($msgtags(display-name).key, $v1, $msgtags(login).key)
    VAR %sub-plan $replace($msgtags(msg-param-sub-plan).key, 1000, $chr(36) $+ 4.99, 2000, $chr(36) $+ 9.99, 3000, $chr(36) $+ 24.99, Prime, Prime)
    msg $1 /me bingAw RESUB!! rooAww %nick Has Just Resubscribed For $msgtags(msg-param-months).key Months In A Row With A %sub-plan Sub! Welcome Back To The Legends! bingAw rooAww
  }
  elseif ($msgtags(msg-id).key == subgift) {
    var %nick_from $iif($msgtags(display-name).key, $v1, $msgtags(login).key) , %nick_to $iif($msgtags(msg-param-recipient-display-name).key, $v1, $msgtags(msg-param-recipient-user-name).key)
    VAR %sub-plan $replace($msgtags(msg-param-sub-plan).key, 1000, $chr(36) $+ 4.99, 2000, $chr(36) $+ 9.99, 3000, $chr(36) $+ 24.99)
    msg $1 /me rooGift GIFTED SUB!! rooGift Thank you %nick_from For Gifting A %sub-plan Sub To %nick_to $+ ! Welcome To The Legends! rooGift rooGift
  }
  else {
    echo 4 @Subs Warning: The above message was not handled.
  }
}

Joined: Dec 2018
Posts: 53
T
TroyL Offline OP
Babel fish
OP Offline
Babel fish
T
Joined: Dec 2018
Posts: 53
Thank you! Do i need to add anything to this or is it fine the way it is? Another thing is what is the sub window for and i gifted a sub and it said "Warning: the above message was not handled." What does that mean? What does this script do? Does it speed up the announcement or does it make it be able to spam the gifted sub messages if someone gifts a mass amount of subs?

Joined: Jan 2004
Posts: 2,127
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 2,127
The window is only for debug purposes while you figure out what your problem is. Your existing script does nothing except monitor the USERNOTICE raw event, ignoring all USERNOTICE with the wrong room id value. Then it looks to see if $msgtags(msg-id).key matches any of the 3 strings "sub" "resub" "gift". If it shows the red message, then that latest message either did not fill this identifier with a value, or it filled it with a different value. The debug message begins showing the $msgtags(msg-id).key string, so it's either empty or an unknown 4th string.

If you're worried about your own spamming, you can try checking the "own messages" box in tools/options/irc/flood, which should hopefully delay your messages to avoid being dinged for flooding.

The purpose of this window is to identify messages that should have been sent but were not. It might also help for the @SUB window to also see the entire USERNOTICE. It might work to do this, I don't know since I don't use twitch. For the line following the existing echo to @Subs could be another line:

echo @Subs USERNOTICE: $1-

Joined: Dec 2018
Posts: 53
T
TroyL Offline OP
Babel fish
OP Offline
Babel fish
T
Joined: Dec 2018
Posts: 53
So will this basically make my bot faster at responding at subs and other stuff?

Joined: Jan 2004
Posts: 2,127
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 2,127
Faster at responding to subs, no. You can only respond to a sub as fast/slow as the usernotice arrives.

I thought your problem was that your script did not see all the gift in a mass gifting, so this debug messaging was trying to discover whether you were receiving messages that you were not responding to. It looks like the other thread has a response to that issue, as there are other message tags you should have also been seeing.

Joined: Dec 2018
Posts: 53
T
TroyL Offline OP
Babel fish
OP Offline
Babel fish
T
Joined: Dec 2018
Posts: 53
Makes sense thank you for all of the help. I turned off flood protection so would i select the "own messages" box?

Joined: Jan 2004
Posts: 2,127
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 2,127
Yes, after enabling flood protection, checkbox for "own messages" should help space apart your own /msg commands. The "op commands" is for people running a script that would need to ban/kick many nicks in a short time - though this delay can make those commands less effective.

Joined: Jan 2019
Posts: 2
L
Bowl of petunias
Offline
Bowl of petunias
L
Joined: Jan 2019
Posts: 2
Hey Maroon.
First sorry for my bad english.

But i need ur help with the Script.
Sub and Resub works fine but i have a problem with "sub-gifts". On single gifts its work fine but on mass-gifts it's spam with every single gift.
Is there a way to separate it? individual gifts and mass gifts?

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

raw USERNOTICE:*:{
  if ($msgtags(room-id).key != 103495737) return
  if (!$window(@Subs)) window @Subs
  echo $+([,$time,]) @Subs msg-id.key $msgtags(msg-id).key display-name.key: $msgtags(display-name).key msg-param-sub-plan.key: $msgtags(msg-param-sub-plan).key
  }
  if ($msgtags(msg-id).key == sub) {
    var %nick $iif($msgtags(display-name).key, $v1, $msgtags(login).key)
    var %sub-plan $replace($msgtags(msg-param-sub-plan).key, 1000, $chr(36) $+ 4.99, 2000, $chr(36) $+ 9.99, 3000, $chr(36) $+ 24.99, Prime, Prime)
    msg $1 shoxx91Herzz %nick shoxx91Herzz Danke für deine %sub-plan Sub! shoxx911hype Willkommen in der Shoxx-Community! shoxx91Herzz shoxx91Herzz
    msg $1 shoxx91Herzz shoxx911hype shoxx91SHype shoxx91SHype shoxx91SHype shoxx91SHype shoxx91SHype shoxx911hype shoxx91Herzz
    msg $1 shoxx91Herzz shoxx911hype shoxx91SHype shoxx91SHype shoxx91SHype shoxx91SHype shoxx91SHype shoxx911hype shoxx91Herzz
  }
  elsif ($msgtags(msg-id).key == resub) {
    var %nick $iif($msgtags(display-name).key, $v1, $msgtags(login).key)
    VAR %sub-plan $replace($msgtags(msg-param-sub-plan).key, 1000, $chr(36) $+ 4.99, 2000, $chr(36) $+ 9.99, 3000, $chr(36) $+ 24.99, Prime, Prime)
	msg $1 shoxx91Herzz %nick shoxx91Herzz Danke für deinen ReSub im $msgtags(msg-param-months).key Monat in folge mit einem %sub-plan Sub! shoxx91Herzz shoxx91Herzz
    msg $1 shoxx91Herzz shoxx911hype shoxx91SHype shoxx91SHype shoxx91SHype shoxx91SHype shoxx91SHype shoxx911hype shoxx91Herzz
    msg $1 shoxx91Herzz shoxx911hype shoxx91SHype shoxx91SHype shoxx91SHype shoxx91SHype shoxx91SHype shoxx911hype shoxx91Herzz
  }
  elseif ($msgtags(msg-id).key == subgift) {
    var %nick_from $iif($msgtags(display-name).key, $v1, $msgtags(login).key) , %nick_to $iif($msgtags(msg-param-recipient-display-name).key, $v1, $msgtags(msg-param-recipient-user-name).key)
    VAR %sub-plan $replace($msgtags(msg-param-sub-plan).key, 1000, $chr(36) $+ 4.99, 2000, $chr(36) $+ 9.99, 3000, $chr(36) $+ 24.99)
    msg $1 shoxx91Herzz shoxx911hype %nick_from shoxx911hype shoxx91Herzz  Danke das du einen %sub-plan Sub an %nick_to $+ verschenkt hast! shoxx911hype shoxx91Herzz
  }
  elsif ($msgtags(msg-id).key == bits) {
    ?????? ?????? ?????
   }
  }
 }
   else {
    echo 4 @Subs Warning: The above message was not handled.
  }
}


That mean for Single Sub-gifts this

Code:
  elseif ($msgtags(msg-id).key == subgift) {
    var %nick_from $iif($msgtags(display-name).key, $v1, $msgtags(login).key) , %nick_to $iif($msgtags(msg-param-recipient-display-name).key, $v1, $msgtags(msg-param-recipient-user-name).key)
    VAR %sub-plan $replace($msgtags(msg-param-sub-plan).key, 1000, $chr(36) $+ 4.99, 2000, $chr(36) $+ 9.99, 3000, $chr(36) $+ 24.99)
    msg $1 shoxx91Herzz shoxx911hype %nick_from shoxx911hype shoxx91Herzz  Danke das du einen %sub-plan Sub an %nick_to $+ verschenkt hast! shoxx911hype shoxx91Herzz
  }


and when a user spend more then 1 Sub the Script only post 3 line of hype?
and the Second question. Can u help me with a Bit thanks?

Thanks for all.

Joined: Jan 2004
Posts: 2,127
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 2,127
did the sub-mystery issue in this link answer your question?
https://forums.mirc.com/ubbthreads.php/topics/264618/Re:_[Twitch]_Script_for_Subscr#Post264618

Your script is showing the echo into the @sub window, so it should have shown you're receiving the sub-mystery message


Link Copied to Clipboard