0

I am currently using the follow script to prevent anyone from posting links on Twitch chat without getting any permissions.

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 %link /(?<=^|\s)((?>\S{3,8}:\/\/|w{3}\56)\S+)|\56( $+ %domain $+ )\b/iS
    if ($findtok(%chanon1,#,1,32)) && ($nick(#,$nick,vr)) && ($regex($1-,%link)) {
      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 . $&
        !
    }
  }
}

I was wondering if anyone could help me with adding exceptions to the list of websites that will be blocked. I want to add Youtube.com and Imgur.com exceptions, i.e. no one needs permission to post those links.

How about would I achieve this?

Thanks!

EDIT:

Thanks for the help @Sirius_Black.

If I wanted the permission message to actually refer to the person who has been permitted, how would I go about doing that?

i.e. instead of just saying "You have 30 seconds to post a link", I wanted it to say ", you have 30 seconds to post a link".

vika09
  • 19
  • 6

1 Answers1

1

use this one

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 . $&
    !
}
}
}
Sirius_Black
  • 471
  • 3
  • 11
  • Hi there! Thanks a lot. I will use this and see if it works. I'm not sure who Jethro is, but I saw the script I posted on a youtube 'tutorial'. It does work, but it seems buggy once in a while. And yes, I have experienced issues with the link off and link on commands once in a while. But what I did notice is that it's because a variable named %p keeps turning up and delays the script from working properly. I have to wait for that variable to unset before anything starts working. A mild annoyance, but nothing too major. – vika09 Jul 03 '14 at 08:06
  • this script has a problem, since %p is used as flood control, when you type !link on, ppl has 4 seconds to post any link, and when someone posts a link, it sets %p again, so ppl has 4 seconds again to post anything – Sirius_Black Jul 03 '14 at 08:25
  • Ah, that makes sense. Is there any way of fixing that? Or is it something that I just have to live with? – vika09 Jul 03 '14 at 09:48
  • Thanks for the help @Sirius_Black. If I wanted the permission message to actually refer to the person who has been permitted, how would I go about doing that? i.e. instead of just saying "You have 30 seconds to post a link", I wanted it to say ", you have 30 seconds to post a link". – vika09 Jul 03 '14 at 12:07
  • @vika09 first you have to accept my answer as correct if it works, then you can post another question, or i will answer it here – Sirius_Black Jul 03 '14 at 20:12
  • @vika09 put this instead msg # $nick $+ , You now have 30 seconds to post a link! – Sirius_Black Jul 04 '14 at 00:59
  • @vika09 whats the server address you connect? your nick in there and channel name? so i can help you – Sirius_Black Jul 04 '14 at 01:00
  • Thanks again for the help. Server address: irc.twitch.tv:6667 My nick: vikaman Channel names: #circon and #sirfoch – vika09 Jul 04 '14 at 08:47
  • I've posted a new topic @Sirius_Black :) – vika09 Jul 04 '14 at 18:23