0

This is quite a long post (specially the code below), so bear with me.

With help from @Siris_Black, I've managed to get this thing working.

//LINK PROTECTION
    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|tv
        var %exception /(?:http?:\/\/)?w{3}\.(youtube|imgur|i.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 $+ , 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 $+ , Link Protection is already off . $&
            !
        }
      }
    }

However, even with the extensive script, there are some problems:

'Whitelisted' links that are being blocked

https://i.stack.imgur.com/Ww4rK.png

As you can see, Alexander_CJ and Psychosis06 posted Imgur links and were timedout (I have BetterTwitchTV, so I can reveal what was purged). Is there something that I have set up wrongly here?

The !permit command doesn't always work There seems to be issues where the permit command fails to actually permit anyone. The primary issue were user names (which I figured out: all user names are lower case). But there still seems to be issues with the !permit + username command. Are there any conflicts that exist here?

Link Script allows certain links that have text before or after them

This is pretty self explanatory, there are situations where the link bot allows a link that seems to have normal text after it or before it. Unless I haven't set up the rule properly, there are situations where the issue crops up.

The Link Protection seems to interfere with other scripts

These are my other scripts:

//Commands
on *:TEXT:!commands:#circon: { 
  if ((%floodcommands) || ($($+(%,floodcommands.,$nick),2))) { return }
  set -u5 %floodcommands On
  set -u15 %floodcommands. $+ $nick On
  msg $chan /me Currently available commands (place a '!' before the word) - donate|song|mods. Please don't spam commands. $+
}

//Song
on *:TEXT:!song:#circon: { 
  if ((%floodsong) || ($($+(%,floodsong.,$nick),2))) { return }
  set -u5 %floodsong On
  set -u15 %floodsong. $+ $nick On
  msg $chan /me You can find Circon's songs here, wait for the song to finish and it will be the last played song: http://grooveshark.com/#!/circonflexes/listens $+
}

//Soccer Link
on *:TEXT:!football:#circon:{
  if ((%floodfootball) || ($($+(%,floodfootball.,$nick),2))) { return }
  set -u5 %floodfootball On
  set -u15 %floodfootball. $+ $nick On
  msg $chan /me Circon is watching the World Cup here!: <LINK> $+
} 

//Mods Link
on *:TEXT:!mods:#circon:{
  if ((%floodmods) || ($($+(%,floodmods.,$nick),2))) { return }
  set -u5 %floodmods On
  set -u15 %floodmods. $+ $nick On
  msg $chan /me Circon's mods are here: http://youtu.be/N-IHaIKQvns. Servercross2 Recticle add-on - https://www.dropbox.com/s/dkd0b1fqp9oaz2e/ServerCross2.rar Dont forget to virus scan before use. :) $+
}

//Donate
on *:TEXT:!donate:#circon:{
  if ((%flooddonate) || ($($+(%,flooddonate.,$nick),2))) { return }
  set -u5 %flooddonate On
  set -u15 %flooddonate. $+ $nick On
  msg $chan /me Please donate to Circon here: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=KRQXH2YM3WGSW $+
}

Once in a while, a command that is input correctly (i.e. !song) will not display the text. In fact, nothing happens. Is there anything that is conflicting? I'm not able to see any issues with what I've done. There are two sets of these scripts (for two Twitch channels).

I'm sorry that this is a lot. I'm a complete newbie to MSL and just need some pointers/tips. I'd primarily appreciate any guidance as to set up the most strict link protection - i.e. disallow ANY linking except youtube and imgur.

Thanks!

vika09
  • 19
  • 6

1 Answers1

0

first, the other on text script (!command,!song,!footbal,!mods) needs to be in another remote file
since u have an on text script that matches anything on link protection script

try this

on @*:text:*:#:linkpost $1-
on @*:action:*:#:linkpost $1-
on @*:notice:*:#:linkpost $1-
alias -l linkpost {
if (!$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|tv
var %exception /(?:http?:\/\/)?(?:w{3}\.)?.+(youtube|\Qimgur\E)\.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 # $$2 $+ , 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 $+ , 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 $+ , Link Protection is already off . $&
    !
}
}
}
Sirius_Black
  • 471
  • 3
  • 11
  • Thanks @Sirius_Black! This seems to work better. Only slight issue is that $nick $+ seems to refer back to me, instead of the person I am giving permission to: http://imgur.com/oDAwUjE $nick works when the bot automatically blocks a link by referring to the infringer. But $nick says my name when permitting the person. – vika09 Jul 05 '14 at 08:41
  • change $nick to $$2 instead, if this answer is the right answer, choose it as correct, Thanks – Sirius_Black Jul 05 '14 at 08:48
  • Hey, @Sirius_Black , for some reason, the link protection bot is attempting to block a mod/op (name: G1nge_UK): http://www.imgur.com/4f7u3Js Also, there are links that are getting through: http://www.imgur.com/4f7u3Js Do tell me if you want me to start a new question :) – vika09 Jul 05 '14 at 19:06
  • Thanks again! I will make those changes and get back to you. I will make sure I start a new question for any other issues. :) – vika09 Jul 05 '14 at 21:19
  • @Sirius_Black, `|` is not a good idea for this kind of usage, I would put these commands on new lines. Additionally, Put space after the variable declaration so it will be extra space before the if condition. Finally, the mIRC way of declaring local variable are with '=' modifier, although it's not must and mIRC is "allowing" this violation, that does not mean we should violate this. I'll hope you will take these notes as constructive notes. – Orel Eraki Jul 07 '14 at 17:30
  • @OrelEraki i didnt make this script, she posted in another post and i modified it, by the way, there is no problem in using | , since it will work as line separator. there are 2 ways to declare "local" variables, one is var %var = value, other is set -l %var value and "=" is not a modifier... – Sirius_Black Jul 08 '14 at 03:41
  • @Sirius_Black, I didn't said there is a problem for using it, I've just said it's not good way in this scenario. When building "complex" statement it's best to do it readable as possible, and that isn't achieved by `|`. And i know there is several ways but only 1 way is with var and that correct way is also with `=` assignment sign, but surly not the bad way that mIRC forgive and that is without `=`. – Orel Eraki Jul 19 '14 at 14:57