mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Feb 2015
Posts: 12
S
Pikka bird
OP Offline
Pikka bird
S
Joined: Feb 2015
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.

Joined: Jul 2006
Posts: 4,145
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,145
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?


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Joined: Feb 2015
Posts: 12
S
Pikka bird
OP Offline
Pikka bird
S
Joined: Feb 2015
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.

Joined: Jul 2006
Posts: 4,145
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,145
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


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Joined: Feb 2015
Posts: 12
S
Pikka bird
OP Offline
Pikka bird
S
Joined: Feb 2015
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
  }
}

Joined: Oct 2015
Posts: 112
B
Vogon poet
Offline
Vogon poet
B
Joined: Oct 2015
Posts: 112
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.


Link Copied to Clipboard