0

I found the following script posted by Sirus_Black. But I have a question that I am hoping he, or anyone can enlighten me with.

on @*:text:*:#:linkpost $1- 
on @*:action:*:#:linkpost $1-
on @*:notice:*:#:linkpost $1-
alias -l linkpost {
  if ((!%p) && (!$hfind(permit,$nick))) { inc -u4 %p
    var %purge /^!(link\so(n|ff)|(permit))\b/iS
    var %domain com|edu|gov|mil|net|org|biz|info|name|museum|us|ca|uk
    var %exception /(?:https?:\/\/)?w{3}\.(youtube|imgur)\.com/
    var %link /(?<=^|\s)((?>\S{3,8}:\/\/|w{3}\56)\S+)|\56( $+ %domain $+ )\b/iS
    if ($findtok(%chanon1,#,1,32)) && ($nick(#,$nick,vr)) && ($regex($1-,%link)) && (!$regex($1-,%exception)) {
      timeout 30 # $nick | /mode # -b $nick
      msg # $nick You did not have permission to post a link ask a mod to !permit you
      msg # /timeout $nick 1
    }
    elseif (($regex($1-,%purge)) && ($regml(1) = permit) && ($nick isop #) && ($$2 ison  #)) {
      hadd -mz permit $v1 30 | notice $v1 You have 30 seconds to post a link. Starting now!
      msg # You now have 30 seconds to post a link!
    }
    elseif (($regml(1) = link on) && ($nick isop #)) {
      goto $iif(!$istok(%chanon1,#,32),a,b) | :a | set %chanon1 $addtok(%chanon,#,32)
      .msg # Link Protection Is Now on in: $+($chr(2),#)
      halt | :b | .msg # $nick $+ , my link protection is already on in $&
        $+($chr(2),#,$chr(2)) !
    }
    elseif (($regml(1) = link off) && ($nick isop #)) {
      goto $iif($istok(%chanon1,#,32),c,d) | :c | set %chanon1 $remtok(%chanon,#,1,32)
      .msg # Link Protection Is Now off in: $+($chr(2),#)
      halt | :d | .msg # $nick $+ , My link protection is already off . $&
        !
    }
  }
}

The script works as intended, but I am struggling with my limited knowledge of how to add onto it.

Say I want to make exceptions for some other websites.

test1.tv test2.eu and ima.ninja

I would imagine, it would be as simple as changing the variable line to:

    var %exception /(?:https?:\/\/)?w{3}\.(test1|test2|ima)\.com/|\.tv|\.eu|\.ninja

But when I tried this, even those links would result in a time out.

Update: okay, I tested it again

var %exception /(?:https?:\/\/)?w{3}\.(test1|test2|ima)\.com/|\.tv|\.eu|\.ninja

this allows me to use test1.tv as I want, but http://test1.tv results in a time out. I also noticed that using any .eu and .tv web site would be permitted as long as the http:// was not present.

/brainfart

jimieo
  • 5
  • 2

1 Answers1

0

try this

on @*:text:*:#:linkpost $1- 
on @*:action:*:#:linkpost $1-
on @*:notice:*:#:linkpost $1-
alias -l linkpost {
if ((!%p) && (!$hfind(permit,$nick))) {
var %purge /^!(link\so(n|ff)|(permit))\b/iS
var %domain com|edu|gov|mil|net|org|biz|info|name|museum|us|ca|uk
var %exception /https?:\/\/(?:w{3})?\.(youtube|imgur|ima|test)\.(ninja|eu|com)/
var %link /(?<=^|\s)((?>\S{3,5}:\/\/|w{3}\56)\S+)|\56( $+ %domain $+ )\b/iS
if ($findtok(%chanon1,#,1,32)) && ($nick(#,$nick,vr)) && ($regex($1-,%link)) && (!$regex($1-,%exception)) {
  timeout 30 # $nick | /mode # -b $nick
  msg # $nick You did not have permission to post a link ask a mod to !permit you
  msg # /timeout $nick 1
}
elseif (($regex($1-,%purge)) && ($regml(1) = permit) && ($nick isop #) && ($$2 ison  #)) {
  hadd -mz permit $v1 30 | notice $v1 You have 30 seconds to post a link. Starting now!
  msg # You now have 30 seconds to post a link!
}
elseif (($regml(1) = link on) && ($nick isop #)) {
  goto $iif(!$istok(%chanon1,#,32),a,b) | :a | set %chanon1 $addtok(%chanon,#,32)
  .msg # Link Protection Is Now on in: $+($chr(2),#)
  halt | :b | .msg # $nick $+ , my link protection is already on in $&
    $+($chr(2),#,$chr(2)) !
}
elseif (($regml(1) = link off) && ($nick isop #)) {
  goto $iif($istok(%chanon1,#,32),c,d) | :c | set %chanon1 $remtok(%chanon,#,1,32)
  .msg # Link Protection Is Now off in: $+($chr(2),#)
  halt | :d | .msg # $nick $+ , My link protection is already off . $&
    !
}
}
}
Sirius_Black
  • 471
  • 3
  • 11
  • Thanks so much for getting back to me. I appreciate the help with this, and I hope I may ask for just a little more. The fix you did was indeed the solution. The only issue I am having now is it being necessary for full links. What I mean is if I want to put a youtube link, I can't simply put youtube.com/siriusisawesome. I would need to include the http://www.youtube.com/siriusisawesome Is there a way to make the http://www. optional? Or to make subdomains acceptable? Ex: http:/ /sub.test.eu or just sub.test.eu Again, I really do appreciate the help. – jimieo Aug 29 '14 at 04:30
  • try this regex match /(?:(?<=w{3}\.|http:\/\/))(\S+\.(?:com|eu|uk|net))/ – Sirius_Black Aug 30 '14 at 00:38
  • Hi @Sirius_Black thanks for the reply I changed var %exception /http?:\/\/(?:w{3})?\.(youtube|imgur|hivemc|jimieo|test)\.(tv|eu|com)/ to var %exception /(?:(?<=w{3}\.|http:\/\/))(\S+\.(?:com|eu|uk|net))/ I am not quite sure where to put my selected domain exceptions. Without them being present every link shared was accepted.. Zero timeouts :S – jimieo Aug 30 '14 at 04:12