Basic — File Browser

Basicv23042002 / Basicv23042002 / basic / sys / raw.mrc

raw.mrc — 10.47 KB — Download this file

; ###################################
;
;  Basic v23042002
;  blue-elf, belf@mircscripter.com
;
;  raw numerics
;
; ###################################
alias undo {
  opcheck #
  tokenize 32 $($+(%,_sys.tmp.,$cid,.lastrawmode.,#),2)
  if (!$1) _err Last massmode for # has expired
  if ($me isop #) .raw MODE # $replace($1,-,_,+,-,_,-) $2-
}
on *:rawmode:#:set -u600 %_sys.tmp. $+ $cid $+ .lastrawmode. $+ # $1-

; if (r isincs modes) cannot cycle
raw 800:*:set %ircx. $+ $cid 1

; who list
dialog whowin {
  title "Who results"
  size -1 -1 592 360
  icon $shortfn($mircexe), 17
  list 1, -1 -1 593 363, size
  button "", 2, 264 333 64 24, hide ok
  list 3, 1 1 1 1, hide
  button "resize",4, 1 1 1 1, hide
  button "cancel",5, 1 1 1 1, hide cancel
}
on *:dialog:whowin.*:init:*:{
  mdxinit $dname 1 75,150,50,50,50,45,150,75,115 Nick,Address,Away,IRCOp,Status,Hops,Server,Channel,Quote
  mdxResizeFix $dname
  mdx SetControlMDX $dname 4 Positioner maxbox minbox size > dll\mdx\dialog.mdx
  if ($_(windows,whowin)) {
    dialog -s $dname $ifmatch
    mdx MoveControl $dname 1 * * $dialog($dname).w $dialog($dname).h
  }
  if ($_(windows,whowin.headerpos)) did -i $dname 1 1 headerdims $ifmatch
}
on *:dialog:whowin.*:sclick:1:{
  var %mouse = $mouse.dx $mouse.dy
  did -i $dname 1 1 page $devent
  tokenize 32 $did($dname,1,1)
  if (($1 == rclick) && ($did($dname,1).sel > 1)) popwhowin %mouse $did($dname,3,$calc($ifmatch - 1))
  elseif (($1-2 == headerclick HEADEREVENT) && ($3 isnum 1-9)) {
    var %tmp = % $+ _sys.tmp. $+ $cid $+ .whowinsort
    if (!$(%tmp,2)) set -u120 $(%tmp) -ctio
    filter $(%tmp,2) $3 9 $dname 3 $dname 1 *
    filter $(%tmp,2) $3 9 $dname 3 $dname 3 *
    if (e isincs $(%tmp,2)) set -u120 $(%tmp) -ctio
    else set -u120 $(%tmp) -ctioe
  }
}
on *:dialog:whowin.*:sclick:4:if ($istok(size minimize maximize restore,$gettok($did($dname,$did),1,32),32)) mdx MoveControl $dname 1 * * $calc($dialog($dname).cw + 3) $calc($dialog($dname).ch + 3)
on *:dialog:whowin.*:sclick:5:{
  savedlgpos whowin $dname
  did -i $dname 1 1 page headerdims
  tokenize 32 $did($dname,1,1)
  if (($1-2 == none HEADERDIMS) && ($3-)) _set windows whowin.headerpos $3-
}
alias popwhowin {
  tokenize 9 $1-
  tokenize 32 $1-
  _mnu New whowin 5 5
  _itm whowin +D 1 $3
  _itm whowin
  _itm whowin 3 &Whois $cr whois $3
  _itm whowin 4 &User Central $cr uwho $3 $3
  _itm whowin +> 5 D&NS $cr dns
  _mnu New dns 5 5 D&NS $cr dns
  _itm dns 1 $3 $cr dns $3
  _itm dns 2 $gettok($4,2,64) $cr dns $gettok($4,2,64)
  _itm dns 3 $9 $cr dns $9
  _itm whowin
  _itm whowin +> 6 &Control $cr ctrl
  _mnu New ctrl 5 5 &Control $cr ctrl
  _itm ctrl 1 &Kick $cr kick $10 $3
  _itm ctrl 2 Kick&Ban $cr _kb $10 $3
  _itm ctrl 
  _itm ctrl 4 &Ignore... $cr _aig $+($3,!,$4)
  _itm whowin +> 7 C&TCP $cr ctcp
  _mnu New ctcp 5 5 C&TCP $cr ctcp
  _itm ctcp 1 &Ping $cr ctcp $3 ping
  _itm ctcp 2 &Finger $cr ctcp $3 finger
  _itm ctcp 3 &Version $cr ctcp $3 version
  _itm ctcp 4 &Time $cr ctcp $3 time
  _itm ctcp
  _itm ctcp 6 &Specify... $cr _whoctcp $3
  _itm whowin +> 8 &DCC $cr dcc
  _mnu New dcc 5 5 &DCC $cr dcc
  _itm dcc 1 &Chat $cr dcc chat $3
  _itm dcc 2 &Send... $cr dcc send $3
  _itm whowin
  _itm whowin 10 &Query $cr query $3
  _itm whowin
  var %num = 12
  if ($wtf($strip($11))) {
    _itm whowin +> %num &Visit $cr url
    _mnu New url 5 5 &Visit $cr url
    _itm url 1 $strip($11) $cr run $strip($11)
    inc %num
  }
  if (($me !ison $10) && ($10 != *)) {
    _itm whowin %num &Join $10 $cr join $10
    inc %num
  }
  if (($server != $9) && (* !isin $9)) {
    _itm whowin +> %num Jum&p to $cr jump
    _mnu New jump 5 5 Jum&p to $cr jump
    _itm jump 1 $9 $chr(9) &Current connection $cr server $9
    _itm jump 2 $9 $chr(9) &New connection $cr server -m $9
    _itm whowin
    inc %num
  }
  _itm whowin $calc(%num + 1) Cl&ose window $cr .timer 1 0 _whoexit
  popit whowin +cC $1-2
}
alias _whoctcp {
  if ($input(Enter CTCP request to send to $1,1,CTCP)) ctcp $1 $ifmatch
  _showdlg whowin
}
alias -l _whoexit { if ($dialog($+(whowin.,$cid))) dialog -c $ifmatch }
alias popit {
  var %click = $_mnu(Popup,$1-)
  if (%click != $null) $gettok(%click,3-,32)
  return
}
alias _itm { _mnu AddItem $1 end $2- }
alias _mnu {
  var %result, %f = dll\popups\popups.dll
  if ($2 == $null) set %result $dll(%f,$1,.)
  else set %result $dll(%f,$1,$2-)
  if ($gettok(%result,1,32) == OK) return $gettok(%result,2-,32)
}
alias whowin {
  if (!$server) halt
  set -u %sys.show 1
  var %err, %c = $1
  if (!$1) %c = #
  if (!%c) %err = /whowin: No target given.
  ; $chan(%c).inwho <-- this has a bug
  if ($inwho == %c) %err = /WHO lookup for %c in progress. Please wait...
  elseif ($dialog($+(whowin.,$cid))) %err = /WHO window already open.
  if (%err) _err %err
  who %c
  iecho Retrieving /WHO info for %c ...
  set %who.head. $+ $cid 0
  set %raw.whoresults. $+ $cid 0
}
raw 352:*:{
  if ($($+(%,raw.whoresults.,$cid),2) !isin 10) return
  set %raw.whoresults. $+ $cid 1
  var %d = whowin. $+ $cid
  if (!$dialog(%d)) dialog -im %d whowin
  var %t = $tab($6,$+($3,@,$4),$iif(H isin $7,No,Yes),$iif(* isin $7,Yes,No),$conv($7),$+($8,$chr(160)),$5,$2,$9-)
  did -a %d 1 %t
  did -a %d 3 %t
  haltdef
}
raw 315:*:{
  var %v = $+(%,raw.whoresults.,$cid)
  if ($(%v,2) isin 10) {
    if (!$(%v,2)) {
      _whoexit
      iecho Unable to get /WHO results for $2
    }
    elseif ($dialog($+(whowin.,$cid))) {
      dialog -e $ifmatch
      dialog -t $ifmatch Who results for $2
    }
    unset $(%v) $($+(%,who.head.,$cid))
    haltdef
  }
}
alias -l _whosort {
  var %a = $gettok($gettok($1,2,9),2,64), %b = $gettok($gettok($2,2,9),2,64)
  if (%filterwho) {
    if (%a > %b) return -1
    if (%a < %b) return 1
    return 0
  }
  if (%a > %b) return 1
  if (%a < %b) return -1
  return 0
}
alias -l conv { return $iif(@ isin $1,Op,$iif(+ isin $1,Voice,Peon)) }
alias -l wtf { return $iif((www.*.* iswm $1-) || (*http://* iswm $1-),1) }

; banstat
alias banstat {
  if (!$server) return
  var %c = $_achan($1), %h = $+(@banwin,$cid)
  hadd -m %h %c $replace($iif($me ison %c,%c,$iif($activecid == $cid && @* !iswm $active,$active,-s)),Status Window,-s)
  iecho Retrieving banlist for %c ...
  if ($chan(%c).ibl) {
    blist_echotop $hget(%h,%c) %c
    var %i = 1
    while ($ibl(%c,%i)) {
      blist_echomid $hget(%h,%c) %c $ifmatch $ibl(%c,%i).by $ibl(%c,%i).ctime
      inc %i
    }
    blist_echoend $hget(%h,%c) %c
    hdel %h %c
  }
  else {
    hadd %h chans $addtok($hget(%h,chans),%c,44)
    .raw mode %c b
  }
}
raw 367:*:{
  var %h = $+(@banwin,$cid)
  if ($istok($hget(%h,chans),$2,44)) {
    if ($left($2,1) !isin $chantypes) {
      hadd %h $remtok($hget(%h,chans),$2,44)
      hdel %h $2
      return
    }
    if (!%.banlist.counter) blist_echotop $hget(%h,$2) $2-
    blist_echomid $hget(%h,$2) $2-
    halt
  }
}
raw 368:*:{
  var %h = $+(@banwin,$cid)
  if ($istok($hget(%h,chans),$2,44)) {
    if (!%.banlist.counter) iecho Unable to get banlist for $2 (or list is empty)
    else blist_echoend $hget(%h,$2) $2-
    hdel %h $2
    unset %.banlist.counter
    halt
  }
}
raw 442:*:{
  var %h = $+(@banwin,$cid)
  if ($istok($hget(%h,chans),$2,44)) {
    hadd %h $remtok($hget(%h,chans),$2,44)
    if ($numtok($hget(%h,chans),44) == 0) hfree %h
  }
}

; /blist_echo <window or channel|-s|-a> <channel> <banmask> [<ban.by> <ban.time>]
;                     $1                    $2       $3         $4        $5
alias -l blist_echotop {
  if ($gts(echo)) {
    set -u %::text Banlist for $2
    _sysdisp info echo $^s
  }
  elseif ($group(#display.basic) == on) xecho $1  $+ $c1 $+ ÚÄ( $+ $c3 Banlist for $2  $+ $c1 $+ )Ä $+ $str(Ä,$calc(53 - $len($2))) $+ ¿
  else iecho Banlist for $2
}
alias -l blist_echomid {
  var %n = $blist_num
  set -u %::text %n $3-4 $iif($5 isnum,$asctime($5))
  if ($gts(echo)) _sysdisp info echo $^s
  elseif ($group(#display.basic) == on) {
    xecho $1  $+ $c1 $+ ³ %n $xalign($3,65)  $+ $c1 $+ ³
    if ($4) xecho $1  $+ $c1 $+ ³ $_xalign($iif(! isin $4,$gettok($4,1,33),$4),46) $+ , $asctime($5,ddd mmm dd/yy hh:nntt)  $+ $c1 $+ ³
  }
  else iecho %::text
}
alias -l blist_echoend {
  if ($gts(echo)) {
    set -u %::text End of banlist for $2
    _sysdisp info echo $^s
  }
  elseif ($group(#display.basic) == on) xecho $1  $+ $c1 $+ À $+  $+ $c3 $+ -- $+ $c4 -- $+ $c1 $+ ÄÄ- $+ $c2 $+ Ä - $+ $c1 $+ $str(Ä,32) $+  $+ $c3 End of Channel Ban List  $+ $c1 $+ ÄÄÄÙ
  else iecho End of banlist for $2
}
alias -l blist_num {
  inc %.banlist.counter
  .timer.unsetblist 1 2 unset % $+ .banlist.counter
  if ($len(%.banlist.counter) < 2) return 0 $+ %.banlist.counter $+ .
  return %.banlist.counter $+ .
}
; /xecho <-s|-a|window>
alias xecho {
  var %w
  if ($1 == -s) %w = Status Window
  elseif ($1 == -a) %w = $active
  else %w = $1
  if (%xecho.mode == $null) set -u2 %xecho.mode $ishighascii($window(%w).font)
  if (%xecho.mode == 0) echo $1 $_hi2lowasc($2-)
  elseif (%xecho.mode == 1) echo $1-
}


; retry
raw *:*:{
  if ($halted) return
  if (($numeric == 471) || ($numeric isnum 473-475)) joinfail $numeric $2
}
alias -l joinfail {
  if ($istok($hget($+($cid,joinretry),@channels),$2,44)) halt
  iecho Cannot join $2 $+ . $joinerror($1)
  iecho Type /RETRY to keep on joining $2 every 20 seconds. Type /RETRY OFF to cancel all attempts.
  hadd -mu60 $+($cid,joinfail) @last $2
  halt
}
alias retry {
  var %timer = $+(.timer.,$cid,joinretry)
  if ($1 == off) {
    %timer off
    _hfree $+($cid,joinfail)
    iecho All join attempts are now cancelled.
  }
  elseif (($hget($+($cid,joinfail),@last)) && ($left($ifmatch,1) isin $chantypes)) {
    hadd -m $+($cid,joinretry) @channels $addtok($hget($+($cid,joinretry),@channels),$hget($+($cid,joinfail),@last),44)
    %timer 0 20 .raw JOIN $hget($+($cid,joinretry),@channels)
    iecho Now attempting to join $hget($+($cid,joinretry),@channels) every 20 seconds.
    hdel $+($cid,joinfail) @last
  }
}
alias -l joinerror {
  goto $1
  :471 | return Channel is already full (+l).
  :473 | return Channel is invite only (+i).
  :474 | return You are banned (+b).
  :475 | return Channel key required (+k).
}
on me:*:JOIN:*:{
  if ($istok($hget($+($cid,joinretry),@channels),$chan,44)) {
    hadd $+($cid,joinretry) @channels $remtok($hget($+($cid,joinretry),@channels),$chan,44)
    if (!$hget($+($cid,joinretry),@channels)) $+(.timer.,$cid,joinretry) off
  }
}
; eof