Search code examples
mirc

Modifying a Link Bot for MIRC


With the help of @Sirius_Black I set up this link monitoring bot for MIRC/Twitch.

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|se|eu|fr|me|nl|de|Q
    var %exception /(?:http?:\/\/)?(?:w{3}\.)?.+(ftr.wot-news|youtu|youtube|\Qimgur\E)\.com|.be/
    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 # /me $nick $+ , you did not have permission to post a link. Type '!permit' to get a mod to allow links for you. Please avoid putting '.it' anywhere in your text.
      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 # /me $$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 . $&
        !
    }
  }
}

The system works fantastically. However, is there a text command script I can add to this that allows any user to, for example, type !link and have the bot respond whether Link Protection is on/off?

Right now, it seems only a mod can turn the bot on or off (with a message telling it's on/off). But is there a way of just sending out a command with the response that checks whether the bot is on/off?

Sorry if I was repetitive.

Thanks!


Solution

  • use this one
    type !links

    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)|(links))\b/iS
    var %domain com|edu|gov|mil|net|org|biz|info|name|museum|us|ca|uk|tv|se|eu|fr|me|nl|de|Q
    var %exception /(?:https?:\/\/)?(?:w{3}\.)?.+(ftr.wot-news|youtu|youtube|\Qimgur\E)\.com|.be/
    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 # /me $nick $+ , you did not have permission to post a link. Type '!permit' to get a mod to allow links for you. Please avoid putting '.it' anywhere in your text.
      msg # /timeout $nick 1
    }
    if ($regex($1-,%purge)) && ($regml(1) == links) {
      msg $chan Link Protection for channel $chan is: $iif($istok(%chanon1,$chan,32),on,off)
    }
    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 # /me $$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 . $&
        !
    }
    }
    }