aIRC — File Browser

aIRCv0.8.69 / aIRCv0.8.69 / script / alias2.mrc

alias2.mrc — 21.12 KB — Download this file

;/**********************************************************************
; *
; * aIRC
; * Loading remote files on demand...
; *
; **********************************************************************/
;
aircdebug {
  if ($istok(on off,$1,32)) {
    _setsetup script _aircdebug $iif($1 == on,1,0)
    if ($1 == on) { _quickloadall }
    else { _quickunloadall }
  }
  if ($show) { info.a aIRC debug is  $+ $iif($_getsetup(script,_aircdebug),ON,OFF) }
}

_quickload {
  var %file = $mircdirscript\ $+ $1
  _loadremotefile + %file
  if ($2- != $null) && ($isalias($2)) { $2- }
}
_quickunload {
  if ($_getsetup(script,_aircdebug)) { return }
  .timer -o 1 0 _~quickunload $1-
}
_~quickunload {
  var %d = $1,%i = $numtok(%d,44),%file = script\ $+ $2
  while (%i) {
    if ($dialog($gettok(%d,%i,44))) { return }
    dec %i
  }
  if (\ isin $2-) { %file = $2- }
  if ($script(%file) != $null) { .unload -rs " $+ %file $+ " }
}
servers { _quickload servers.mrc _servers.dialog $1- }
cpanel { _quickload setup.mrc _cpanel $1- }
setup { _quickload setup.mrc _setup $1- }
msgedit { _quickload setup.mrc _msgedit $1- }
fkeys { _quickload setup.mrc _fkeys $1- }
userlist { _quickload userlist.mrc _userlist $1- }
user { _quickload userlist.mrc _user $1- }
importuf { _quickload userlist.mrc _importuf $1- }
usermode { _quickload usermode.mrc _usermode $1- }
profiles { _quickload profiles.mrc _profiles $1- }
chansetup { _quickload chansetup.mrc _chansetup $1- }
plsetup { _quickload plsetup.mrc _plsetup $1- }
pprot { _quickload pprotsetup.mrc _pprot $1- }
cprot { _quickload cprotsetup.mrc _cprot $1- }
_protaction { _quickload protaction.mrc _protaction.opendialog $1- }
help { _quickload help.mrc _airchelp $1- }
nsetup { _quickload network.mrc _nsetup $1- }
weed { _quickload weed.mrc _weed $1- }

_quickunloadall {
  if ($_getsetup(script,_aircdebug)) { return }
  _~quickunload chansetup                      $mircdirscript\chansetup.mrc
  _~quickunload cprot,_protlist                $mircdirscript\cprotsetup.mrc
  _~quickunload airchelp                       $mircdirscript\help.mrc
  _~quickunload _nsetup                        $mircdirscript\network.mrc
  _~quickunload partylinesetup                 $mircdirscript\plsetup.mrc
  _~quickunload pprot                          $mircdirscript\pprotsetup.mrc
  _~quickunload _profiles,_newprofile          $mircdirscript\profiles.mrc
  _~quickunload _protaction                    $mircdirscript\protaction.mrc
  _~quickunload _servers                       $mircdirscript\servers.mrc
  _~quickunload _cpanel,_setup,_msgedit,_fkeys $mircdirscript\setup.mrc
  _~quickunload userlist,_user,importuf        $mircdirscript\userlist.mrc
  _~quickunload usermode                       $mircdirscript\usermode.mrc
  _~quickunload _weed                          $mircdirscript\weed.mrc
}
_quickloadall {
  _quickload servers.mrc
  _quickload setup.mrc
  _quickload userlist.mrc
  _quickload usermode.mrc
  _quickload profiles.mrc
  _quickload chansetup.mrc
  _quickload plsetup.mrc
  _quickload pprotsetup.mrc
  _quickload cprotsetup.mrc
  _quickload protaction.mrc
  _quickload help.mrc
  _quickload network.mrc
  _quickload weed.mrc
}

;/**********************************************************************
; *
; * aIRC
; * huh?
; *
; **********************************************************************/
;

tbar {
  if ($1 == on) { _setsetup script _titlebar.update 1 }
  elseif ($1 == off) {
    _setsetup script _titlebar.update 0
    titlebar
  }
  var %state = $_getsetup(script,_titlebar.update)
  if (%state) { %_titlebar = $iif($_getsetup(script,_titlebar.tags),$_getsetup(script,_titlebar.tags),<DUMMY>) }
  else { unset %_titlebar }
  if ($show) { info.a Titlebar update is  $+ $iif(%state,ON,OFF) }
}

; /_loadremotefile +flags file
; flags: r - reload if it's already loaded
;        e - echo load/unload messages
_loadremotefile {
  if ($isfile($2-)) {
    if ($script($2-)) {
      if (r isin $1) { $iif(e isin $1,reload,.reload) -rs $+ $calc($script(0) - 7) " $+ $2- $+ " }
    }
    else { $iif(e isin $1,load,.load) -rs $+ $calc($script(0) - 7) " $+ $2- $+ " }
  }
}
_loadingsetuponstart {
  _start
  _miniprogress 95
  _nickol.fix
  if ($_getsetup(email,pop3.autover)) { chmails }
  if ($_getsetup(script,_readnotes)) { .notes read }
  ;  if ($_getsetup(script,_checkver)) { checkver 1 }
  _setsetup script _session $calc(1 + $iif($_getsetup(script,_session) isnum,$_getsetup(script,_session),0))
  _tnick.reset
  _start.users
  _start.ignores
  _start.bans
  _start.notes
  _start.sstatus
  _start.filelist
  _start.themes
  if ($hget(_aircjunk) == $null) { hmake _aircjunk 15 }
  writeini " $+ $_tmpdir(session.ini) $+ " script uptime $ctime
  _miniprogress 97
  var %dir = $mircdir $+ etc\,%tmp = $findfile(%dir,tabo*.bmp,0,1,.remove " $+ $1- $+ "),%load

  if ($_getsetup(script,_session) <= 1) { lang }

  if ($_getsetup(script,_session) <= 1) || ($_getsetup(script,onstart.about)) { %load = about }
  if ($_getsetup(script,onstart.tipofday)) { %load = %load tip }
  if (%load != $null) { .timer -o 1 0 $ifmatch }
  _remove $_scriptini
  _hook.call loadingsetuponstart
}
_loadsetup {
  unset %_*
  if ($hget(_aircjunk) == $null) { hmake _aircjunk 15 }
  _loadhashmainsetup

  if ($_getsetup(dcc,maxcps.state)) && ($_isint($_getsetup(dcc,maxcps.value))) { .dcc maxcps $ifmatch }
  else { .dcc maxcps off }
  .pdcc $iif($_getsetup(dcc,pdcc.state),on,off)
  .fsend $iif($_getsetup(dcc,fsend),on,off)
  if ($_isint($_getsetup(dcc,packetsize))) { .dcc packetsize $ifmatch }

  if ($_getsetup(away,autoaway.status)) {
    if ($_isint($_getsetup(away,autoaway.time))) { %_away.autot = $ifmatch }
  }
  if ($_getsetup(script,_sound)) { inc %_sound }
  if ($_getsetup(script,_partylinemonitor)) { inc %_partylinemonitor }
  if ($_getsetup(script,_partyline)) { .partyline on }
  else { .partyline off }
  $iif($_getsetup(script,_rcctcp),.enable,.disable) #_rcctcp
  $iif($_getsetup(script,_rctext),.enable,.disable) #_rctext
  %_maskclon = $_getsetup(script,_mask.clones)
  %_masknorm = $_getsetup(script,_mask.default)
  %_maskuser = $_getsetup(script,_mask.user)
  _loadsetup.nicklistcol
  .tbar
  if ($_getsetup(script,_nofloodtlag.o)) {
    if ($_isint($_getsetup(script,_nofloodtlag.t))) { %_nofloodtlag = $ifmatch }
  }
  _prot.init
  _hook.call loadsetup
}
_start {
  if ($hget(_aircjunk) == $null) { hmake _aircjunk 15 }
  hdel -w _aircjunk _autoidnick_*
  _fixstuff
  .dccserver on 59
  unset %.lag.* %~* %Ø* %¶* %c.nomsgauto1
  _maintimer
  _loadsetup
}
_start.users {
  _start.users.newfile
  var %f = $_userinifile,%i = 1,%t = $_countusers,%handle,%hosts
  while (%i <= %t) {
    %handle = $_ruini($ini(%f,%i),handle)
    %hosts = $_ruini(%handle,hosts)
    var %m =  1,%n = $numtok(%hosts,32)
    while (%m <= %n) {
      _auser %handle $gettok(%hosts,%m,32)
      inc %m
    }
    inc %i
  }
}
_start.users.newfile {
  var %file = $readini -n " $+ $mircini $+ " rfiles n0,%file = " $+ %file $+ "
  write -c %file
  write %file ;/**********************************************************************
  write %file ; *
  write %file ; * aIRC
  write %file ; * Userlist
  write %file ; *
  write %file ; * to edit use /userlist
  write %file ; *
  write %file ; * [Autogenerated from " $+ $_fixfilename($_userinifile,m) $+ " $+ ]
  write %file ; *
  write %file ; * DON'T EDIT THIS FILE MANUALLY!!
  write %file ; *
  write %file ; **********************************************************************/
  write %file ;
  .reload -ru %file
}
_start.dirs {
  var %i,%udir = $mircdir $+ usr\,%dir
  mkdir addons
  mkdir addons\tschemes
  mkdir download
  mkdir etc
  mkdir etc\ascii
  mkdir etc\bmps
  mkdir etc\help
  mkdir etc\icons
  mkdir etc\text
  mkdir etc\tmp
  mkdir logs
  mkdir sounds
  mkdir themes
  mkdir " $+ %udir $+ "
  mkdir " $+ $_usrdir $+ "
  %i = $finddir(%udir,*,0,1)
  while (%i) {
    %dir = $finddir(%udir,*,%i,1) $+ \
    mkdir " $+ %dir $+ recent $+ "
    mkdir " $+ %dir $+ lists $+ "
    mkdir " $+ %dir $+ misc $+ "
    dec %i
  }
}
_miniprogress.close {
  if ($dialog(_aIRCminiprogress)) { dialog -x _aIRCminiprogress }
}
pbaronstart {
  if ($istok(on off,$1,32)) { writeini " $+ $_mainini $+ " main pbaronstart $iif($1 == on,1,0) }
  if ($show) { info.a Pbar on start is  $+ $iif($_readini($_mainini,main,pbaronstart),ON,OFF) }
}
_onctcp {
  unset %+ctcp.* %+dcc.*
  if ($1 == dcc) && ($istok(chat send accept resume,$2,32)) && (%::chan == $null) {
    if ($2 == chat) {
      %+dcc.longip = $4
      %+dcc.ip = $longip($4)
      %+dcc.port = $5
    }
    elseif ($2 == send) {
      %+dcc.size = $gettok($1-,$0,32)
      %+dcc.port = $gettok($1-,$calc($0 - 1),32)
      %+dcc.longip = $gettok($1-,$calc($0 - 2),32)
      %+dcc.file = $remove($gettok($1-,3- [ $+ [ $calc($0 - 3) ] ] ,32),$chr(34))
      %+dcc.ip = $longip(%+dcc.longip)
    }
    elseif ($istok(accept resume,$2,32)) {
      %+dcc.size = $gettok($1-,$0,32)
      %+dcc.port = $gettok($1-,$calc($0 - 1),32)
      %+dcc.file = $remove($gettok($1-,3- [ $+ [ $calc($0 - 2) ] ] ,32),$chr(34))
    }

    if (($istok(send chat,$2,32)) && (%+dcc.ip == $null)) || (%+dcc.port == $null) || (($2 != chat) && ((%+dcc.size == $null) || (%+dcc.file == $null))) { %+dcc.badcc = parameters }
    elseif (. isin %+dcc.port) || ($_not($_isint(%+dcc.port))) || (%+dcc.port < 1024) || (%+dcc.port > 65535) { %+dcc.badcc = port }
    elseif ($istok(accept resume send,$2,32)) && (($nopath(%+dcc.file) != %+dcc.file) || ($_fixfilename(%+dcc.file,m) == $null)) { %+dcc.badcc = file }
    elseif ($istok(accept resume send,$2,32)) && ((. isin %+dcc.size) || ($_not($_isint(%+dcc.size)))) { %+dcc.badcc = size }
    elseif ($istok(send chat,$2,32)) && (($_not($_isip(%+dcc.ip))) || (127.* iswm %+dcc.ip) || (*.255 iswm %+dcc.ip) || (*.0 iswm %+dcc.ip)) { %+dcc.badcc = ip }
    else { return }
  }
  %+ctcp.show = 1
  %+ctcp.hideparms = 0
  %+ctcp.reply = 0
  %+ctcp.replymsg = $null
  if (%::nick == %::me) && (airc_* iswm $1) { %+ctcp.show = 0 }
  elseif ($istok(ping version clientinfo finger time userinfo,$1,32)) {
    %+ctcp.reply = 1
    if ($1 == ping) {
      %+ctcp.replymsg = PING $2-
      %+ctcp.hideparms = 1
    }
    elseif ($1 == version) {
      if (%~noversion) { %+ctcp.reply = 0 }
      else {
        ; this should be: %+ctcp.reply = 1
        %+ctcp.reply = $iif($event == ctcp,0,1)
        %+ctcp.replymsg = VERSION $_aircad(+)
      }
      ;      set -u15 %~noversion 1
      halt
    }
    elseif ($1 == clientinfo) { %+ctcp.replymsg = clientinfo ACTION CLIENTINFO DCC FINGER PAGE PING SOUND TIME USERINFO VERSION }
    elseif ($1 == time) { %+ctcp.replymsg = time $asctime($ctime) }
    elseif ($istok(finger userinfo,$1,32)) { %+ctcp.replymsg = $1 Idle $idle seconds }
  }
  if ($_getsetup(script,_ctcpcloak)) { %+ctcp.reply = 0 }
}
; $_f2w_a2r(file,window,flags)
; file->window
; alias-> remotes
; flags:
;   +l  - aliases will be local aliases
_f2w_a2r {
  var %file = $1,%win = $2,%flags = $3,%tmpfile,%alias = alias
  if ($isfile(%file) == $false) { return }
  _openwins %win
  %tmpfile = $_tmpdir($nopath(%file))
  write -c " $+ %tmpfile $+ "
  if (l isin %flags) { %alias = alias -l }
  .copy -o " $+ %file $+ " " $+ %tmpfile $+ "
  loadbuf %win " $+ %tmpfile $+ "
  var %wm = ?* ?*,%i = $fline(%win,%wm,0,0),%line,%first
  while (%i) {
    var %num = $fline(%win,%wm,%i,0),%line = $line(%win,%num),%first = $left(%line,1)
    if (%first != $null) && (%first != $chr(59)) && (%first != $chr(32)) { rline %win %num %alias %line }
    dec %i
  }
  .remove " $+ %tmpfile $+ "
}
; $_f2w_r2lr(file,window,flags)
; file->window
; alias-> remotes
; flags:
_f2w_r2lr {
  var %file = $1,%win = $2,%flags = $3,%tmpfile,%alias = alias -l
  if ($isfile(%file) == $false) { return }
  _openwins %win
  %tmpfile = $_tmpdir($nopath(%file))
  write -c " $+ %tmpfile $+ "
  .copy -o " $+ %file $+ " " $+ %tmpfile $+ "
  loadbuf %win " $+ %tmpfile $+ "
  var %wm = alias ?*,%i = $fline(%win,%wm,0,0),%line,%first
  while (%i) {
    var %num = $fline(%win,%wm,%i,0),%line = $line(%win,%num)
    if ($gettok(%line,1-2,32) != alias -l) { rline %win %num %alias $gettok(%line,2-,32) }
    dec %i
  }
  .remove " $+ %tmpfile $+ "
}
_lang.loaddialog {
  var %d = $1,%type = $2,%minver = $3,%file = $4,%dir = $5 $+ \ $+ language\,%lang = $_getlang,%file = %dir $+ %lang $+ %file,%file = $_fixfilename(%file,e),%tmp
  if (%file == $null) || ($dialog(%d) == $null) { return }
  var %file = " $+ %file $+ ",%tmp = $read -nsaIRCminver %file
  if (%tmp < %minver) { return }
  var %win = @__langloaddialog
  _openwins %win
  filter -fw %file %win %type *
  var %i = 1,%n = $line(%win,0)
  while (%i <= %n) {
    tokenize 32 $line(%win,%i)
    if ($2 isnum 1-3000) || (($chr(44) isin $2) && ($remove($2,$chr(44)) isnum)) {
      if (p isin $3) { did -o %d $2 $4- }
      else {
        if (r isin $3) { did -r %d $2 }
        var %com,%string
        if (l isin $3) && ($4 isnum) { var %com = did -o %d $2 $4,%string = $5- }
        elseif (a isin $3) { var %com = did -a %d $2,%string = $4- }
        else { var %com = did -o %d $2 1,%string = $4- }
        if (%string != $null) && (e isin $3) { %string = $_evaltext(%string) }
        %com %string
      }
    }
    elseif ($2 == title) { dialog -t %d $4- }
    inc %i
  }
  close -@ %win
}
;/**********************************************************************
; *
; * aIRC
; * Scriptsize...
; *
; **********************************************************************/
;
scriptsize {
  var %i = 1,%sa = 0,%la = 0,%f,%files
  while (%i <= $alias(0)) {
    %f = $alias(%i)
    if ($istok(%files,%f,44) == $false) {
      if (*.ini iswm %f) { %files = $addtok(%files,%f,44) }
      inc %sa $file(%f).size
      inc %la $lines(%f)
    }
    inc %i
  }
  var %i = 0,%sp = 0,%lp = 0,%f
  while (%i <= 4) {
    %f = $readini -n " $+ $mircini $+ " pfiles n [ $+ [ %i ] ]
    if ($istok(%files,%f,44) == $false) {
      if (*.ini iswm %f) { %files = $addtok(%files,%f,44) }
      inc %sp $file(%f).size
      inc %lp $lines(%f)
    }
    inc %i
  }
  var %i = 1,%sr = 0,%lr = 0,%f
  while (%i <= $script(0)) {
    %f = $script(%i)
    if ($istok(%files,%f,44) == $false) {
      if (*.ini iswm %f) { %files = $addtok(%files,%f,44) }
      if ($nopath(%f) != mierda.mrc) {
        inc %sr $file(%f).size
        inc %lr $lines(%f)
      }
    }
    inc %i
  }
  info.a SIZE: a: %sa r: %sr p: %sp TOTAL: $calc(%sa +%sr + %sp)
  info.a LINE: a: %la r: %lr p: %lp TOTAL: $calc(%la +%lr + %lp)
}
;/**********************************************************************
; *
; * aIRC
; * misc stuff
; *
; **********************************************************************/
;
_setmymode {
  if ($_reqchangemodes($remove($usermode,-,+),$remove($1,-,+)) != $null) {
    var %mode = $_fixmodes($ifmatch),%fmode = %mode,%i = 1,%t
    while ($mid(%mode,%i,1)) {
      %t = $mid(%mode,$calc(%i + 1),1)
      if ($ifmatch == +) && (%t !isincs %.usermodes) { %fmode = $removecs(%fmode,$_nospaces(+,%t)) }
      inc %i 2
    }
    if ($_unfixmodes(%fmode) != $null) { mode $me $ifmatch }
  }
}
_togglechanmodes {
  if ($2 === k) {
    if ($_ischanmode($1,k)) { mode $1 -k $chan($1).key }
    else { mode $1 +k $_param(1,$null,Channel key:)) }
  }
  elseif ($2 === l) {
    if ($_ischanmode($1,l)) { mode $1 -l }
    else { mode $1 +l $_param(isint,$null,Max users in channel:) }
  }
  else { mode $1 $iif($_ischanmode($1,$2),-,+) $+ $2 }
}
_playwin {
  var %i = 1,%n = $line($1,0)
  while (%i <= %n) {
    $replace($2-,,$line($1,%i))
    inc %i
  }
}
_inifont2winfont {
  tokenize 32 $1-
  var %win = $1,%size = $2,%font = $3-,%bold
  if (%size > 700) {
    dec %size 700
    %bold = -b
  }
  if (%size > 400) { dec %size 400 }
  font %bold %win %size %font
}
_checkemptychan { .timer__checkemptychan $+ $1 1 1 _~checkemptychandoit $1 }
_~checkemptychanoff { .timer__checkemptychan $+ $1 off }
_~checkemptychandoit {
  var %chan = $1,%text
  if ($me !ison %chan) || ($me isop %chan) || (+* iswm %chan) { return }
  if ($nick(%chan,0) == 1) && ($_rchini(cycle,%chan)) && ($_not($_ischanmode(%chan,r))) {
    %text = Trying to cycle %chan to regain ops.
    info.s %text
    _putlog %text
    .rejoin %chan
  }
}
_onopen.query {
  if ($_getsetup(script,_logquery)) && ($_logfile($1)) {
    clear $1
    loadbuf 100 -p $1 " $+ $ifmatch $+ "
  }
  if ($_getsetup(script,_chansquery)) {
    if ($comchan($1,0)) { info.w $1 Common channels with $1 $+ : $_comchansattr($1) }
    else { info.w $1 No common channels with $1 }
  }
}
; _enforce.topic <channel> [topic]
_enforce.topic {
  var %chan = $1,%t = chantopic $+ %chan,%enforced,%topic
  if ($me !isop %chan) || ($_not($_rchini(chantopic,%chan))) { return 0 }
  if ($_rinitxt(%t) != $null) || ($_rinitxt(chantopic) != $null) { %enforced = $_evaltext($replace($ifmatch,<CHAN>,%chan)) }
  if ($2- != $null) { %topic = $2- }
  else { %topic = $chan(%chan).topic }
  if (%enforced != %topic) {
    .quote topic %chan : $+ %enforced
    return 1
  }
  return 0
}
; _enforce.modes <channel> [modes]
_enforce.modes {
  tokenize 32 $1-
  var %chan = $1,%t = chanmode $+ %chan,%enforced,%enforcedmodes,%enforcedkey,%enforcedlimit,%changedmodes,%signo,%mode,%shit,%currentkey = $chan(%chan).key,%currentlimit = $chan(%chan).limit,%i = 0,%ircchanmodes
  if ($me !isop %chan) || ($_not($_rchini(chanmode,%chan))) { return 0 }
  if ($_rinitxt(%t) != $null) || ($_rinitxt(chanmode) != $null) { %enforced = $ifmatch }
  %enforcedmodes = $_fixmodes($gettok(%enforced,1,32))
  if (+k isincs %enforcedmodes) {
    if (+l isincs %enforcedmodes) { %enforcedkey = $gettok(%enforced,$iif($pos(%enforcedmodes,+k) < $pos(%enforcedmodes,+l),2,3),32) }
    else { %enforcedkey = $gettok(%enforced,2,32) }
  }
  if (+l isincs %enforcedmodes) {
    if (+k isincs %enforcedmodes) { %enforcedlimit = $gettok(%enforced,$iif($pos(%enforcedmodes,+l) < $pos(%enforcedmodes,+k),2,3),32) }
    else { %enforcedlimit = $gettok(%enforced,2,32) }
  }
  if (%enforcedmodes == $null) { return }
  if ($2- != $null) { %changedmodes = $_fixmodes($2) }
  %ircchanmodes = $_fixmodes($gettok($chan(%chan).mode,1,32))
  while ($mid(%enforcedmodes,1,2) != $null) {
    var %signo = $mid(%enforcedmodes,1,1),%mode = $mid(%enforcedmodes,2,1),%t = %signo $+ %mode,%zi = 0
    if ((%mode isincs %changedmodes) && ($mid(%enforcedmodes,1,2) !isincs %changedmodes)) || ((%signo == +) && (%mode !isincs %changedmodes)) {
      inc %i
      inc %zi
    }
    if ((%mode isincs %ircchanmodes) && ($mid(%enforcedmodes,1,2) !isincs %ircchanmodes)) || ((%signo == +) && (%mode !isincs %ircchanmodes)) || ((%t === +k) && (%enforcedkey != %currentkey)) || ((%t === +l) && (%enforcedlimit != %currentlimit)) { inc %zi }
    if (%zi) {
      if (%t === +k) {
        if (%enforcedkey != $null) && (%enforcedkey != %currentkey) {
          if (k isincs $gettok($chan(%chan).mode,1,32)) { .quote mode %chan -k %currentkey }
          _chanmode %chan +k %enforcedkey
        }
      }
      elseif (%t == -k) { _chanmode %chan -k %currentkey }
      elseif (%t === +l) {
        if ($_isint(%enforcedlimit)) && (%enforcedlimit != %currentlimit) { _chanmode %chan +l %enforcedlimit }
      }
      else { _chanmode %chan %t }
    }
    %enforcedmodes = $right(%enforcedmodes,-2)
  }
  _chanmode.flush
  return %i
}
; _autolimit.chan
_autolimit.chan {
  var %chan = $1,%opt
  .timer_autolimit. $+ %chan off
  if ($me !isop %chan) { return }
  %opt = $_rchini(_autolimiter,%chan)
  tokenize 32 %opt
  if ($1) && ($0 == 3) && ($_isint($_nospaces($2-3))) {
    var %int = $2,%+usrs = $3,%last = $_get(junk,_autolimit,%chan),%newlimit
    if (%last > $ctime) { %last = $ctime - 60 }
    if (%last == $null) || ($calc(%last + %int) < $ctime) {
      .timer_autolimit. $+ %chan 1 %int _autolimit.chan %chan
      _setd junk _autolimit %chan $ctime
      %newlimit = $nick(%chan,0) + %+usrs
      if ($chan(%chan).limit != %newlimit) { mode %chan +l %newlimit }
    }
    else { .timer_autolimit. $+ %chan 1 $calc(%int - $ctime + %last) _autolimit.chan %chan }
  }
}

; /_automsghtchan #chan $nick command
_automsghtchan {
  if (%c.nomsgauto == $null) {
    inc -u20 %c.nomsgauto
    $3-
  }
}

; /_automsg.onjoinpart <on|off> <msg|notice> <text>
_automsg.onjoinpart {
  var %command = _puthelp $nick & $iif($2,_qprivmsg,_qnotice) $nick
  if ($_evaltext($3-) != $null) { %command $ifmatch }
}

; /_filtercom <nick1,nick2> <mask type> <command>
_filtercom {
  var %nick,%type = $2,%command = $3-,%mask,%fulladdress,%i,%n,%cnick,%done
  if ($1 == $null) { return }
  %i = 1
  %n = $numtok($1,44)
  while (%i <= %n) {
    %nick = $gettok($1,%i,44)
    %fulladdress = $_address(%nick,5)
    if (%fulladdress == $null) || ($istok(0.0.0.0 x.x.x.x,$gettok(%fulladdress,2,64),32)) { $replace(%command,<TARGET>,%nick) }
    else {
      %mask = $_mask(%fulladdress,%type)
      if ($istok(%done,%mask,44) == $false) { $replace(%command,<TARGET>,%mask) }
      if ($len(%mask) > 900) { %done = $deltok(%done,1,44) }
      %done = $addtok(%done,%mask,44)
    }
    inc %i
  }
}