CAPAB Addon — File Browser

CAPABAddonv2.0 / CAPABAddonv2.0 / capab / capab.mrc

capab.mrc — 7.42 KB — Download this file

on *:LOAD: {
  set %capab.enabled 1
  echo 6 -s CAPAB Script by KIA version 2.0.
  echo 6 -s io.dll Written by Saturn for mIRC 6.14-6.3
  echo 6 -s To enable the script, type /capab enable  
  echo 6 -s To start the script now, type /scon -a capab on
  if (!$isalias(msg)) .enable #repmsg

}

on *:UNLOAD: {
  capab.unset
}

on *:START: {
  capab.unset
}

on *:CONNECT: {
  unset %capab. [ $+ [ $cid ] $+ ] .*
  ;CAPAB option on, try to enable it
  if (%capab.enabled == 1) {
    .capab
  }
}

on *:DISCONNECT: {
  if ($hget(capab. $+ $cid)) hfree capab. $+ $cid
}

alias capab.auth {
  if ($hget(capab. $+ $cid ,$$1)) {
    if ($v1 == +) return $true
    return $false
  }
  return
}

alias capab {
  if ((!$show) || ($1 == on)) {
    .raw CAPAB IDENTIFY-MSG
    ;.raw CAPAB IDENTIFY-CTCP
    if ($show) echo -a Attempting to enable CAPAB...
    return
  }
  if ($1 == enable) {
    set %capab.enabled 1 
    echo -a CAPAB will attempt to start when connecting to a server
  }
  elseif ($1 == disable) {
    unset %capab.enabled
    echo -a CAPAB will NOT attempt to start when connecting to a server
  }
  else {
    echo -a CAPAB is only supported by certain IRC networks
    echo -a CAPAB will $iif(!%capab.enabled,not) be enabled when connecting to a server
    echo -a /capab on - Overrides the default connection setting to try and enable CAPAB on a server
    echo -a /capab enable - Enables CAPAB by default when connecting to a server
    echo -a /capab disable - Disables automatic startup of CAPAB on a server
    echo -a Note: Once CAPAB is enabled on a server, it can only be removed by disconnecting from the server
  }
}
alias io return $dll($scriptdirio.dll,$$1,$2-)

;Add privmsg rules to the io DLL for capab messages
alias capab.init.rules {
  io add -im ":& PRIVMSG & :-ACTION *" capab.io -m 
  io add -i $result ":& PRIVMSG & :+ACTION *" capab.io +m
  io add -i $result ":& NOTICE & :-*" capab.io -m
  io add -i $result ":& NOTICE & :+*" capab.io +m
  io add -im ":& PRIVMSG & :-*" capab.io -c
  io add -i $result ":& PRIVMSG & :+*" capab.io +c
  io add -im ":& PRIVMSG & :-*" capab.io -m
  io add -i $result ":& PRIVMSG & :+*" capab.io +m
}

alias -l capab.unset { 
  unset %capab.*
  hfree -w capab.*
}

alias capab.io {
  if (m isin $3) {
    if (!%capab. [ $+ [ $cid ] $+ ] .m) return 0
    hadd -m capab. $+ $cid $right($gettok($1,1,33),-1) $left($3,1)
    $io(recv,$regsubex($1,/:[+-]/,:))
    return 1
  }
  elseif (c isin $3) {
    if (!%capab. [ $+ [ $cid ] $+ ] .c) return 0
    hadd -m capab. $+ $cid $right($gettok($1,1,33),-1) $left($3,1)
    $io(recv,$regsubex($1,/:[+-]/,:))
    return 1
  }
  return 0
}

alias -l capab.nick {
  if (!$1) return
  ;Readini is for showing prefixes on nicks
  var %nick = $iif($gettok($readini($mircini,options,n2),30,44),$iif($3,$nick($3,$1).pnick,$1),$1)
  if ($2 == text) {
    if (($cnick($1)) && ($cnick($1).method isnum 0-1)) return $iif($cnick($1).color == $color(text),%nick, $+ $ifmatch $+ %nick $+  $+ $color(text))
  }
  return %nick
}
;CAPAB numeric
raw 290:*: {
  if ($2 == IDENTIFY-MSG) {
    set %capab. [ $+ [ $cid ] $+ ] .m 1 
    if (!%capab. [ $+ [ $cid ] $+ ] .c) capab.init.rules
  }
  if ($2 == IDENTIFY-CTCP) {
    set %capab. [ $+ [ $cid ] $+ ] .c 1
    if (!%capab. [ $+ [ $cid ] $+ ] .m) capab.init.rules
  }
  if (!$hget(capab. $+ $cid)) hmake capab. $+ $cid 100
  echo 6 -ts CAPAB Enabled for $2
  haltdef
}

;Unknown command
raw 421:*: {
  if (CAPAB isin $1-2) {
    echo -se CAPAB Protocol not supported by Server ( $+ $server $+ )
    haltdef
  }
}

on ^*:TEXT:*:#,?: {
  if (%capab. [ $+ [ $cid ] $+ ] .m) {
    if ($halted) return
    if ($highlight($1-) isin $1-) var %highl = 1
    else var %highl = 0
    window -g1 $iif($chan,$chan,$nick)
    echo $color(text) -t $+ $iif(%highl,l) $+ i2 $iif($chan,$chan,$nick) $iif($capab.auth($nick),+,-) < $+ $capab.nick($nick,text,$chan) $+ > $1-
    haltdef
  }
}

on ^*:ACTION:*:#,?: {
  if (%capab. [ $+ [ $cid ] $+ ] .m) {
    if ($halted) return
    if ($highlight($1-) isin $1-) var %highl = 1
    else var %highl = 0
    window -g1 $iif($chan,$chan,$nick)
    echo $color(action) --t $+ $iif(%highl,l) $+ i2 $iif($chan,$chan,$nick) $iif($capab.auth($nick),+,-) * $capab.nick($nick,action,$chan) $1-
    haltdef
  }
}

on ^*:NOTICE:*:#,?: {
  if (%capab. [ $+ [ $cid ] $+ ] .m) {
    if ($halted) return
    var %echonotice = $gettok($readini($mircini,options,n5),13,44)
    ;Channel notices
    if (($target ischan) || ($right($target,-1) ischan)) {
      var %message = $iif($capab.auth($nick),+,-) $+(-,$nick,:,$target,-) $1-
      var %ntarget = $iif($left($target,1) == $chr(35),$target,$right($target,-1))
      window -g1 %ntarget
      echo $color(notice) -ti2 %ntarget %message
      ;Check for echo to active screen settings
      if ((%echonotice) && ($active != %ntarget)) echo $color(notice) -tai2 %message
      halt
    }
    var %message = $iif($capab.auth($nick),+,-) $+(-,$nick,-) $1-

    ;Private notices
    if ($comchan($nick,0) > 0) {
      if (($nick ison $active) && ($cid == $activecid)) {
        echo $color(notice) -tai2 %message
        halt
      }
      var %c = 1 
      while (%c <= $comchan($nick,0)) {
        echo $color(notice) -ti2 $comchan($nick,%c) %message
        if (!%echonotice) window -g1 $comchan($nick,%c)
        inc %c
      }
      if (%echonotice) { echo $color(notice) -t $+ $iif($cid == $activecid,a,s) $+ i2 %message
        window -g1 $iif($cid == $activecid,$qt($active),"Status Window")
      }
      halt
    }
    echo $color(notice) -tsei2 %message
    window -g1 "Status Window"
    halt
  }
}

on *:INPUT:*: {
  if ($window($active).type !isin query channel) return
  if ((%capab. [ $+ [ $cid ] $+ ] .m != 1) || ($left($1,1) == $readini($mircini,text,commandchar))) return
  msg $active $1-
  haltdef
}

#repmsg off
alias msg {
  if (!$2) {
    echo $color(info) -si2 * /msg: insufficient parameters
    return
  }
  if (%capab. [ $+ [ $cid ] $+ ] .m != 1) {
    $iif($show,msg,.msg) $1-
    return
  }
  .msg $1-
  if (!$show) return
  if (!$window($1)) echo $color(text) -tai2 $iif(e isin $usermode,+,-) -> * $+ $capab.nick($1,text) $+ * $2-
  else {
    ;Check for mIRC's option for prefixing own messages
    if ($gettok($readini($mircini,options,n0),23,44)) { 
      %nick = < $+ $capab.nick($me,text,$iif($left($1,1) == $chr(35),$1)) $+ >
    }
    else var %nick = >
    ;Assuming usermode e is "registered"
    echo $color(text) -ti2 $1 $iif(e isin $usermode,+,-) %nick $2-
  }
}

alias describe {
  if (!$2) {
    echo $color(info) -si2 * /describe: insufficient parameters
    return
  }
  if (%capab. [ $+ [ $cid ] $+ ] .m != 1) {
    $iif($show,describe,.describe) $1-
    return
  }
  .describe $1-
  if (!$show) return
  if (!$window($1)) echo $color(action) -tai2 $iif(e isin $usermode,+,-) -> * $+ $1 $+ * $2-
  else {
    %nick = $capab.nick($me,action,$iif($left($1,1) == $chr(35),$1))
    ;Assuming usermode e is "registered"
    echo $color(action) -ti2 $1 $iif(e isin $usermode,+,-) * %nick $2-
  }
}

alias me {
  if ($window($active).type !isin query channel) {
    echo $color(info) -si2 * /me: cannot use /me in this window
    return
  }
  if (%capab. [ $+ [ $cid ] $+ ] .m != 1) {
    $iif($show,me,.me) $1-
    return
  }
  $iif($show,describe,.describe) $active $1-
  return
}
#repmsg end