mIRC Homepage

Twitch link protection for multiple channels?

Posted By: Spike

Twitch link protection for multiple channels? - 19/02/16 07:57 PM

I've looked for tons of scripts for twitch link protection but they 1. Don't work anymore 2. Don't work for multiple channels

My bot is in more then just 1 channel. So i want it so every channel can toggle it on and off for there channel not everyone elses channel.


The only script I found that works but isn't for multiple channels is this one

Code:
on *:text:!links*:#: {
  if ($nick isop #) {
    if ($2 == on) {
      if (%links) {
        msg # Link protection is already enabled
        return
      }
      else {
        msg # Link protection enabled
        set %links On
        return
      }
    }
    if ($2 == off) {
      if (%links) {
        msg # Link protection disabled
        unset %links on
        return
      }
      else {
        msg # Link protection is already disabled
        return
      }
    }
    else { msg # ' $+ $2 $+ ' is not a valid function. use '!links on' to enable link protection and '!links off' to disable it again. }
  }
}

on *:text:!permit*:#: {
  if ($nick isop #) {
    if (%links) {
      set -u30 %permit $addtok(%permit,$2,32)
      msg $chan You have 30 seconds to post a link, $2
    }
  }
}

on +201:text:*:#: {
  if ($nick isop #) { return }
  if ($istok(%permit,$nick,32)) { return }
  if (%links) {
    if (*www.* iswm $1- || *http://* iswm $1- || *.com* iswm $1- || *.tv* iswm $1- || *.nl* iswm $1- || *.sh* iswm $1- || *.net* iswm $1- || *.me* iswm $1-) {
      .ruser 201 $nick
      msg # /timeout $nick 86400
      msg # That was your 3rd link. Try again tomorrow, $nick [Link] [24h]
      return
    }
  }
}
on +200:text:*:#: {
  if ($nick isop #) { return }
  if ($istok(%permit,$nick,32)) { return }
  if (%links) {
    if (*www.* iswm $1- || *http://* iswm $1- || *.com* iswm $1- || *.tv* iswm $1- || *.nl* iswm $1- || *.sh* iswm $1- || *.net* iswm $1- || *.me* iswm $1-) {
      .ruser 200 $nick | .auser 201 $nick | .timermsg 1 3600 .ruser 201 $nick
      msg # /timeout $nick 
      msg # No links without permission, $nick $+ ! [Link] [Timeout]
      return
    }
  }
}
on *:text:*:#: {
  if ($nick isop #) { return }
  if ($nick == PUT CASTER HERE) { return }
  if ($istok(%permit,$nick,32)) { return }
  if (%links) {
    if (*www.* iswm $1- || *http://* iswm $1- || *.com* iswm $1- || *.tv* iswm $1- || *.nl* iswm $1- || *.sh* iswm $1- || *.net* iswm $1- || *.me* iswm $1-) {
      msg $chan /timeout $nick 10
      msg $chan Please ask permission before posting a link, $nick [Link] [Warning]
      .auser 200 $nick | .timermsg 1 3600 .ruser 200 $nick
      return
    }
  }
} 
Posted By: Loki12583

Re: Twitch link protection for multiple channels? - 19/02/16 08:10 PM

Anywhere you're using a global variable such as %links use a dynamic variable with the channel name:

Code:
set %links. [ $+ [ # ] ] On


Instead of using global variables you can also use ini files or hash tables
Posted By: Wims

Re: Twitch link protection for multiple channels? - 19/02/16 08:48 PM

Except this one doesn't work either, looking for "www.' and the like inside the text will fail on a lot of occasions.
Try this, you can do !links per channel. The number of warning is global, meaning that if a nickname has been warned twice on channel #a, if he send an url on channel #b, it's taken as the third warning.
Code:
on *:text:*:#:{
  if ($regex($1-,/^!links (on|off)/)) && ($nick isop $chan) {
      if ($2 == on) %channellink = $remtok(%channellink,$chan,32)
      else %channellink = $addtok(%channellink,$chan,32)
      msg $chan Link status changed: $2
  }
  elseif ($regex($1-,/^!permit .+/)) && ($nick isop $chan) {
    set %nicklink $+ $chan $($+(%,nicklink,$chan),2) $2
    .timer 1 30 set %nicklink $+ $chan $remtok($($+(%,nicklink,$chan),2),$2,32)
    msg $chan You have 30 seconds to post a link, $2
  }
  elseif (!$istok(%channellink,$chan,32)) && ($isurl($1-)) && (!$istok($($+(%,nicklink,$chan),2),$nick,32)) {
    var %w $($+(%,warnurl,$nick),2)
    if (%w == 1) {
      msg $chan /timeout $nick 10
      msg $chan Please ask permission before posting a link, $nick
      .timermsg 1 3600 unset $+(%,warnurl,$nick)
      inc %warnurl $+ $nick
    }
    elseif (%w == 2) { 
      msg $chan /timeout $nick 
      msg $chan No links without permission, $nick $+ !
      .timermsg 1 3600 unset $+(%,warnurl,$nick)
      inc %warnurl $+ $nick
    }
    elseif (%w == 3) { 
      msg $chan /timeout $nick 86400
      msg $chan That was your 3rd link. Try again tomorrow, $nick
      unset %warnurl $+ $nick
    }
  }
}
alias url_pattern return m@((?:(?:https?|ircs?)://(?:www\.)?|www\.)((?:(?:[-\w]+\.)+)[-\w]+)(?::\d+)?(?:/((?:[-a-zA-Z;./\d#:_?=&,]*)))?)@ig
alias isurl {
  noop $regex(isurl,$1-,$url_pattern) 
  if ($prop == all) {
    var %a 1,%url
    while ($regml(isurl,%a) != $null) {
      %url = %url $v1
      inc %a
    }
    return %url
  }
  return $iif($prop isnum 0-,$regml(isurl,$prop),$iif($regml(isurl,0),$true,$false))
}
Posted By: Spike

Re: Twitch link protection for multiple channels? - 19/02/16 09:00 PM

Originally Posted By: Wims
Except this one doesn't work either, looking for "www.' and the like inside the text will fail on a lot of occasions.
Try this, you can do !links per channel. The number of warning is global, meaning that if a nickname has been warned twice on channel #a, if he send an url on channel #b, it's taken as the third warning.
Code:
on *:text:*:#:{
  if ($regex($1-,/^!links (on|off)/)) && ($nick isop $chan) {
      if ($2 == on) %channellink = $remtok(%channellink,$chan,32)
      else %channellink = $addtok(%channellink,$chan,32)
      msg $chan Link status changed: $2
    }
  }
  elseif ($regex($1-,/^!permit .+/)) && ($nick isop $chan) {
    set %nicklink $+ $chan $($+(%,nicklink,$chan),2) $2
    .timer 1 30 set %nicklink $+ $chan $remtok($($+(%,nicklink,$chan),2),$2,32)
    msg $chan You have 30 seconds to post a link, $2
  }
  elseif (!$istok(%channellink,$chan,32)) && ($isurl($1-)) && (!$istok($($+(%,nicklink,$chan),2),$nick,32)) {
    var %w $($+(%,warnurl,$nick),2)
    if (%w == 1) {
      msg $chan /timeout $nick 10
      msg $chan Please ask permission before posting a link, $nick
      .timermsg 1 3600 unset $+(%,warnurl,$nick)
      inc %warnurl $+ $nick
    }
    elseif (%w == 2) { 
      msg $chan /timeout $nick 
      msg $chan No links without permission, $nick $+ !
      .timermsg 1 3600 unset $+(%,warnurl,$nick)
      inc %warnurl $+ $nick
    }
    elseif (%w == 3) { 
      msg $chan /timeout $nick 86400
      msg $chan That was your 3rd link. Try again tomorrow, $nick
      unset %warnurl $+ $nick
    }
  }
}
alias url_pattern return m@((?:(?:https?|ircs?)://(?:www\.)?|www\.)((?:(?:[-\w]+\.)+)[-\w]+)(?::\d+)?(?:/((?:[-a-zA-Z;./\d#:_?=&,]*)))?)@ig
alias isurl {
  noop $regex(isurl,$1-,$url_pattern) 
  if ($prop == all) {
    var %a 1,%url
    while ($regml(isurl,%a) != $null) {
      %url = %url $v1
      inc %a
    }
    return %url
  }
  return $iif($prop isnum 0-,$regml(isurl,$prop),$iif($regml(isurl,0),$true,$false))
}


That doesn't seem to be working. Its not timing the person out (the bot is a mod/op) and i've done !links on
Posted By: Wims

Re: Twitch link protection for multiple channels? - 19/02/16 09:55 PM

I edited the code, there was one extra '}'
Posted By: Spike

Re: Twitch link protection for multiple channels? - 19/02/16 10:19 PM

Originally Posted By: Wims
I edited the code, there was one extra '}'


Still doesn't seem to work. !links on and !links off work fine just it doesn't time out the person that posted a link.
Posted By: Wims

Re: Twitch link protection for multiple channels? - 19/02/16 11:03 PM

I tested the code, everything worked
Posted By: Spike

Re: Twitch link protection for multiple channels? - 20/02/16 12:06 AM

Originally Posted By: Wims
I tested the code, everything worked


Did you test it on twitch?
Posted By: Wims

Re: Twitch link protection for multiple channels? - 20/02/16 12:54 AM

No but it shouldn't matter
Posted By: Spike

Re: Twitch link protection for multiple channels? - 20/02/16 05:25 AM

Originally Posted By: Wims
No but it shouldn't matter


Well its not working on twitch so thats prob why..
Posted By: westor

Re: Twitch link protection for multiple channels? - 20/02/16 09:04 AM

This code is working well stop blush, great job @Wims.

The problem is into your side.

1. Remove the old code before pasting the new that @Wims gave you.

2. Place the @Wims code into a new file into the 'Remotes' tab, make sure that the only code inside the file is @Wims code and only that.

3. Make sure you have enabled CAP support while connecting to twitch.tv in order to work the commands, paste this code into an new file into the Script Editor (ALT+R) -> Remotes tab, restart/reconnect the bot into the twitch server and retry.

4. Make sure you are using the latest mIRC version 7.43 in order to work.

If you follow these steps the code is going to work 99.9% , if you will not do any of these steps correct then it will never going to work in twitch.
Posted By: Wims

Re: Twitch link protection for multiple channels? - 20/02/16 01:09 PM

You said !links works, this means the on text event triggers, if it triggers, all of the code is working.
Check westor's post; for example if you forgot to replace the new code with the old one and still have the old one loaded in the same file as the new one (and the old one is first in the file), only !links will work because of my early error, and only one event is triggered per file, so the new code would not be triggered in this case.
That's likely the issue but there are various ways in which a correct code can fail, if you still need help you can join the channel in my signature and I'll help you there.
© 2021 mIRC Discussion Forums