mIRC Home    About    Download    Register    News    Help

Print Thread
Scripting a TwitchTV bot / Link time-out code #244069 21/01/14 04:22 PM
Joined: Jan 2014
Posts: 101
M
Majeye Offline OP
Vogon poet
OP Offline
Vogon poet
M
Joined: Jan 2014
Posts: 101
Ok, just wanted to let everyone know this is for a TwitchTV bot, which should help for responses.

I am having a bit of trouble getting the link time out code to work.. basically want it to work similar to nightbot, ironbot, moobot, etc.. when someone posts a link in chat, for the bot to time them out for 1 second to remove the link.. unless they have permission from a mod or myself to post the link.

I don't know what I did wrong for this code to not work, so any help would be appreciated.. but here is the code:

Code:
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 # $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 # My 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 # My Link Protection Is Now off in: $+($chr(2),#)
      halt | :d | .msg # $nick $+ , My link protection is already off . $&
        !
    }
  }

Re: Scripting a TwitchTV bot / Link time-out code [Re: Majeye] #244072 21/01/14 06:48 PM
Joined: Jan 2014
Posts: 101
M
Majeye Offline OP
Vogon poet
OP Offline
Vogon poet
M
Joined: Jan 2014
Posts: 101
Anyone?

Re: Scripting a TwitchTV bot / Link time-out code [Re: Majeye] #244073 21/01/14 06:56 PM
Joined: Jan 2004
Posts: 1,276
L
Loki12583 Offline
Hoopy frood
Offline
Hoopy frood
L
Joined: Jan 2004
Posts: 1,276
All I did was restructure the (awful) goto statements and everything seems to be working. Would you mind debugging some yourself to see where something is going wrong, and providing reproducible steps, with your expected and actual results?

(these events need to be in their own file)

Code:
on @*:text:*:#:linkpost $1-
on @*:action:*:#:linkpost $1-
on @*:notice:*:#:linkpost $1-
alias -l linkpost {
  if (%p) || ($hfind(permit,$nick)) { return }

  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 # $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 #) {
    if (!$istok(%chanon1,#,32),a,b) {
      set %chanon1 $addtok(%chanon,#,32)
      .msg # My Link Protection Is Now on in: $+($chr(2),#)
      halt
    }
    else {
      .msg # $nick $+ , my link protection is already on in $+($chr(2),#,$chr(2),!)
    }
  }
  elseif ($regml(1) == link off) && ($nick isop #) {
    if ($istok(%chanon1,#,32),c,d) {
      set %chanon1 $remtok(%chanon,#,1,32)
      .msg # My Link Protection Is Now off in: $+($chr(2),#)
      halt
    }
    else {
      .msg # $nick $+ , My link protection is already off!
    }
  }
}


Edit: This is a slow moving forum, no need to bump posts so soon (or ever)

Last edited by Loki12583; 21/01/14 06:59 PM.
Re: Scripting a TwitchTV bot / Link time-out code [Re: Loki12583] #244074 21/01/14 07:53 PM
Joined: Jan 2014
Posts: 101
M
Majeye Offline OP
Vogon poet
OP Offline
Vogon poet
M
Joined: Jan 2014
Posts: 101
For some reason, it still isn't working..

I may just have to scrap the script and start over. frown

Re: Scripting a TwitchTV bot / Link time-out code [Re: Majeye] #244075 21/01/14 08:40 PM
Joined: Apr 2013
Posts: 27
R
RuLerZ Offline
Ameglian cow
Offline
Ameglian cow
R
Joined: Apr 2013
Posts: 27
Loki12583 your awesome!

Why dont you just do a check for text entered as *Http://* || *www*?

Re: Scripting a TwitchTV bot / Link time-out code [Re: Majeye] #244086 23/01/14 04:24 AM
Joined: Jan 2014
Posts: 101
M
Majeye Offline OP
Vogon poet
OP Offline
Vogon poet
M
Joined: Jan 2014
Posts: 101
I got this script to work... now I can't figure out timed scripts... totally greek to me.

anyone know how to get a timed script to work, one that works without executing a command?

Re: Scripting a TwitchTV bot / Link time-out code [Re: Majeye] #244088 23/01/14 08:18 AM
Joined: Jan 2014
Posts: 101
M
Majeye Offline OP
Vogon poet
OP Offline
Vogon poet
M
Joined: Jan 2014
Posts: 101
I fixed the link protection with this code:

Quote:
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(%chanon,#,1,32)) && ($nick(#,$nick,vr)) && ($regex($1-,%link)) {
kick # $nick | /mode # -b $nick
msg # $nick You did not have permission to post a link ask a mod to !permit $nick
msg $chan /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!
}
elseif (($regml(1) = link on) && ($nick isop #)) {
goto $iif(!$istok(%chanon,#,32),a,b) | :a | set %chanon $addtok(%chanon,#,32)
.msg # My 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(%chanon,#,32),c,d) | :c | set %chanon $remtok(%chanon,#,1,32)
.msg # My Link Protection Is Now off in: $+($chr(2),#)
halt | laugh | .msg # $nick $+ , My link protection is already off . $&
!
}
}
}

Re: Scripting a TwitchTV bot / Link time-out code [Re: Majeye] #244089 23/01/14 08:19 AM
Joined: Jan 2014
Posts: 101
M
Majeye Offline OP
Vogon poet
OP Offline
Vogon poet
M
Joined: Jan 2014
Posts: 101
Does anyone know how to make the link protection multi-channel though?

for some reason I can only get this to work in one channel at a time