mIRC Homepage
Posted By: Majeye Link protection script [TwitchTV] - 13/01/15 06:31 AM
so.. I have link protection that works fine.. but my bot is slowly becoming public and need to make it so if people add regulars, they are added to their channel only.. anyone know how to add that to the following script?


Code:
on $@*:text:*:#:{
  if ($regex($1-,/.+\.(com|co|uk|net|org|gov|tv|edu|fm)/iS)) && ($nick !isop $chan) {
    if (!$istok(%permit,$nick,32)) {
      msg # .timeout $nick 1
      msg $chan Please, $Nick Ask a mod for permission to post links!
    }
  }


  noop $regex($1-,/^!(reg del|reg add|permit)\s(\S+)/iS) { 
    if ($regml(1) == reg add) && ($nick isop $chan) {
      if ($istok(%permit,$regml(2),32)) {
        msg $chan $regml(2) is already on the regular list
      }
      else {
        set %permit $addtok(%permit,$regml(2),32)
        msg $chan $regml(2) You are now always permitted to post links
      }
    }
    if ($regml(1) == permit) && ($nick isop $chan) {
      set %permit $addtok(%permit,$regml(2),32)
      .timerunset 1 30 set %permit $remtok(%permit,$regml(2),1,32)
      msg $chan $regml(2) You have 30 seconds to post a link in here
    }
    if ($regml(1) == reg del) && ($nick isop $chan) {
      if ($istok(%permit,$regml(2),32)) {
        set %permit $remtok(%permit,$regml(2),1,32)
        msg $chan $regml(2) removed from regular list
      }
      else {
        msg $chan $regml(2) is not on regular list
      }
    }
  }
}
Posted By: Majeye Re: Link protection script [TwitchTV] - 13/01/15 08:33 AM
Belhifet came to my Twitch chat to assist a bit..

I still don't fully understand how to get it to work properly.
Posted By: Belhifet Re: Link protection script [TwitchTV] - 13/01/15 09:49 AM
Code:
on $@*:text:*:#:{
  if ($regex($1-,/.+\.(com|co|uk|net|org|gov|tv|edu|fm)/iS)) && ($nick !isop $chan) {
    if (!$istok($($+(%,permit.,$chan),2),$nick,32)) {
      msg # .timeout $nick 1
      msg $chan Please, $Nick Ask a mod for permission to post links!
    }
  }
  noop $regex($1-,/^!(reg del|reg add|permit)\s(\S+)/iS)  
  if ($regml(1) == reg add) && ($nick isop $chan) {
    if ($istok($($+(%,permit.,$chan),2),$regml(2),32)) {
      msg $chan $regml(2) is already on the regular list
    }
    else {
      set $+(%,permit.,$chan) $addtok($($+(%,permit.,$chan),2),$regml(2),32)
      msg $chan $regml(2) You are now always permitted to post links
    }
  }
  if ($regml(1) == permit) && ($nick isop $chan) {
    set $+(%,permit.,$chan) $addtok($($+(%,permit.,$chan),2),$regml(2),32)
    set -u30 $+(%,permit.,$chan) $remtok($($+(%,permit.,$chan),2),$regml(2),1,32)
    msg $chan $regml(2) You have 30 seconds to post a link in here
  }
  if ($regml(1) == reg del) && ($nick isop $chan) {
    if ($istok($($+(%,permit.,$chan),2),$regml(2),32)) {
      set $+(%,permit.,$chan) $remtok($($+(%,permit.,$chan),2),$regml(2),1,32)
      msg $chan $regml(2) removed from regular list
    }
    else {
      msg $chan $regml(2) is not on regular list
    }
  }
}


Its possible I made a typo or soemthing in here I didnt test anything, but the idea is...make the variable specific to the channel by naming it dynamically by including the channel name.


Its worth noting

Code:
  if ($regex($1-,/.+\.(com|co|uk|net|org|gov|tv|edu|fm)/iS)) && ($nick !isop $chan) {

the links that are most likely to be abusive links, url shorteners, would bypass your link protection.
Posted By: Belhifet Re: Link protection script [TwitchTV] - 13/01/15 10:11 AM
I'll explain this a little bit.

This is what out variable is
%permit.#majeye belhifet,bob,superbob

$+(%,permit.,$chan)

When we write this, we tell mirc to join these things together. This is called string concatenation. The first thing mirc does is find out what its joining together. In this cause its % and permit. and #majeye (it turns $chan into the channel, this is why we seperated % and permit. because we didn't want it to look for a variable %permit. If we hadn't done this most likely when looking for %permit. it would return $null and join NOTHING with #majeye, resulting in just the channel name.)

When we want to find out what the value of a dynamic variable is we have to tell mirc to evaluate it once its done. We do so by using the evalution identifier, like so $($+(%,permit.,$chan),2).

Remember that %perment.#majeye belhifet,bob,superbob is our variable. When we use evaluation it returns belhifet,bob,superbob. The number we've used..2 is the number of times the statement is evaluated. The first time is when we turn $chan into #majeye, the second time is when we turn %perment.#majeye into belhifet,bob,superbob. We could evaluate it some more by puting the number 3 there. In this case we'd still get belhifet,bob,superbob, but had out result(belhifet,bob,superbob) been 100 + 1 instead...we'd evaluate that to 101.
Posted By: Majeye Re: Link protection script [TwitchTV] - 13/01/15 03:20 PM
Wow.. thank you for explaining it so thoroughly. I had to sleep to understand it a bit more. <3

Added a few more to the link protection search wink

Code:
  if ($regex($1-,/.+\.(com|co|uk|net|org|gov|tv|edu|fm|ly|gl|de|rs|gs|eu|ro|gp|sh|in|do|cc|tk|me|uz|nr|biz|to)/iS)) && ($nick !isop $chan) { 
Posted By: Majeye Re: Link protection script [TwitchTV] - 13/01/15 06:32 PM
Blah.. so the script is still timing people out even after allowing them a permit.

Not sure what is wrong.


Code:
on $@*:text:*:#:{
  if ($regex($1-,/.+\.(com|co|uk|net|org|gov|tv|edu|fm|ly|gl|de|rs|gs|eu|ro|gp|sh|in|do|cc|tk|me|uz|nr|biz|to)/iS)) && ($nick !isop $chan) {
    if (!$istok($($+(%,permit.,$chan),2),$nick,32)) {
      msg # .timeout $nick 1
      msg $chan Please, $Nick Ask a mod for permission to post links!
    }
  }
  noop $regex($1-,/^!(reg del|reg add|permit)\s(\S+)/iS)  
  if ($regml(1) == reg add) && ($nick isop $chan) {
    if ($istok($($+(%,permit.,$chan),2),$regml(2),32)) {
      msg $chan $regml(2) is already on the regular list
    }
    else {
      set $+(%,permit.,$chan) $addtok($($+(%,permit.,$chan),2),$regml(2),32)
      msg $chan $regml(2) You are now always permitted to post links
    }
  }
  if ($regml(1) == permit) && ($nick isop $chan) {
    set $+(%,permit.,$chan) $addtok($($+(%,permit.,$chan),2),$regml(2),32)
    set -u120 $+(%,permit.,$chan) $remtok($($+(%,permit.,$chan),2),$regml(2),1,32)
    msg $chan $regml(2) You have 2 minutes to post a link in here
  }
  if ($regml(1) == reg del) && ($nick isop $chan) {
    if ($istok($($+(%,permit.,$chan),2),$regml(2),32)) {
      set $+(%,permit.,$chan) $remtok($($+(%,permit.,$chan),2),$regml(2),1,32)
      msg $chan $regml(2) removed from regular list
    }
    else {
      msg $chan $regml(2) is not on regular list
    }
  }
}
Posted By: Majeye Re: Link protection script [TwitchTV] - 13/01/15 08:34 PM
Can anyone spot the error in the script in the post right above this one? Looking to get this one fixed asap.
Posted By: Majeye Re: Link protection script [TwitchTV] - 13/01/15 08:58 PM
Ok so I think I found the culprit.. not sure if its affecting permits and add regs being channel specific.. but here is what I changed.

Code went FROM:
Code:
    set -u120 $+(%,permit.,$chan) $remtok($($+(%,permit.,$chan),2),$regml(2),1,32)
    msg $chan $regml(2) You have 2 minutes to post a link in here


TO this code:
Code:
    .timerunset 1 30 set $+(%,permit.,$chan) $remtok($($+(%,permit.,$chan),2),$regml(2),1,32)
    msg $chan $regml(2) You have 30 seconds to post a link in here


And seems to be working in my own channel so far. Again, not sure if anything is channel specific.. but at least it's working for now.
© mIRC Discussion Forums