mIRC Home    About    Download    Register    News    Help

Print Thread
Twitch link protection for multiple channels? #256817 19/02/16 07:57 PM
Joined: Sep 2014
Posts: 46
S
Spike Offline OP
Ameglian cow
OP Offline
Ameglian cow
S
Joined: Sep 2014
Posts: 46
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
    }
  }
} 

Re: Twitch link protection for multiple channels? [Re: Spike] #256819 19/02/16 08:10 PM
Joined: Jan 2004
Posts: 1,286
L
Loki12583 Online
Hoopy frood
Online
Hoopy frood
L
Joined: Jan 2004
Posts: 1,286
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

Re: Twitch link protection for multiple channels? [Re: Spike] #256822 19/02/16 08:48 PM
Joined: Jul 2006
Posts: 3,702
W
Wims Offline
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 3,702
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))
}

Last edited by Wims; 19/02/16 09:55 PM.

Looking for a good help channel about mIRC? Check #mircscripting @ irc.swiftirc.net
Re: Twitch link protection for multiple channels? [Re: Wims] #256823 19/02/16 09:00 PM
Joined: Sep 2014
Posts: 46
S
Spike Offline OP
Ameglian cow
OP Offline
Ameglian cow
S
Joined: Sep 2014
Posts: 46
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

Re: Twitch link protection for multiple channels? [Re: Spike] #256825 19/02/16 09:55 PM
Joined: Jul 2006
Posts: 3,702
W
Wims Offline
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 3,702
I edited the code, there was one extra '}'


Looking for a good help channel about mIRC? Check #mircscripting @ irc.swiftirc.net
Re: Twitch link protection for multiple channels? [Re: Wims] #256826 19/02/16 10:19 PM
Joined: Sep 2014
Posts: 46
S
Spike Offline OP
Ameglian cow
OP Offline
Ameglian cow
S
Joined: Sep 2014
Posts: 46
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.

Re: Twitch link protection for multiple channels? [Re: Spike] #256827 19/02/16 11:03 PM
Joined: Jul 2006
Posts: 3,702
W
Wims Offline
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 3,702
I tested the code, everything worked


Looking for a good help channel about mIRC? Check #mircscripting @ irc.swiftirc.net
Re: Twitch link protection for multiple channels? [Re: Wims] #256830 20/02/16 12:06 AM
Joined: Sep 2014
Posts: 46
S
Spike Offline OP
Ameglian cow
OP Offline
Ameglian cow
S
Joined: Sep 2014
Posts: 46
Originally Posted By: Wims
I tested the code, everything worked


Did you test it on twitch?

Re: Twitch link protection for multiple channels? [Re: Spike] #256834 20/02/16 12:54 AM
Joined: Jul 2006
Posts: 3,702
W
Wims Offline
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 3,702
No but it shouldn't matter


Looking for a good help channel about mIRC? Check #mircscripting @ irc.swiftirc.net
Re: Twitch link protection for multiple channels? [Re: Wims] #256836 20/02/16 05:25 AM
Joined: Sep 2014
Posts: 46
S
Spike Offline OP
Ameglian cow
OP Offline
Ameglian cow
S
Joined: Sep 2014
Posts: 46
Originally Posted By: Wims
No but it shouldn't matter


Well its not working on twitch so thats prob why..

Re: Twitch link protection for multiple channels? [Re: Spike] #256837 20/02/16 09:04 AM
Joined: Dec 2008
Posts: 1,511
westor Offline
Hoopy frood
Offline
Hoopy frood
Joined: Dec 2008
Posts: 1,511
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.

Re: Twitch link protection for multiple channels? [Re: Spike] #256839 20/02/16 01:09 PM
Joined: Jul 2006
Posts: 3,702
W
Wims Offline
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 3,702
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.


Looking for a good help channel about mIRC? Check #mircscripting @ irc.swiftirc.net