mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Jan 2023
Posts: 6
L
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
L
Joined: Jan 2023
Posts: 6
Hi everyone,

I'm looking to set up a Twitch bot that thanks users for subbing, resubbing and gifting subs. However, I'm having issues with the gifting subs part.

Originally, I had the script setup but if a user gifted 10 subs (for example) then it would post a message 10 times when I would only want it to post a message once. Anyone know how I can get around this? This is what I have so far:

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


raw USERNOTICE:*:{
if (($msgtags(msg-id).key == sub) && ($1 == #TwitchUsername)) {
var %ck $iif($msgtags(display-name).key, $v1, $msgtags(login).key)
MSG $1 @ $+ %ck Welcome to the Fam!!
}
elseif (($msgtags(msg-id).key == resub) && ($1 == #TwitchUsername)) {
var %ck $iif($msgtags(display-name).key, $v1, $msgtags(login).key)
if ($0 == 1) {
MSG $1 Thank you @ $+ %ck for the resubbing for $msgtags(msg-param-cumulative-months).key months!!
}
}
elseif (($msgtags(msg-id).key == subgift) && ($1 == #TwitchUsername)) {
var %ck $iif($msgtags(display-name).key, $v1, $msgtags(login).key)
if ($0 == 1) {
MSG $1 Thank you @ $+ %ck for the gifting subs!
}
else {
MSG $1 Thank you @ $+ %ck for the gifting subs!
}
}

}


Thank you in advanced!

Joined: Jan 2004
Posts: 2,127
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 2,127
Not having a personal twitch channel, I don't have an opportunity to see these messages. But from your description, it sounds like your issue is that someon giving 10 gifts causes there to be 10 separate messages, and you want to have them combined into just 1 message?

It's easier if you can see some debug messages showing exactly what messages are received in that 'raw USERMODE'. You can make it create some debug messages by insert these commands immediately below the 'raw usernotice' row:

Code
if (!$window(@usernotice)) window -z @ @usernotice
echo 3 -t @usernotice nick $nick chan $chan tags: $msgtags
echo 4 -t @usernotice nick mesg: $1-

Once you see what the messages look like, you'll have a better idea how to handle them.

Joined: Jan 2023
Posts: 6
L
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
L
Joined: Jan 2023
Posts: 6
So I will say that I am not expert at this but I am trying to learn so bare with me and my stupid questions.

Quote
"it sounds like your issue is that someon giving 10 gifts causes there to be 10 separate messages, and you want to have them combined into just 1 message?"

You are absolutely correct. Basically, someone would gift 10 subs, it would say "X has gifted 10 subs" followed by

Quote
X has gifted a tier 1 sub to A
X has gifted a tier 1 sub to B
X has gifted a tier 1 sub to C

and so on flooding the Twitch chat. I wanted the bot to say something like:

Quote
X has gifted 1 sub! Thank you!
for one gifted sub and
Quote
X has gifted (number higher than 1 here) subs! Thank you!
for more than 1 gifted sub without the spam.

Quote
You can make it create some debug messages by insert these commands immediately below the 'raw usernotice' row...
- so by this, do you mean pasting that code into my script and wait for someone to gift a sub to see the results? Or?

Joined: Jan 2004
Posts: 2,127
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 2,127
Originally Posted by Legend_Killer
so by this, do you mean pasting that code into my script and wait for someone to gift a sub to see the results?

You are absolutely correct. Inserting these lines into your script as new lines between the "raw userhost" and the "if" statement which follows it. If you're queasy about doing this, make sure you have a backup copy of your script saved somewhere.

Once you know what the message itself and the attached tags all look like, that can affect the solution. If there is something else in the tag which identifies that this is #X of #Y gifts, that can be used to show only a single summary message.

Otherwise, it might be necessary to have a delayed response, after all the gift messages have been put into a temporary @window, where the script has written enough information that allows determining whether this is part of a series, or not.

That solution may not be perfect in rare cases. For example, I don't know how it would handle someone gifting 100 things at the same time, since sending you 100 userhost messages at the same time might flood you to the point the network would disconnect you, and to prevent this the network might have a way of spacing these messages apart, which means it might be handy to have the message contain the exact second when the message is received, so in my debug messages where I used -t that likely only shows hours:minutes, it could be useful to see the full seconds too, by replacing -t with $time

So the lines would change instead to:

Code
if (!$window(@usernotice)) window -z @ @usernotice
echo 3 $time @usernotice nick $nick chan $chan tags: $msgtags
echo 4 $time @usernotice nick mesg: $1-

Joined: Jan 2023
Posts: 6
L
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
L
Joined: Jan 2023
Posts: 6
Perfect, thank you so much for your help.

Give me a couple of days to test it and I'll let you know how it goes!

Joined: Jan 2023
Posts: 6
L
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
L
Joined: Jan 2023
Posts: 6
Ok so just tested this. I saw no feedback/response from the bot unfortunately. Any ideas what may be the issue?

Joined: Jan 2004
Posts: 2,127
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 2,127
Remove those lines from the other event, and put these lines in a brand new remote scriptfile
in the remote tab of the alt+R script editor you can use the file/new to do that.
Then put these lines in that file:

Code
raw USERNOTICE:*:{
  if (!$window(@usernotice)) window -z @usernotice
  echo 3 $time @usernotice nick $nick chan $chan tags: $msgtags
  echo 4 $time @usernotice nick mesg: $1-
  beep 1
}

The beep is just to make a sound when something goes to the window, and you can remove that
Once you have some lines in the window, you can either copy them by highlighting with the mouse, or the @usernotice window will have a "buffer" menu choice in the upper left corner of the window, from where you can either save-as to disk, or copy to clipboard

Joined: Jan 2023
Posts: 6
L
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
L
Joined: Jan 2023
Posts: 6
So this is a test script to see if the script works? Or does it perform a different function? (sorry, just trying to learn/understand)

Joined: Jan 2004
Posts: 2,127
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 2,127
same thing i was trying to do before, all it does is echo all userhost messages to a @userhost window, so you can see what are the messages you are receiving. maybe the 10 message being received do tell you that this sub is #N of 10 subs given by a specific person

Joined: Jan 2023
Posts: 6
L
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
L
Joined: Jan 2023
Posts: 6
Ah ok. So that script you posted, do I need to edit it at all? Or can I just edit it into my script as it is?

Joined: Jan 2004
Posts: 2,127
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 2,127
As I described before, all you need to do is make a new script file to put the last script into it. This isn't a permanent solution, since the only thing it does is create a log window containing the contents of the USERHOST messages. But hopefully this will let you see exactly what content of messages you are receiving. I can't do it myself since I don't receive subscriptions.


Link Copied to Clipboard