|
Khonor
|
Khonor
|
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.
|
|
|
|
Joined: Dec 2008
Posts: 1,483
Hoopy frood
|
Hoopy frood
Joined: Dec 2008
Posts: 1,483 |
Try use this code: ($isurl from Wims) Also i fixed some code errors, and added !clearsongs to clear the song list.
alias isurl { ; by Wims
noop $regex(isurl,$1-,m@((?:(?:https?|ircs?):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 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 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. }
}
|
|
|
|
Joined: Jul 2006
Posts: 4,020
Hoopy frood
|
Hoopy frood
Joined: Jul 2006
Posts: 4,020 |
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: 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
Last edited by Wims; 26/01/16 10:09 PM.
#mircscripting @ irc.swiftirc.net == the best mIRC help channel
|
|
|
|
Khonor
|
Khonor
|
Hi @Wims, Thank you for your answer, but remains same as the examples I gave above. 
|
|
|
|
Joined: Dec 2008
Posts: 1,483
Hoopy frood
|
Hoopy frood
Joined: Dec 2008
Posts: 1,483 |
Try use this code: Syntax: !songrequest <LINK> <NAME> Example: !songrequest https://www.youtube.com/watch?v=qpgTC9MDx1o Maroon 5 - Animals
alias isurl { ; by Wims
var %p m@((?:(?:https?|ircs?):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 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 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.. 
Last edited by westor; 29/01/16 09:12 PM.
|
|
|
|
Khonor
|
Khonor
|
Hi @Westor,
I tried several times with the script you gave me, but still does not work.
|
|
|
|
Joined: Jan 2004
Posts: 1,330
Hoopy frood
|
Hoopy frood
Joined: Jan 2004
Posts: 1,330 |
Well for a start it's got tabs in it, that's no good.
|
|
|
|
Joined: Dec 2008
Posts: 1,483
Hoopy frood
|
Hoopy frood
Joined: Dec 2008
Posts: 1,483 |
Try to paste it from here:
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. }
}
|
|
|
|
|