mIRC Home    About    Download    Register    News    Help

Topic Options
#265382 - 12/04/19 01:56 PM [Twitch] Sub bot is not counting months on resubs
Scootycoolguy Offline
Pikka bird

Registered: 25/02/15
Posts: 12
Hey. The past month or two, my sub bot has not been properly counting resubs and just defaulting to 0. I didn't change anything that would cause this, but don't know what I need to update to fix it.

The main section of the code:
Code:
raw USERNOTICE:*:{
  if (($msgtags(msg-id).key == sub) && ($1 == #CHANNEL_NAME)) {
    var %nick $iif($msgtags(display-name).key, $v1, $msgtags(login).key)
    msg $1 EMOTE_HERE Welcome %nick to blah blah blah EMOTE HERE
  }
  elseif (($msgtags(msg-id).key == resub) && ($1 == #CHANNEL_NAME)) {
    var %nick $iif($msgtags(display-name).key, $v1, $msgtags(login).key)
    if ($0 == 1) {
      msg $1 EMOTE_HERE Thanks %nick for $msgtags(msg-param-months).key months in a row! EMOTE_HERE
    }


Mainly looking at the $msgtags(msg-param-months).key section here and why it would stop counting.

Any input is appreciated.

Top
#265383 - 12/04/19 02:00 PM Re: [Twitch] Sub bot is not counting months on resubs [Re: Scootycoolguy]
Wims Offline
Planetary brain

Registered: 31/07/06
Posts: 3515
Loc: France
Did you write this code and do you know how to debug a code?

blind shot: if you open the script editor for that code and press control + h, do you get a warning message about bracket { } being mismatched?
_________________________
Looking for a good help channel about mIRC? Check #mircscripting @ irc.swiftirc.net

Top
#265384 - 12/04/19 02:08 PM Re: [Twitch] Sub bot is not counting months on resubs [Re: Wims]
Scootycoolguy Offline
Pikka bird

Registered: 25/02/15
Posts: 12
The core functionality of the code was written by another a couple of years ago. I was taking what I was understanding of it and editing it slightly (like personal messages and channels to apply it to etc). Don't know enough about mirc to accurately begin to debug

This wasn't the entire code being used hence mismatched {} being shown. The rest is either redundant or completely irrelevant so I didn't add it to the example.

Top
#265385 - 12/04/19 02:17 PM Re: [Twitch] Sub bot is not counting months on resubs [Re: Scootycoolguy]
Wims Offline
Planetary brain

Registered: 31/07/06
Posts: 3515
Loc: France
Change:
Code:
if ($0 == 1) {
  msg $1 EMOTE_HERE Thanks %nick for for $msgtags(msg-param-months).key months in a row! EMOTE_HERE
}
To:
Code:
if ($0 == 1) {
      echo -s Debug for resub: $rawmsg
      msg $1 EMOTE_HERE Thanks %nick for for $msgtags(msg-param-months).key months in a row! EMOTE_HERE
}
This will add a line into your status window everytime this part of the code triggers (which is only for reesub), the line will contain what twitch is sending, if it's not sending a tag with a name "msg-param-months" (which is what I assume is the case) either twitch is buggy or something changed, or you're misunderstanding/missing something
_________________________
Looking for a good help channel about mIRC? Check #mircscripting @ irc.swiftirc.net

Top
#265389 - 13/04/19 02:11 AM Re: [Twitch] Sub bot is not counting months on resubs [Re: Wims]
Scootycoolguy Offline
Pikka bird

Registered: 25/02/15
Posts: 12
When using the debug, my status window produces this.

Just in case, this is the entire code I am working with (I know it is messy). Something tells me something with Twitch has changed since around Jan/Feb when this happened and users could announce their total time subscribed and not just how long they resubbed in a row.

Code:
raw USERNOTICE:*:{
  if (($msgtags(msg-id).key == sub) && ($1 == #moonmoon_ow)) {
    var %nick $iif($msgtags(display-name).key, $v1, $msgtags(login).key)
    msg $1 moon2M Welcome %nick to the bald club moon2M
  }
  elseif (($msgtags(msg-id).key == resub) && ($1 == #moonmoon_ow)) {
    var %nick $iif($msgtags(display-name).key, $v1, $msgtags(login).key)
    if ($0 == 1) {
      msg $1 moon2B Thanks %nick for for $msgtags(msg-param-months).key months in a row! moon2B That's pretty cringe moon2B
    }
    else {
      msg $1 moon2B Thanks %nick for for $msgtags(msg-param-months).key months in a row! moon2B That's pretty cringe moon2B
    }
  }
  elseif (($msgtags(msg-id).key == subgift) && ($1 == #moonmoon_ow)) {
    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){
    msg $1 moon2B Thanks %nick_from for forcing a sub to %nick_to moon2B
  }
}

Top
#265484 - 14/05/19 05:04 AM Re: [Twitch] Sub bot is not counting months on resubs [Re: Scootycoolguy]
Blas Offline
Vogon poet

Registered: 27/10/15
Posts: 111
I checked the official Twitch documentation. Twitch added a number of new message tags to look out for. It appears that msg-param-months is only sent on subgift and anonsubgift. Whereas the newer tag msg-param-cumulative-months is sent on sub and resub. Knowing this, you can edit your script accordingly to react using this information. You can always look at all the available message tags there as well and easily come up with creative ways for your bot to reply to any type of subscription (as well as raids and new chatter). I hope this helps.
_________________________
My Twitch mIRC Bot Games and Stuff

Top