mIRC Home    About    Download    Register    News    Help

Print Thread
[Twitch] I need help with song request system #256537 26/01/16 03:09 PM
Joined: Jun 2014
Posts: 77
K
Khonor Offline OP
Babel fish
OP Offline
Babel fish
K
Joined: Jun 2014
Posts: 77
Hi there,

I need some help, I want to add in a way for the bot to recognize links so that for the !songrequest command, if one does not give a link, their input will not be accepted. I am fairly new to IRC, so I apologize if the script has errors!

For example:

This: !songrequest Maroon 5 - Sugar youtu.be/09R8_2nJtjg?list=RDRgKAFK5djSk

Should give an output of "added song name Maroon 5 - Sugar to the song queue. youtu.be/09R8_2nJtjg?list=RDRgKAFK5djSk"

Any help is appreciated. Thanks in advance!




on $*:TEXT:!songrequest &:#: {
if ((%floodsongrequest) || ($($+(%,floodsongrequest.,$nick),2))) { return }
write songlist.txt $2
write songlinks.txt $3
write songusers.txt $nick
msg $chan Added song name $2 to the song queue. %slink
}

on *:text:!currentsong:#: {
if ((%floodcurrentsong) || ($($+(%,floodcurrentsong.,$nick),2))) { return }
set -u30 %floodcurrentsong On
set -u60 %floodcurrentsong. $+ $nick On {
if ($read(songlist.txt,2)) {

var %slist2 $read(songlist.txt,1)
var %slink2 $read(songlinks.txt,1)
var %suser2 $read(songusers.txt,1)
msg $chan Current Song: %slist $chr(124) Requested by %suser $chr(124) %slink
write -dl1 songlist.txt
write -dl1 songlinks.txt
write -dl1 songusers.txt
}
else {
msg $chan There are no more songs in the queue.
write -dl1 songlist.txt
write -dl1 songlinks.txt
write -dl1 songusers.txt
}
}
}

on *:text:!nextsong:#: {
if ($nick isop #) {
if ((%floodnextsong) || ($($+(%,floodnextsong.,$nick),2))) { return }
set -u5 %floodnextsong On
set -u10 %floodnextsong. $+ $nick On {
if ($read(songlist.txt,2)) {
var %slist2 $read(songlist.txt,2)
var %slink2 $read(songlinks.txt,2)
var %suser2 $read(songusers.txt,2)

msg $chan Next Song: %slist $chr(124) Requested by %suser $chr(124) %slink
write -dl1 songlist.txt
write -dl1 songlinks.txt
write -dl1 songusers.txt
}
else {
msg $chan There are no more songs in the queue.
write -dl1 songlist.txt
write -dl1 songlinks.txt
write -dl1 songusers.txt
}
}
}
else msg # This command is only available to moderators.
}

Last edited by Khonor; 26/01/16 03:21 PM.
Re: [Twitch] I need help with song request system [Re: Khonor] #256539 26/01/16 04:02 PM
Joined: Dec 2008
Posts: 1,511
westor Offline
Hoopy frood
Offline
Hoopy frood
Joined: Dec 2008
Posts: 1,511
Try use this code:

($isurl from Wims)

Also i fixed some code errors, and added !clearsongs to clear the song list.

Php Code:

alias isurl { ; by Wims
  noop $regex(isurl,$1-,m@((?:(?:https?|ircs?)://(?:www\.)?|www\.)((?:(?:[-\w]+\.)+)[-\w]+)(?::\d+)?(?:/(?:[-a-zA-Z;/\d#:_?=&,().]*))?)@ig)
  if ($prop == all) {
	var %a 1
	while ($regml(isurl,%a)) { var %url = %url $v1 | inc %a 2 }
	return $iif(%url,%url,0)
  }
  return $iif($prop isnum 0-,$regml(isurl,$prop),$iif($regml(isurl,0),$true,$false))
}

on $*:TEXT:!songrequest &:#: {
  if ((%floodreqsong) || ($($+(%,floodreqsong.,$nick),2))) { return }
  if (!$2) { msg $chan Error, Please specify a song name! | return }
  if (!$3) { msg $chan Error, Please specify a song link! | return }
  if (!$isurl($3)) { msg $chan Error, Please specify a valid link url! | return }
  set -eu30 %floodreqsong On
  set -eu60 %floodreqsong. $+ $nick On
  write songlist.txt $2
  write songlinks.txt $3
  write songusers.txt $nick
  msg $chan $nick -> Added $qt($2) song name with $qt($3) link to the song queue list.
}

on *:text:!currentsong:#: {
  if ((%floodcurrentsong) || ($($+(%,floodcurrentsong.,$nick),2))) { return }
  set -eu30 %floodcurrentsong On
  set -eu60 %floodcurrentsong. $+ $nick On
  if ($read(songlist.txt,n,1)) {
	var %slist = $read(songlist.txt,n,1)
	var %slink = $read(songlinks.txt,n,1)
	var %suser = $read(songusers.txt,n,1)
	msg $chan Current Song: %slist $chr(124) Requested by %suser $chr(124) %slink
  }
  else { msg $chan There are no more songs in the queue list. }
}

on *:text:!nextsong:#: {
  if ((%floodnextsong) || ($($+(%,floodnextsong.,$nick),2))) { return }
  if ($nick !isop #) { msg # This command is only available to moderators! | return }
  set -eu30 %floodnextsong On
  set -eu60 %floodnextsong. $+ $nick On
  if ($read(songlist.txt,n,2)) {
	var %slist2 = $read(songlist.txt,n,2)
	var %slink2 = $read(songlinks.txt,n,2)
	var %suser2 = $read(songusers.txt,n,2)
	msg $chan Next Song: %slist2 $chr(124) Requested by %suser2 $chr(124) %slink2
  }
  else { msg $chan There are no more songs in the queue list. }
}

on *:text:!clearsongs:#: {
  if ((%floodclearsong) || ($($+(%,floodclearsong.,$nick),2))) { return }
  if ($nick !isop #) { msg # This command is only available to moderators! | return }
  set -eu30 %floodclearsong On
  set -eu60 %floodclearsong. $+ $nick On
  var %t = $lines(songlist.txt)
  if (%t) {
	write -c $qt(songlist.txt)
	write -c $qt(songlinks.txt)
	write -c $qt(songusers.txt)
	msg $chan $nick -> The song list has been cleared.
  }
  else { msg $chan There are no more songs in the queue list. }
}
 

Re: [Twitch] I need help with song request system [Re: westor] #256543 26/01/16 09:21 PM
Joined: Jun 2014
Posts: 77
K
Khonor Offline OP
Babel fish
OP Offline
Babel fish
K
Joined: Jun 2014
Posts: 77
Hi @westor,

Thanks for your reply and help really appreciate it, but there is a problem, whenever I want to load a song I did not take the bot.


Example 1:

Me: !songrequest Maroon 5 - Animals https://www.youtube.com/watch?v=qpgTC9MDx1o


Bot: Not responds...





Example 2:

Me: !songrequest https://www.youtube.com/watch?v=qpgTC9MDx1o


Bot: Please specify a song link!

Re: [Twitch] I need help with song request system [Re: Khonor] #256544 26/01/16 10:08 PM
Joined: Jul 2006
Posts: 3,586
W
Wims Offline
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 3,586
I didn't look at the script itself but westor edited the $isurl alias I gave him, he actually broke it, the pattern for the regex call should be in a variable or similar form of escaping, otherwise, the comma in the pattern is taken as an argument seperator, try with this alias instead:

Code:
alias isurl {
var %p m@((?:(?:https?|ircs?)://(?:www\.)?|www\.)((?:(?:[-\w]+\.)+)[-\w]+)(?::\d+)?(?:/(?:[-a-zA-Z;/\d#:_?=&,().]*))?)@ig
  noop $regex(isurl,$1-,%p)
  if ($prop == all) {
	var %a 1
	while ($regml(isurl,%a)) { var %url = %url $v1 | inc %a 2 }
	return $iif(%url,%url,0)
  }
  return $iif($prop isnum 0-,$regml(isurl,$prop),$iif($regml(isurl,0),$true,$false))
}


Worth nothing the pattern originally was an identifier, called with $regex(isurl,$1-,$url_pattern), and this method is somewhat better because it avoids any complication from the mirc parser, indeed if the pattern had a '%' after the comma and a space after some more character, /var would interpret it as a new variable declaration.

@westor if you edit, break a code and then state I made it, I'm not going to be happy cry

Last edited by Wims; 26/01/16 10:09 PM.

Looking for a good help channel about mIRC? Check #mircscripting @ irc.swiftirc.net
Re: [Twitch] I need help with song request system [Re: Wims] #256545 26/01/16 11:44 PM
Joined: Jun 2014
Posts: 77
K
Khonor Offline OP
Babel fish
OP Offline
Babel fish
K
Joined: Jun 2014
Posts: 77
Hi @Wims,

Thank you for your answer, but remains same as the examples I gave above. frown

Re: [Twitch] I need help with song request system [Re: Khonor] #256584 29/01/16 09:10 PM
Joined: Dec 2008
Posts: 1,511
westor Offline
Hoopy frood
Offline
Hoopy frood
Joined: Dec 2008
Posts: 1,511
Try use this code:

Syntax: !songrequest <LINK> <NAME>

Example: !songrequest https://www.youtube.com/watch?v=qpgTC9MDx1o Maroon 5 - Animals

Php Code:

alias isurl { ; by Wims
  var %p m@((?:(?:https?|ircs?)://(?:www\.)?|www\.)((?:(?:[-\w]+\.)+)[-\w]+)(?::\d+)?(?:/(?:[-a-zA-Z;/\d#:_?=&,().]*))?)@ig
  noop $regex(isurl,$1-,%p)
  if ($prop == all) {
		var %a 1
		while ($regml(isurl,%a)) { var %url = %url $v1 | inc %a 2 }
		return $iif(%url,%url,0)
  }
  return $iif($prop isnum 0-,$regml(isurl,$prop),$iif($regml(isurl,0),$true,$false))
}
on $*:TEXT:!songrequest &:#: {
  if ((%floodreqsong) || ($($+(%,floodreqsong.,$nick),2))) { return }
  if (!$2) { msg $chan Error, Please specify a song link! | return }
  if (!$isurl($2)) { msg $chan Error, Please specify a valid link url! | return }
  if (!$3) { msg $chan Error, Please specify a song name! | return }
  set -eu30 %floodreqsong On
  set -eu60 %floodreqsong. $+ $nick On
  write songlist.txt $3-
  write songlinks.txt $2
  write songusers.txt $nick
  msg $chan $nick -> Added $qt($3-) song name with $qt($2) link to the song queue list.
}

on *:text:!currentsong:#: {
  if ((%floodcurrentsong) || ($($+(%,floodcurrentsong.,$nick),2))) { return }
  set -eu30 %floodcurrentsong On
  set -eu60 %floodcurrentsong. $+ $nick On
  if ($read(songlist.txt,n,1)) {
		var %slist = $read(songlist.txt,n,1)
		var %slink = $read(songlinks.txt,n,1)
		var %suser = $read(songusers.txt,n,1)
		msg $chan Current Song: %slist $chr(124) Requested by %suser $chr(124) %slink
  }
  else { msg $chan There are no more songs in the queue list. }
}

on *:text:!nextsong:#: {
  if ((%floodnextsong) || ($($+(%,floodnextsong.,$nick),2))) { return }
  if ($nick !isop #) { msg # This command is only available to moderators! | return }
  set -eu30 %floodnextsong On
  set -eu60 %floodnextsong. $+ $nick On
  if ($read(songlist.txt,n,2)) {
		var %slist2 = $read(songlist.txt,n,2)
		var %slink2 = $read(songlinks.txt,n,2)
		var %suser2 = $read(songusers.txt,n,2)
		msg $chan Next Song: %slist2 $chr(124) Requested by %suser2 $chr(124) %slink2
  }
  else { msg $chan There are no more songs in the queue list. }
}

on *:text:!clearsongs:#: {
  if ((%floodclearsong) || ($($+(%,floodclearsong.,$nick),2))) { return }
  if ($nick !isop #) { msg # This command is only available to moderators! | return }
  set -eu30 %floodclearsong On
  set -eu60 %floodclearsong. $+ $nick On
  var %t = $lines(songlist.txt)
  if (%t) {
		write -c $qt(songlist.txt)
		write -c $qt(songlinks.txt)
		write -c $qt(songusers.txt)
		msg $chan $nick -> The song list has been cleared.
  }
  else { msg $chan There are no more songs in the queue list. }
}
 


@Wims acutally mine version (from you) $isurl its true that is modified because there was an parsing problem but actually i cant remeber which and u fixed it, anyway.. smile

Last edited by westor; 29/01/16 09:12 PM.
Re: [Twitch] I need help with song request system [Re: westor] #256870 25/02/16 12:10 AM
Joined: Jun 2014
Posts: 77
K
Khonor Offline OP
Babel fish
OP Offline
Babel fish
K
Joined: Jun 2014
Posts: 77
Hi @Westor,

I tried several times with the script you gave me, but still does not work.

Re: [Twitch] I need help with song request system [Re: Khonor] #256871 25/02/16 12:58 AM
Joined: Jan 2004
Posts: 1,276
L
Loki12583 Offline
Hoopy frood
Offline
Hoopy frood
L
Joined: Jan 2004
Posts: 1,276
Well for a start it's got tabs in it, that's no good.

Re: [Twitch] I need help with song request system [Re: Loki12583] #256879 25/02/16 07:00 PM
Joined: Dec 2008
Posts: 1,511
westor Offline
Hoopy frood
Offline
Hoopy frood
Joined: Dec 2008
Posts: 1,511
Try to paste it from here:

Code:
alias isurl { ; by Wims
  var %p = m@((?:(?:https?|ircs?)://(?:www\.)?|www\.)((?:(?:[-\w]+\.)+)[-\w]+)(?::\d+)?(?:/(?:[-a-zA-Z;/\d#:_?=&,().]*))?)@ig
  noop $regex(isurl,$1-,%p)
  if ($prop == all) {
    var %a = 1
    while ($regml(isurl,%a)) { var %url = %url $v1 | inc %a 2 }
    return $iif(%url,%url,0)
  }
  return $iif($prop isnum 0-,$regml(isurl,$prop),$iif($regml(isurl,0),$true,$false))
}
on $*:TEXT:!songrequest &:#: {
  if ((%floodreqsong) || ($($+(%,floodreqsong.,$nick),2))) { return }
  if (!$2) { msg $chan Error, Please specify a song link! | return }
  if (!$isurl($2)) { msg $chan Error, Please specify a valid link url! | return }
  if (!$3) { msg $chan Error, Please specify a song name! | return }
  set -eu30 %floodreqsong On
  set -eu60 %floodreqsong. $+ $nick On
  write songlist.txt $3-
  write songlinks.txt $2
  write songusers.txt $nick
  msg $chan $nick -> Added $qt($3-) song name with $qt($2) link to the song queue list.
}

on *:text:!currentsong:#: {
  if ((%floodcurrentsong) || ($($+(%,floodcurrentsong.,$nick),2))) { return }
  set -eu30 %floodcurrentsong On
  set -eu60 %floodcurrentsong. $+ $nick On
  if ($read(songlist.txt,n,1)) {
    var %slist = $read(songlist.txt,n,1)
    var %slink = $read(songlinks.txt,n,1)
    var %suser = $read(songusers.txt,n,1)
    msg $chan Current Song: %slist $chr(124) Requested by %suser $chr(124) %slink
  }
  else { msg $chan There are no more songs in the queue list. }
}

on *:text:!nextsong:#: {
  if ((%floodnextsong) || ($($+(%,floodnextsong.,$nick),2))) { return }
  if ($nick !isop #) { msg # This command is only available to moderators! | return }
  set -eu30 %floodnextsong On
  set -eu60 %floodnextsong. $+ $nick On
  if ($read(songlist.txt,n,2)) {
    var %slist2 = $read(songlist.txt,n,2)
    var %slink2 = $read(songlinks.txt,n,2)
    var %suser2 = $read(songusers.txt,n,2)
    msg $chan Next Song: %slist2 $chr(124) Requested by %suser2 $chr(124) %slink2
  }
  else { msg $chan There are no more songs in the queue list. }
}

on *:text:!clearsongs:#: {
  if ((%floodclearsong) || ($($+(%,floodclearsong.,$nick),2))) { return }
  if ($nick !isop #) { msg # This command is only available to moderators! | return }
  set -eu30 %floodclearsong On
  set -eu60 %floodclearsong. $+ $nick On
  var %t = $lines(songlist.txt)
  if (%t) {
    write -c $qt(songlist.txt)
    write -c $qt(songlinks.txt)
    write -c $qt(songusers.txt)
    msg $chan $nick -> The song list has been cleared.
  }
  else { msg $chan There are no more songs in the queue list. }
}