Peace & Protection 4.00 — File Browser
PeaceProtection4.00v4.0 / PeaceProtection4.00v4.0 / SCRIPT / ALIAS2.MRC
ALIAS2.MRC — 9.11 KB — Download this file
; #= P&P -a
; **********************
; Unsorted routines
; **********************
;;;###*** Not yet divided- interfaces to temporarily load ***###;;;
; Load and unload temp scripts
_load if ($script($1.mrc) == $null) .load -rs $+ $calc($script(0) - 2) "script\ $+ $1.mrc" | $2-
_unload if ($script($1.mrc)) .timer -o 1 0 .unload -rs " $+ $ifmatch $+ "
;_load register _bug $1-
bug _error Sorry, this feature is disabled.
feedback bug 2
theme if ($1 == $null) _dialog -am themes themes | else _load themfile _theme $1-
line _load themfile _line $1-
ncedit _load themfile _ncedit $1-
fontfix _load themfile _fontfix $1-
awaycfg _load config2 _awaycfg $1-
about _load config2 _about $1-
popups _load config2 _popups $1-
config _load config _config $1-
cfg _load config _config $1-
protedit _load protedit _protedit $1-
;;;###*** Not yet divided ***###;;;
inv invite $1-
invite {
if ($2) {
if ($_ischan($1)) invite $_nc($2) $1
else invite $_nc($1) $2
}
elseif ($active ischan) {
if ($1) invite $_nc($1) $active
else invite $_entry(-1,$null,User to invite to,$active,?) $active
}
elseif ($query($active) == $active) {
if ($1) invite $active $1
else invite $active $_entry(-1,$chan(1),Invite,$active,to what channel?)
}
elseif (=* iswm $active) {
if ($1) invite $right($active,-1) $1
else invite $right($active,-1) $_entry(-1,$chan(1),Invite,$right($active,-1),to what channel?)
}
else _qhelp /invite
}
who if ($1 == ) who $2- | elseif ($1 != $null) { if ($show) _Q.who user $1- | else _Q.who hide $1- } | else _qhelp /who
_Q.who %-whopend = %-whopend $1 | who $2-
myver {
if (%!addon.ids == $null) me is using Peace & Protection $:ver by pai
else me is using Peace & Protection $:ver by pai - with addons $_addon.names(1)
say You can get it at $:www
}
p&p myver
;
; Recent list trackers (not actively kept sync'd with other mircs)
;
; _recent type max# value
_recent {
if ($3 == $null) return
var %num = 2,%file = $_cfg($1.rct)
window -hl @.recent
aline @.recent $3-
if ($exists(%file)) loadbuf @.recent %file
%= [ $+ [ $1. ] $+ [ 1 ] ] = $3-
:loop
if ($line(@.recent,%num) != $3-) { %= [ $+ [ $1. ] $+ [ %num ] ] = $ifmatch | inc %num }
else dline @.recent %num
if ((%num <= $2) && (%num <= $line(@.recent,0))) goto loop
savebuf 1- $+ $2 @.recent %file
window -c @.recent
%= [ $+ [ $1.clr ] ] = Clear this list
}
; _recclr type
_recclr unset %= $+ $1.* | _broadcastp unset % $+ = $+ $1.* | .remove $_cfg($1.rct)
; $_rec(type,#)
_rec if (%= [ $+ [ $1. ] $+ [ $2 ] ] ) return $2. $left($replace($ifmatch,&,&&),40) $+ $iif($len($ifmatch) > 40,...) | return
_rechash {
window -hl @.recent
unset %=*
var %dir = $mircdirconfig\ $+ %!user $+ \
%dir = $findfile(%dir,*.rct,0,_rechash2 $1-)
window -c @.recent
}
_rechash2 {
clear @.recent
loadbuf @.recent " $+ $1- $+ "
:loopN
%= [ $+ [ $replace($nopath($1-),.rct,.) ] $+ [ $line(@.recent,0) ] ] = $line(@.recent,$line(@.recent,0))
dline @.recent $line(@.recent,0)
if ($line(@.recent,1)) goto loopN
%= [ $+ [ $gettok($nopath($1-),1,46) ] $+ [ .clr ] ] = Clear this list
}
;
; Another 'recent lists' type that merely stores in a file, not in vars
;
; _recent2 type max# value
_recent2 {
if ($3 == $null) return
var %file = $_cfg($1.lis)
window -hl @.recent
aline @.recent $3-
if ($exists(%file)) {
loadbuf @.recent %file
var %line = -ns" $+ $3- $+ "
%line = $read %line %file
if ($readn) dline @.recent $calc(1 + $readn)
}
savebuf 1- $+ $2 @.recent %file
window -c @.recent
}
;
; Server list (status window) update
;
_slistpop set -u %.serversl $_cfgx(serverlist,groups) | set -u %.serverslo $_cfgx(serverlist,on)
serverlist {
var %num,%old,%tok,%bit,%curr,%sini,%groups,%group,%curr,%prog,%ln,%line,%desc,%serv,%port,%win
if ($1 == off) { _cfgxw serverlist on 0 | disps Serverlist disabled. }
elseif ($1 == on) {
_cfgxw serverlist on 1
if ($2) _cfgxw serverlist groups $_c2s($2-)
if ($_cfgx(serverlist,groups) != $null) disps Serverlist enabled. ( $+ $ifmatch $+ )
else disps Serverlist enabled but empty.
}
elseif ($1) {
%bit = +
%num = 1
%old = $_cfgx(serverlist,groups)
:loopM
%tok = $gettok($1-,%num,32)
if (+* iswm %tok) { %bit = + | %tok = $right(%tok,-1) }
elseif (-* iswm %tok) { %bit = - | %tok = $right(%tok,-1) }
if (%tok) {
if (%bit == +) {
if ($istok(%old,%tok,32)) disps $:s(%tok) is already in serverlist
else disps Adding $:s(%tok) to serverlist
%old = $addtok(%old,%tok,32)
}
else {
if ($istok(%old,%tok,32)) disps Removing $:s(%tok) from serverlist
else disps $:s(%tok) is not in serverlist
%old = $remtok(%old,%tok,1,32)
}
}
if (%num < $numtok($1-,32)) { inc %num | goto loopM }
_cfgxw serverlist groups %old
}
elseif ($_cfgx(serverlist,on)) {
if ($_cfgx(serverlist,groups) != $null) disps Serverlist is enabled. ( $+ $ifmatch $+ )
else disps Serverlist is enabled but empty.
}
else disps Serverlist is disabled.
%sini = $readini -n $mircini files servers
if (%sini == $null) %sini = servers.ini
if ($exists(%sini) == $false) _error Cannot find servers.iniCannot update serverlist without a servers file
%curr = $file(%sini).mtime $_cfgx(serverlist,on) $_cfgx(serverlist,groups)
if (($exists($_cfg(servers.mrc))) && (%curr == $_cfgx(serverlist,last))) { disps Serverlist is up-to-date. | return }
_cfgxw serverlist last %curr
disps Refreshing serverlist popups...
window -hl @.servlist
aline @.servlist ; #= P&P -rs 0
aline @.servlist ; ########################################
aline @.servlist ; Peace & Protection
aline @.servlist ; Servers popups (*auto-generated*)
aline @.servlist ; ########################################
if (1 != $_cfgx(serverlist,on)) goto sloff
aline @.servlist menu status $chr(123)
%groups = $_cfgx(serverlist,groups)
if (%groups == $null) goto none
if ($exists(%sini) == $false) goto none
_progress.1 Updating server popup lists...
%prog = $numtok(%groups,32) + 1
%curr = 0
; Open a window per group
window -hl @.prescan
%num = 1
:loop0
%group = $gettok(%groups,%num,32)
if (%group) {
_progress.2 $int($calc(%curr / %prog * 100)) Scanning %group
inc %curr
window -hsl @.sl@ $+ %group
clear @.prescan
filter -fw %sini @.prescan *GROUP: $+ %group
filter -fw %sini @.prescan n*=Random & %group *
%ln = $line(@.prescan,0)
:loop9
%line = $gettok($line(@.prescan,%ln),2-,61)
%desc = $left(%line,$calc($pos(%line,SERVER:) - 1))
%serv = $mid(%line,$calc($pos(%line,SERVER:) + 7),999)
%serv = $left(%serv,$calc($pos(%serv,GROUP:) - 1))
%port = $gettok(%serv,2,58)
%serv = $gettok(%serv,1,58)
if (($gettok(%desc,1,58) == %group) && ($numtok(%desc,58) > 1)) %desc = $gettok(%desc,2-,58)
if ($gettok(%desc,1,32) == Random) aline @.sl@ $+ %group - $remtok(%desc,%group,1,32) %serv %port
else aline @.sl@ $+ %group %desc %serv %port
if (%ln > 1) { dec %ln | goto loop9 }
inc %num | goto loop0
}
window -c @.prescan
; Copy servers to file
_progress.2 $int($calc(%curr / %prog * 100)) Saving to popups
%num = 1
:loop3
%group = $gettok(%groups,%num,32)
if (%group) {
%win = @.sl@ $+ %group
if ($line(%win,0) == 0) goto next3
aline @.servlist %group
var %old,%bit
%curr = 0
%ln = 1
:loop4
%line = $line(%win,%ln)
if (%line) {
%serv = $gettok(%line,1,127)
if ($gettok(%serv,1,44) != %old) {
%old = $ifmatch
if ($numtok(%serv,44) > 1) {
if (%curr < 2) {
%tok = %old $+ , *
if ($fline(%win,%tok,0,0) == $calc($line(%win,0) - %ln + 1)) %bit = 1
}
if (%curr == 1) aline @.servlist .-
%curr = 2
if (%bit != 1) {
if ($findtok(US EU CA NZ AU,%old,1,32)) aline @.servlist . $+ $gettok(USA.Europe.Canada.New Zealand.Australia,$ifmatch,46)
else aline @.servlist . $+ %old
}
}
else {
aline @.servlist . $+ $remtok(%old,-,1,32) $+ :server $gettok(%line,2,127) $ $+ gettok( $+ $_c2s($gettok(%line,3,127)) $+ ,$_pprand( $+ $numtok($gettok(%line,3,127),44) $+ ),32)
if (%curr == 0) %curr = 1
}
}
if ($numtok(%serv,44) > 1) aline @.servlist $iif(%bit,.,..) $+ $iif(%bit,%serv,$gettok(%serv,2-,44)) $+ :server $gettok(%line,2,127) $ $+ gettok( $+ $_c2s($gettok(%line,3,127)) $+ ,$_pprand( $+ $numtok($gettok(%line,3,127),44) $+ ),32)
inc %ln | goto loop4
}
:next3
window -c %win
inc %num | goto loop3
}
_progress.2 100 Done!
; Load script file
:none
aline @.servlist -
aline @.servlist $chr(125)
:sloff
savebuf @.servlist $_cfg(servers.mrc)
window -c @.servlist
_broadcastp .unload -rs " $!+ $!script(servers.mrc) $!+ " $chr(124) .load -rs2 $_cfg(servers.mrc)
.timer 1 0 .unload -rs " $+ $script(servers.mrc) $+ " $chr(124) .load -rs2 $_cfg(servers.mrc)
}