aIRC — File Browser

aIRCv0.8.69 / aIRCv0.8.69 / script / script3.mrc

script3.mrc — 31.49 KB — Download this file

;/**********************************************************************
; *
; * aIRC
; * Query Blocker
; *
; **********************************************************************/
;
alias queryblock { _dialog -m _queryblocker _queryblocker }
dialog _queryblocker {
  title "Query Blocker [/queryblock]"
  size -1 -1 188 169
  option dbu

  box "Block", 1002,5 0 100 120,
  check "Block all queries", 1003,10 10 75 10,
  check "Block if msg match:", 1004,10 20 75 10,
  list 1005,20 30 79 71, Size extsel sort
  button "&Add", 1006,20 105 35 10,
  button "&Del", 1007,65 105 35 10,

  box "Exempts", 1009,110 0 75 120,
  check "+n users (owners)", 1010,115 10 65 10,
  check "+m users (masters)", 1011,115 20 65 10,
  check "+o users (ops)", 1012,115 30 65 10,
  check "+f users (friends)", 1013,115 40 65 10,
  check "Channel Ops (@)", 1014,115 60 65 10,
  check "Channel Voices (+)", 1015,115 70 65 10,
  check "Users in notify list", 1016,115 80 65 10,

  box "Reject Notice", 1018,5 120 179 33,
  check "Send reject Notice", 1019,10 130 58 10,
  edit "", 1020,20 140 159 10, AutoHs

  button "&Ok", 2990,60 155 30 12, Ok
  button "&Cancel", 2991,95 155 30 12, Cancel
}
alias -l _queryblockfile { return $_chfile($_usrdir(queryblock.dat)) }
alias -l _queryblockdr {
  did $iif($did($dname,1004).state,-e,-b) $dname 1005,1006,1007
  did $iif($did($dname,1019).state,-e,-b) $dname 1020
}
ON *:DIALOG:_queryblocker:init:0:{
  _mdx.init $_icofile(dtwindow_Trffc10c.ico)
  did $iif($_getsetup(queryblocker,blockall),-c,-u) $dname 1003
  did $iif($_getsetup(queryblocker,blockmsg),-c,-u) $dname 1004
  did $iif($_getsetup(queryblocker,exempt_n),-c,-u) $dname 1010
  did $iif($_getsetup(queryblocker,exempt_m),-c,-u) $dname 1011
  did $iif($_getsetup(queryblocker,exempt_o),-c,-u) $dname 1012
  did $iif($_getsetup(queryblocker,exempt_f),-c,-u) $dname 1013
  did $iif($_getsetup(queryblocker,exempt_@),-c,-u) $dname 1014
  did $iif($_getsetup(queryblocker,exempt_+),-c,-u) $dname 1015
  did $iif($_getsetup(queryblocker,exempt_notify),-c,-u) $dname 1016
  did $iif($_getsetup(queryblocker,sendnotice_s),-c,-u) $dname 1019
  did -o $dname 1020 1 $_getsetup(queryblocker,sendnotice_t)
  loadbuf -o $dname 1005 " $+ $_queryblockfile $+ "
  _queryblockdr
  _dummy $_lang.loaddialog($dname,$dname,00086969,main.lang,$scriptdir)
}
ON *:DIALOG:_queryblocker:sclick:1004,1019:{ _queryblockdr }
ON *:DIALOG:_queryblocker:sclick:1006:{
  var %d = $dname,%string = $_parameter($null,1,Query Blocker [/queryblock],normal,$null,Block incoming query if message matches:)
  if ($dialog(%d)) { _dialog.add %d 1005 %string }
}
ON *:DIALOG:_queryblocker:sclick:1007:{
  while ($did($dname,1005,$did($dname,1005,0).sel).sel) { did -d $dname 1005 $ifmatch }
}
ON *:DIALOG:_queryblocker:sclick:2990:{
  _setsetup queryblocker blockall $did($dname,1003).state
  _setsetup queryblocker blockmsg $did($dname,1004).state
  _setsetup queryblocker exempt_n $did($dname,1010).state
  _setsetup queryblocker exempt_m $did($dname,1011).state
  _setsetup queryblocker exempt_o $did($dname,1012).state
  _setsetup queryblocker exempt_f $did($dname,1013).state
  _setsetup queryblocker exempt_@ $did($dname,1014).state
  _setsetup queryblocker exempt_+ $did($dname,1015).state
  _setsetup queryblocker exempt_notify $did($dname,1016).state
  _setsetup queryblocker sendnotice_s $did($dname,1019).state
  _setsetup queryblocker sendnotice_t $did($dname,1020)
  write -c " $+ $_queryblockfile $+ "
  filter -if $dname 1005 " $+ $_queryblockfile $+ " *
}
ON ^*:OPEN:*:{
  var %blockall = $_getsetup(queryblocker,blockall),%blockmsg = $_getsetup(queryblocker,blockmsg)
  if (%blockall) || (%blockmsg) {
    if (n isincs %++flags) && ($_getsetup(queryblocker,exempt_n)) { return }
    if (m isincs %++flags) && ($_getsetup(queryblocker,exempt_m)) { return }
    if (o isincs %++flags) && ($_getsetup(queryblocker,exempt_o)) { return }
    if (f isincs %++flags) && ($_getsetup(queryblocker,exempt_f)) { return }
    if ($nick isnotify) && ($_getsetup(queryblocker,exempt_notify)) { return }
    var %@ = $_getsetup(queryblocker,exempt_@),%+ = $_getsetup(queryblocker,exempt_+)
    if (%@) || (%+) {
      var %i = $comchan($nick,0),%chan
      while (%i) {
        %chan = $comchan($nick,%i)
        if (%@) && ($nick isop %chan) { return }
        if (%+) && ($nick isvo %chan) { return }
        dec %i
      }
    }
    var %block = 0,%reject = $_getsetup(queryblocker,sendnotice_s)
    if (%blockall) { %block = 1 }
    elseif (%blockmsg) {
      %reject = 0
      var %h = _queryblock
      _hmake %h
      hload -n %h " $+ $_queryblockfile $+ "
      %block = $hmatch(%h,$strip($1-),1).data
      hfree %h
    }
    if (%block) {
      var %tmp = $strip($1-)
      if ($len(%tmp) > 20) { %tmp = $left(%tmp,17) $+ ... }
      %tmp = Blocked incoming query from $nick ( $+ $address $+ ) $+ : %tmp
      info.a %tmp
      if ($_group(#_awaylog.private)) { _awaylog.add %tmp }
      if (%reject) {
        if ($_flood.main(1,0,5,0,60,__queryblock.botnet,0)) || ($_flood.main(1,0,3,0,60,$_nospaces(__queryblock.,%++maskclon),0)) { halt }
        if ($_evaltext($_getsetup(queryblocker,sendnotice_t)) != $null) { _puthelp $nick & _qnotice $nick $ifmatch }
      }
      halt
    }
  }
}
;/**********************************************************************
; *
; * aIRC
; * Servers List
; *
; **********************************************************************/

alias _start.sstatus { _servers.sstatus }
alias _servers.sstatus {
  tokenize 32 $1 $lower($2)
  var %netwin = @__servessstatus1,%win = @__servessstatus2,%w2 = @__servessstatus3,%wt = @__servessstatus4,%wp = @__servessstatus5,%file = $_usrdir(sstatus.mrc),%ifile = $_mini(files,servers),%chk = 0,%i = 1,%n,%net,%line,%tok,%desc,%server,%ports,%randone,%regtmp,%region,%countmp,%country,%prep
  if (%ifile == $null) { %ifile = servers.ini }
  close -@ %netwin
  window -hs %netwin
  _openwins %win %w2 %wt %wp
  if ($isfile(%file) == $false) {
    write -c $"(%file) [nets]
    write $"(%file) dalnet
    write $"(%file) efnet
    write $"(%file) ircnet
    write $"(%file) undernet
  }
  if ($ini(%file,nets)) { loadbuf -tnets %netwin $"(%file) }
  if ($1) {
    if ($fline(%netwin,$2,1)) { %chk = 1 }
    else { aline %netwin $2 }
  }
  else {
    if ($fline(%netwin,$2,1)) { dline %netwin $ifmatch }
    else { %chk = 1 }
  }
  if ($isfile(%ifile) == $false) {
    error.a Servers INI file not found. $iif(%ifile != $null,$^'(%ifile))
    close -@ %netwin %win %w2 %wt %wp
    return
  }
  if ($isfile(%ifile)) && (%chk) {
    _dummy $readini $"(%file) time crc
    if ($result != $crc(%ifile)) { %chk = 0 }
  }
  if (%chk) {
    close -@ %netwin %win %w2 %wt %wp
    return
  }
  aline %win ;/**********************************************************************
  aline %win ; *
  aline %win ; * aIRC
  aline %win ; * Servers Popups in Status Window
  aline %win ; *
  aline %win ; * (use /servers to edit)
  aline %win ; *
  aline %win ; **********************************************************************/
  aline %win ;
  aline %win #_ off
  aline %win ;
  aline %win [time]
  aline %win crc= $+ $crc(%ifile)
  aline %win [nets]
  filter -ww %netwin %win
  aline %win [nets_]
  aline %win ;
  aline %win #_ end
  aline %win alias -l _s $chr(123) server $ $+ 1 $ $+ _randtok($iif($server($1).port,$_range($server($1).port,20),6667),44) $chr(125)
  aline %win menu status $chr(123)
  %n = $line(%netwin,0)
  _progress.init Generating server popups
  while (%i <= %n) {
    clear %w2
    clear %wt
    clear %wp
    var %region,%country
    %net = $line(%netwin,%i)
    aline %wp %net
    _progress2 %i $calc(%n + 1) %net
    _servers.sstatusf *=Random & %net server*
    _servers.sstatusf *GROUP: $+ %net
    %randone = 0
    while ($line(%w2,0)) {
      %line = $line(%w2,1)
      var %regtmp,%countmp
      %tok = 1- $+ $findtok(%line,$wildtok(%line,*SERVER,1,58),1,58)
      %desc = $lower($left($gettok($gettok(%line,%tok,58),2,61),-6))
      %server = $gettok(%line,$calc($findtok(%line,$wildtok(%line,*SERVER,1,58),1,58) + 1),58)
      %line = : $+ $chr(123) _s %server $chr(125)
      if ($istok(%desc,random,32)) {
        if (*: random server iswm %desc) || (*: random * server iswm %desc) { aline %wp . $+ $gettok(%desc,$numtok(%desc,58),58) $+ %line }
        else {
          %desc = $remove(%desc,:,.)
          if (random ?*? server iswm %desc) { aline %wp . $+ $gettok(%desc,1-2,32) server $+ %line }
          else { aline %wp . $+ %desc $+ %line }
        }
        %randone = 1
      }
      else {
        if (%randone) { aline %wp . $+ - }
        %prep = .
        %randone = 0
        %desc = $gettok(%desc,$numtok(%desc,58),58)
        if ($istok(AF AS EU ME NA,$remove($gettok(%desc,1,32),$chr(44)),32)) {
          %regtmp = $replace($remove($gettok(%desc,1,32),$chr(44)),AF,africa,AS,asia,EU,europe,ME,middle east,NA,north america)
          %desc = $gettok(%desc,2-,32)
          if (%region != %regtmp) {
            %region = %regtmp
            aline %wp %prep $+ %region
          }
          %prep = %prep $+ .
        }
        else { var %region }
        if ($__country($remove($gettok(%desc,1,32),$chr(44))) != $null) {
          %countmp = $lower($ifmatch)
          %desc = $gettok(%desc,2-,32)
          if (%country != %countmp) {
            %country = %countmp
            aline %wp %prep $+ %country
          }
          %prep = %prep $+ .
        }
        elseif ($__country(%server) != $null) {
          %countmp = $lower($ifmatch)
          if (%country != %countmp) {
            %country = %countmp
            aline %wp %prep $+ %country
          }
          %prep = %prep $+ .
        }
        else { var %country }
        aline %wp %prep $+ $iif(%desc != $null,%desc,server) $+ %line
      }
      dline %w2 1
    }
    if ($line(%wp,0) > 1) { filter -ww %wp %win }
    inc %i
  }
  _progress 99 Saving File...
  aline %win $chr(125)
  .savebuf %win $"(%file)
  .flushini $"(%file)
  .reload -rs3 $"(%file)
  _progress 100 Done!
  close -@ %netwin %win %w2 %wt %wp
}
alias _servers.sstatusf {
  var %w2 = @__servessstatus3,%win = @__servessstatusf,%ifile = $_mini(files,servers)
  close -@ %win
  window -hs %win
  filter -fw $"(%ifile) %win $1-
  filter -ww %win %w2
  close -@ %win
}

;/**********************************************************************
; *
; * aIRC
; * Userlist stuff
; *
; **********************************************************************/
alias _menuadduser2 { _menuadduser $1 $2 $_parameter($null,1,Add user [/+user],1,$1,Add [ $1 ] to the userlist with handle:) }
alias _menuadduser {
  var %nick = $1,%flags = $remove($2,+),%handle = %nick,%mask = $_getaddress(%nick,%_maskuser)
  if ($3 != $null) { %handle = $3 }
  if (%handle == $null) || ($_isuser(%handle)) { return }
  +user %handle $iif($_ismask(%mask),%mask)
  if (%flags != $null) && ($_isuser(%handle)) {
    if ($_sanitycheck(%flags) != $null) { chattr %handle $ifmatch }
  }
}
; /addegg <nick> <password> <#channel1,#channel2,...>
alias addegg {
  if ($_disconnected) { return }
  var %nick = $1
  %nick = $_parameter(%nick,1,Add eggdrop to userlist [/addegg],1,$null,Bot nick:)
  if (%nick == $me) {
    error.a Don't add yourself as a bot!
    return
  }
  if ($_getaddress(%nick,%_maskuser) != $null) { _addegg %nick $ifmatch $2- }
  else { _nickhost %nick %_maskuser _donothing _addegg %nick <MASK> $2- }
}
; /_addegg <handle> <hostmask> <password> <#channel1,#channel2,...>
alias _addegg {
  var %nick = $$1,%addy = $$2,%pass = $3,%chans = $_fixchans($4),%title = Add eggdrop ( $+ %nick $+ ) to userlist [/addegg],%i
  %pass = $_parameterpass(%pass,1,%title,1,$null,Bot password:)
  .+bot %nick $null %addy
  if (b isincs $_nickflags(%nick)) {
    if (%chans != $null) {
      %i = $numtok(%chans,44)
      while (%i) {
        chattr %nick +B $gettok(%chans,%i,44)
        dec %i
      }
    }
    else { chattr %nick +B }
    chbotpass %nick %pass
    botprofile %nick eggdrop
  }
}
alias _addhost2nick {
  var %file = $_userinifile,%r,%i = 1,%n = $_countusers,%nick = $1,%mask = $2,%win = @__addhost2nick
  if (%mask == $null) { return }
  _openwins %win
  if (%n) {
    while (%i <= %n) {
      if ($_ruini($ini(%file,%i),handle) != $null) { aline %win $ifmatch }
      inc %i
    }
    +host $_select($null,1,Add host [/+host],normal,%nick,-wc,%win,Add hostmask [ %mask ] to handle:) %mask
  }
  else { error.a There are no users }
}
alias _menutmpchattr {
  var %handle = $1,%chan = $2,%ruinic = %chan,%flags,%tmp
  if (%ruinic == $null) { %ruinic = global }
  %flags = $_ruini(%handle,%ruinic)
  %tmp = [+|-]flags
  if (%flags != $null) { %tmp = %tmp $+ <CRLF>Current: %flags }
  chattr %handle $_parameter($null,1,Change flags [/chattr],1,$null,%tmp) %chan
}
;/**********************************************************************
; *
; * aIRC
; * Channel Settings
; *
; **********************************************************************/
;
alias _getclonimmunes {
  var %file = $_chaninifile,%chan = $1,%res
  if (%chan != $null) && ($_readini(%file,%chan,_cloneimmunes) != $null) { %res = $ifmatch }
  else { %res = $_readini(%file,default,_cloneimmunes) }
  if ($gettok(%res,1,32) == >) { %res = $gettok(%res,2-,32) }
  return 0.0.0.0 x.x.x.x %res
}
alias _update.channelsetup {
  var %f1 = $shortfn($_scriptini),%f2 = $shortfn($_chaninifile),%i = $ini(%f1,chan,0),%topic
  while (%i) {
    %item = $ini(%f1,chan,%i)
    if ($_readini(%f1,chan,%item) != $null) { writeini %f2 default %item $ifmatch }
    dec %i
  }
  remini %f1 chan
  flushini %f1
  flushini %f2
}
alias _chansetup2chanprot {
  _prot.init
  var %c,%scs = $_schans,%pcs = $hget(_aircprot,channels),%i = $numtok(%scs,32)
  __chansetup2chanprot
  while (%i) {
    %c = $gettok(%scs,%i,32)
    __chansetup2chanprot %c
    %pcs = $addtok(%pcs,%c,32)
    dec %i
  }
  _hadd _aircprot channels %pcs
  _prot.save
}
alias -l __chansetup2chanprot {
  var %t = chan_global,%protchan,%h = _aircprot
  if ($1 != $null) { %t = chan_ $+ $1 }
  if ($hget(%h,%t) != $null) { %protchan = $ifmatch }
  else { %protchan = $replace($str(_$null,33),_,$chr(32)) }
  if ($_rchini(enforcebans,$1) != $null) { %protchan = $puttok(%protchan,$ifmatch,30,32) }
  if ($_rchini(bitch,$1) != $null) { %protchan = $puttok(%protchan,$ifmatch,19,32) }
  if ($_rchini(stopnethack,$1) != $null) { %protchan = $puttok(%protchan,$ifmatch,18,32) }
  if ($_rchini(revengebot,$1) != $null) {
    %protchan = $puttok(%protchan,$ifmatch,28,32)
    %protchan = $puttok(%protchan,$ifmatch,29,32)
  }
  _hadd %h %t %protchan
}

;/**********************************************************************
; *
; * aIRC
; * Protection Aliases
; *
; **********************************************************************/

alias _prot.init {
  var %h = $iif($1 != $null,$1,_aircprot)
  _hmake %h 50
  hload %h $shortfn($_protectinifile)
}
alias _prot.save {
  var %h = _aircprot
  if ($hget(%h)) {
    hadd %h XTRA binary
    hsave -o _aircprot $shortfn($_protectinifile)
  }
}
alias _prot.updateprots {
  var %i = 1,%cs = $_getsetup(prot,channels),%n = $numtok(%cs,32),%c,%h = _aircprot

  hfree -w %h
  hmake %h 50

  _hadd %h personal $_getsetup(prot,personal)
  _hadd %h personalbotnet $_getsetup(prot,personalbotnet)

  _hadd %h chan_global $_getsetup(prot,chan)
  _hadd %h botnet_global $_getsetup(prot,chanbotnet)
  _hadd %h cuadvert_global $_rinitxt(_protlist_cuadvert)
  _hadd %h cubadnick_global $_rinitxt(_protlist_cubadnick)
  _hadd %h cubadident_global $_rinitxt(_protlist_cubadident)
  _hadd %h cunsctcp_global $_rinitxt(_protlist_cunsctcp)
  _hadd %h cuswear_global $_rinitxt(_protlist_cuswear)

  _hadd %h channels %cs
  while (%i <= %n) {
    var %c = $gettok(%cs,%i,32),%ht = _prot.chan $+ %c
    _hadd %h chan_ $+ %c $_getsetup(prot,chan [ $+ [ %c ] ] )
    _hadd %h botnet_ $+ %c $_getsetup(prot,chanbotnet [ $+ [ %c ] ] )
    _hadd %h cuadvert_ $+ %c $_rinitxt(_protlist_cuadvert [ $+ [ %c ] ] )
    _hadd %h cubadnick_ $+ %c $_rinitxt(_protlist_cubadnick [ $+ [ %c ] ] )
    _hadd %h cubadident_ $+ %c $_rinitxt(_protlist_cubadident [ $+ [ %c ] ] )
    _hadd %h cunsctcp_ $+ %c $_rinitxt(_protlist_cunsctcp [ $+ [ %c ] ] )
    _hadd %h cuswear_ $+ %c $_rinitxt(_protlist_cuswear [ $+ [ %c ] ] )

    inc %i
  }
  remini $shortfn($_scriptini) prot
  var %win = @__updateprots,%file = $shortfn($_scriptxtini)
  _openwins %win
  filter -fwx %file %win _protlist_*
  savebuf %win %file
  close -@ %win
  _prot.save
}
alias _protectinifile { return $_chfile($_usrdir(protect.dat)) }
alias _protactinifile { return $_chfile($_usrdir(protact.ini)) }
alias _protactdefaultinifile { return $_chfile(etc\profile\protact.ini) }
;
;;
;
; $_triggered(type,channel,var,nick,site,address,fulladdress,word1,word2,word3,word4,%word5)
;
;  for floods: <COUNT>   %word1
;              <MAX>     %word2
;              <SECONDS> %word3
;              <COUNTB>  %word4
;              <MAXB>    %word5
;              <C/S>     counter1/second
;              <CB/S>    counter2/second
;
;
;
;  for words:  <WORD>    %word1
;              <TRIGGER> %word2
;
alias _triggered {
  var %file = $_protactinifile,%tf,%tmp,%num,%win = @__triggered,%type = $1,%chan,%nick = $4,%site = $5,%address = $6,%fulladdress = $7,%line,%command,%mask,%pre,%botnet = 0,%duration,%nicknomask = 0
  var %word1 = $_noeval($8),%word2 = $_noeval($9),%word3 = $_noeval($10),%word4 = $_noeval($11),%word5 = $_noeval($12)
  if ($istok(0.0.0.0 x.x.x.x,%site,32)) { %nicknomask = 1 }
  if ($mid(%type,2,1) == b) { %botnet = 1 }
  if ($_ischan($2)) {
    %chan = $2
    %tf = $2 $+ , $+ $1
    %tmp = $read -ns $+ %tf $+ .1.isaction %file
  }
  if ($_not(%tmp)) {
    %tf = $1
    %tmp = $read -ns $+ %tf $+ .1.isaction %file
  }
  if ($_not(%tmp)) { return }
  tokenize 32 % $+ $3
  inc $1
  %num = [ [ $1 ] ]
  %tmp = $read -ns $+ %tf $+ . $+ %num $+ .isaction %file
  if ($_not(%tmp)) {
    set $1 1
    %num = 1
  }
  _openwins %win
  filter -fw $"(%file) %win %tf $+ . $+ %num $+ .*
  while ($line(%win,0)) {
    tokenize 32 $line(%win,1)
    var %line,%command,%mask,%pre,%tmp = $gettok($1,3,46),%duration
    tokenize 32 $2-
    if ($1) {

      if (%tmp == isaction) {  }
      elseif (%tmp == warnyou) {
        %line = $2-
        if ($istok(puchat pufserve,%type,32)) && ($active == $_nospaces(=,%nick)) { %command = info.s <-!-LINE-!-> }
        else { %command = info.a <-!-LINE-!-> }
      }
      elseif (%tmp == warn) {
        %line = $5-
        if ($istok(puchat pufserve,%type,32)) { %command = msg = $+ %nick <-!-LINE-!-> }
        elseif ($4 == NICK) || (%nicknomask) {
          if ($2) { %command = _puthelp %nick & _qnotice %nick <-!-LINE-!-> }
          else { %command = _puthelp %nick & _qprivmsg %nick <-!-LINE-!-> }
        }
        elseif ($_mask(%fulladdress,$4) != $null) {
          %mask = $ifmatch
          if ($2) { %command = _mnotice %mask <-!-LINE-!-> }
          else { %command = _mmsg %mask <-!-LINE-!-> }
        }
      }
      elseif (%tmp == warnchan) {
        %line = $5-
        if ($me isop %chan) {
          if ($4) {
            if ($2) { %command = _puthelp %chan co& ._onotice %chan <-!-LINE-!-> }
            else { %command = _puthelp %chan co& ._omsg %chan <-!-LINE-!-> }
          }
          else {
            if ($2) { %command = _puthelp %chan c& _qnotice %chan <-!-LINE-!-> }
            else { %command = _puthelp %chan c& _qprivmsg %chan <-!-LINE-!-> }
          }
        }
      }
      elseif (%tmp == deop) {
        if (%chan == $null) {
          if ($2 == NICK) || (%nicknomask) { %command = cdeop %nick }
          elseif ($_mask(%fulladdress,$2) != $null) { %command = cdeop $ifmatch }
        }
        elseif ($me isop %chan) {
          if ($2 == NICK) || (%nicknomask) { %command = deop %chan %nick }
          elseif ($_mask(%fulladdress,$2) != $null) { %command = deop %chan $ifmatch }
        }
      }
      elseif (%tmp == ban) {
        if ($2) && ($_isint($3)) { %duration = $3 }
        if ($4 == NICK) || (%nicknomask) { %mask = %nick $+ !*@* }
        elseif ($_mask(%fulladdress,$4) != $null) { %mask = $ifmatch }
        if (%mask != $null) {
          if ($_getsetup(script,_use+banonautoban)) {
            %line = $5-
            if (%duration) { %pre = % $+ bantime $+ %duration }
            if (%chan == $null) { %command = +ban %mask %pre <-!-LINE-!-> }
            elseif ($me isop %chan) { %command = +ban %mask %chan %pre <-!-LINE-!-> }
          }
          else {
            if (%duration) { %pre = -u $+ %duration }
            if (%chan == $null) { %command = cban %pre %mask }
            elseif ($me isop %chan) { %command = ban %pre %chan %mask }
          }
        }
      }
      elseif (%tmp == kick) {
        %line = $3-
        if (%chan == $null) {
          if ($2 == NICK) || (%nicknomask) { %command = ckick -i %nick <-!-LINE-!-> }
          elseif ($_mask(%fulladdress,$2) != $null) { %command = ckick -i $ifmatch <-!-LINE-!-> }
        }
        elseif ($me isop %chan) {
          if ($2 == NICK) || (%nicknomask) { %command = kick -i %chan %nick <-!-LINE-!-> }
          elseif ($_mask(%fulladdress,$2) != $null) { %command = kick -i %chan $ifmatch <-!-LINE-!-> }
        }
        if (%command != $null) { %command = .timer 1 1 %command }
      }
      elseif (%tmp == ignore) {
        %line = $11-
        if ($5) { %pre = %pre $+ p }
        if ($6) { %pre = %pre $+ c }
        if ($7) { %pre = %pre $+ n }
        if ($8) { %pre = %pre $+ t }
        if ($9) { %pre = %pre $+ i }
        if ($10) { %pre = %pre $+ k }
        if (%pre != $null) {
          if ($2) && ($_isint($3)) { %pre = %pre $+ u $+ $3 }
          if (%pre != $null) { %pre = - $+ %pre }
          if (%botnet) { %command = +ignore %pre *!*@* <-!-LINE-!-> }
          elseif ($4 == NICK) || (%nicknomask) { %command = +ignore %pre %nick $+ !*@* <-!-LINE-!-> }
          elseif ($_mask(%fulladdress,$4) != $null) { %command = +ignore %pre $ifmatch <-!-LINE-!-> }
        }
      }
      elseif (%tmp == nick) {
        %line = $6-
        if ($4) {
          if ($2) { %command = _triggered.changenick $3 $_randstring(8,lu) }
          else { %command = _triggered.changenick 0 $_randstring(8,lu) }
        }
        else {
          if ($2) { %command = _triggered.changenick $3 <-!-LINE-!-> }
          else { %command = _triggered.changenick 0 <-!-LINE-!-> }
        }
      }
      elseif (%tmp == sound) {
        %line = $2-
        if (%line == $null) || (*.wav !iswm %line) { var %line }
        else { %command = .splay <-!-LINE-!-> }
      }
      elseif (%tmp == flash) {
        if ($2- != $null) {
          %line = $2-
          %command = .flash <-!-LINE-!->
        }
      }
      elseif (%tmp == modes) {
        %line = $4-
        if ($2) { %command = _tmode %chan $round($3,0) <-!-LINE-!-> }
        else { %command = _tmode %chan 0 <-!-LINE-!-> }
      }
      elseif (%tmp == topic) {
        %line = $4-
        if ($2) { %command = _ttopic %chan $round($3,0) <-!-LINE-!-> }
        else { %command = _ttopic %chan 0 <-!-LINE-!-> }
      }
      elseif (%tmp == custom) {
        if ($2- != $null) {
          %line = $2-
          %command = <-!-LINE-!->
        }
      }
    }
    if (%command != $null) {
      if (%line != $null) {
        var %c/s = 0,%cb/s = 0
        if (%word1) && (%word2) { %c/s = $round($calc(%word1 / %word2),2) }
        if (%word4) && (%word5) { %cb/s = $round($calc(%word4 / %word5),2) }
        %line = $_evaltext($replace(%line,<CHAN>,%chan,<NICK>,%nick,<SITE>,%site,<ADDRESS>,%address,<FULLADDRESS>,%fulladdress,<COUNT>,%word1,<MAX>,%word2,<SECONDS>,%word3,<COUNTB>,%word4,<MAXB>,%word5,<WORD>,%word1,<TRIGGER>,%word2,<C/S>,%c/s,<CB/S>,%cb/s,<PHRASE>,%word1,<DEOPTIME>,%word1,<KICKTIME>,%word1,<KICKREASON>,%word2))
      }
      if (%tmp == custom) { .timer -o 1 0 $replace(%command,<-!-LINE-!->,%line) }
      else { $replace(%command,<-!-LINE-!->,%line) }
    }
    dline %win 1
  }
  if ($istok(cumdeop cumkick cumban,%type,32)) { _chanmode.flush }
  close -@ %win
}
alias _mnotice {
  if ($1 == $null) || ($2- == $null) { return }
  var %i = $ial($1,0),%nick
  while (%i) {
    %nick = $ial($1,%i).nick
    _puthelp %nick & _qnotice %nick $2-
    dec %i
  }
}
alias _mmsg {
  if ($1 == $null) || ($2- == $null) { return }
  var %i = $ial($1,0),%nick
  while (%i) {
    %nick = $ial($1,%i).nick
    _puthelp %nick & _qprivmsg %nick $2-
    dec %i
  }
}
; /_tmode $chan time modes
alias _tmode {
  var %chan = $1,%time = $2,%modes = $3,%extra = $4-,%change
  if ($me isop %chan) {
    %change = $_reqchangemodes($gettok($chan(%chan).mode,1,32),$_changemodes($gettok($chan(%chan).mode,1,32),%modes))
    if (%change != $null) {
      _chanmode %chan %change %extra
      if ($_isint($round(%time,0))) { .timer_tmode $+ %chan 1 $ifmatch _chanmode %chan $replace(%change,-,?,+,-,?,+) }
    }
  }
}
; /_ttopic $chan time topic
alias _ttopic {
  var %chan = $1,%time = $2,%topic = $3-,%oldtopic
  if ($me isop %chan) {
    %oldtopic = $chan(%chan).topic
    if (%topic !== %oldtopic) {
      .raw topic %chan : $+ %topic
      if ($_isint($round(%time,0))) { .timer_ttopic $+ %chan 1 $ifmatch .raw topic %chan : $+ %oldtopic }
    }
  }
}
alias _triggered.changenick {
  if ($_not($_connected)) { return }
  if ($_flood2(20,__NOSELFNICKFLOOD)) { return }
  _tnick.set $1-
}
; /_tnick time nick
alias _tnick.set {
  if ($_not($_connected)) || ($1 !isnum) || ($1 < 0) || ($2 == $null) { return }
  if ($1) {
    if (%†myoldnick == $null) { %†myoldnick = $me }
    .timer_CHANGENICK2 1 $1 _tnick.reset
  }
  else { .timer_CHANGENICK2 off }
  .timer_CHANGENICK1 1 0 _tnick.change $2
}
alias _tnick.reset {
  if (%†myoldnick != $null) { _tnick.change %†myoldnick }
  unset %†myoldnick
}
alias _tnick.change {
  if ($1 != $null) && ($1 != $me) { nick $1 }
}

;/**********************************************************************
; *
; * aIRC
; * Autojoin
; *
; **********************************************************************/

alias autojoin {
  if ($_disconnected) { return }
  if ($_getnetsetting(autojoin) != $null) {
    var %autojoin = $ifmatch,%chans = $_autojoin.getchans(%autojoin)
    if (a isin $1) {
      .timer_autojoin 1 5 _autojoinnowporlaputamadre %autojoin
      info.a Press $_addfkey(o,5,_autojoin.cancel) in the next 5 seconds to cancel autojoin to: %chans
    }
    else { _autojoinnowporlaputamadre %autojoin }
  }
  elseif (a !isin $1) { error.a There are no autojoin channels for this network }
}
alias _autojoin.cancel {
  if ($timer(_autojoin)) {
    .timer_autojoin* off
    info.a Autojoin Cancelled
  }
}
alias _autojoinnowporlaputamadre {
  var %i = 1,%n = $numtok($1-,32),%tmp,%chan,%pass,%toks,%ft
  while (%i <= %n) {
    var %tmp = $gettok($1-,%i,32),%chan = $gettok(%tmp,1,44),%pass = $gettok(%tmp,2-,44)
    if ($me !ison %chan) {
      if (%pass != $null) { .quote join %chan %pass }
      else { %toks = $addtok(%toks,%chan,44) }
      %ft = $addtok(%ft,%chan,44)
    }
    inc %i
  }
  if (%toks != $null) { .quote join %toks }
  info.a Joining: %ft
}
alias _autojoin.getchans {
  var %i = 1,%n = $numtok($1-,32),%r
  while (%i <= %n) {
    %r = $addtok(%r,$gettok($gettok($1-,%i,32),1,44),44)
    inc %i
  }
  return %r
}

;/**********************************************************************
; *
; * aIRC
; * Network Settings
; *
; **********************************************************************/

alias _snetworkini { return $_chfile($_usrdir(snetwork.ini)) }

alias _update.networkstuff {
  var %toks = modes_on_connect modes_on_oper modes_oper on_connect minserver autojoin,%i = $numtok(%toks,32),%sf = $shortfn($_scriptini),%nf = $shortfn($_snetworkini),%tok,%tok2
  while (%i) {
    var %tok = $gettok(%toks,%i,32),%tok2 = _network_ $+ %tok
    if ($_readini(%sf,script,%tok2) != $null) { writeini %nf default %tok $ifmatch }
    remini %sf script %tok2
    dec %i
  }
  flushini %nf
}

; $_getnetsetting(setting,[net])[.prop]
;   prop     = state,contents
alias _getnetsetting {
  var %net = $2,%t,%s = 0,%c,%file = $_snetworkini
  if (%net == $null) { %net = %.network }
  %t = $_readini(%file,%net,$1)
  if (%t == $null) { %t = $_readini(%file,default,$1) }
  if ($1 != autojoin) {
    if ($gettok(%t,1,32)) { %s = 1 }
    %c = $gettok(%t,2-,32)
  }
  else {
    var %s = 1,%c = %t
    if (%c == ,) { var %c }
  }
  if ($prop == state) { return %s }
  if ($prop == contents) { return %c }
  if (%s) { return %c }
}
alias _onconnect.init-server {
  if (%.network == $null) || ($_readini($_tmpdir(session.ini),script,netinit)) { return }
  writeini " $+ $_tmpdir(session.ini) $+ " script netinit 1
  _setsetup script init-server $_getnetsetting(on_connect)
  if ($_getnetsetting(modes_on_connect).state) { _setmymode $_getnetsetting(modes_on_connect) }
  var %line = $_getsetup(script,init-server)
  if (%line != $null) { .timer_init-server 1 0 $ $+ _evaltext( $+ %line $+ ) }
  if ($_getnetsetting(modes_oper) != $null) { oper $ifmatch }
  autojoin -a
}
;/**********************************************************************
; *
; * aIRC
; * Userhost
; *
; **********************************************************************/

alias userhost { ._nickhost $_parameter($1-,1,Userhost [/userhost],replace 32 44,$_activequery,Nick[s]:) 5 $null echo.userhost <NICK> <ADDR> <AWAY> <IRCOP> }

; /_nickhost nicks masktype errcommand command parms
;  if errcommand == $null, a no such nick message is displayed
;  parms will be for errcommand and command
alias _nickhost {
  __nickhost.checkflush
  var %i = 1,%tnicks = $replace($1,$chr(44),$chr(32))
  if ($show) { lecho.a $colour(info) $^*** Looking up address of %tnicks }
  while ($gettok(%tnicks,%i,32) != $null) {
    inc %c.nickhost.total
    set %c.nickhost. $+ %c.nickhost.total $ifmatch $2-
    .quote userhost $ifmatch
    inc %i
  }
}
alias -l __nickhost.fixvars {
  %c.nickhost.total = $round(%c.nickhost.total,0)
  if (%c.nickhost.total !isnum) { %c.nickhost.total = 0 }
  %c.nickhost.curr = $round(%c.nickhost.curr,0)
  if (%c.nickhost.curr !isnum) { %c.nickhost.curr = 0 }
}
alias -l __nickhost.checkflush {
  __nickhost.fixvars
  if (%c.nickhost.curr > 0) && (%c.nickhost.curr >= %c.nickhost.total) { unset %c.nickhost.* }
}
raw 302:*:{
  __nickhost.checkflush
  var %irco = $iif(* isin $2,1,0),%nick = $remove($gettok($2,1,61),*),%addr = %nick $+ ! $+ $right($gettok($2,2,61),-1),%away = $iif($left($gettok($2,2,61),1) == -,1,0),%line,%currnick,%mask,%errcmd,%cmd
  if (%nick == $me) && (%.myaddress == $null) && ($_isfullmask(%addr)) { %.myaddress = %addr }
  if (%c.nickhost.total) {
    inc %c.nickhost.curr
    if (%c.nickhost.curr <= %c.nickhost.total) {
      var %line = %c.nickhost. [ $+ [ %c.nickhost.curr ] ] ,%currnick = $gettok(%line,1,32),%errcmd = $gettok(%line,3,32)
      if (%currnick == %nick) {
        %mask = $_mask(%addr,$gettok(%line,2,32))
        _timeremote $replace($gettok(%line,4-,32),<ADDR>,%addr,<MASK>,%mask,<NICK>,%nick,<AWAY>,%away,<IRCOP>,%irco)
      }
      elseif (%errcmd != $null) { _timeremote %errcmd $replace($gettok(%line,5-,32),<ADDR>,$null,<MASK>,$null,<NICK>,%currnick,<AWAY>,$null,<IRCOP>,$null) }
      else { error.a %currnick no such nick }

    }
    __nickhost.checkflush
    halt
  }
}
raw 401:* No such nick*:{
  __nickhost.checkflush
  if (%c.nickhost.total) && ($gettok(%c.nickhost. [ $+ [ $calc(%c.nickhost.curr + 1) ] ] ,1,32) == $2) { halt }
}