Peace & Protection 4.00 — File Browser
PeaceProtection4.00v4.0 / PeaceProtection4.00v4.0 / SCRIPT / FIRST.MRC
FIRST.MRC — 27.72 KB — Download this file
; #= P&P -rs 1
; ########################################
; Peace & Protection
; Connect routines and other things that should be
; the first loaded script
; ########################################
;
; Blacklist halting
;
on ^black:OPEN:?:*:halt
on ^black:INVITE:#:halt
on ^black:NOTICE:*:?:halt
ctcp black:*:?:.ignore -tu20 $wildsite | if ($1 != VERSION) halt
; Debugging support
#pnpdebug off
alias -l _debugstart .remove debug.log | .debug on
alias _ppdebug echo -sti2 *** (debug) $1-
alias _timetest var %ttest = $ticks | $1- | _ppdebug $calc($ticks - %ttest) ms for $1-
alias _time1 set -u1 %.ttest $ticks
alias _time2 _ppdebug $calc($ticks - %.ttest) ms
#pnpdebug end
alias -l _debugstart return
alias _ppdebug return
alias _timetest $1-
alias _time1 return
alias _time2 return
;;; More work needed (timetests etc)
; Startup routines
on *:START:{
_debugstart
; Version check
if ($version < 5.6) { echo 4 -sti2 Peace and Protection requires mIRC 5.6 or later to run! (you are using $version $+ ) | halt }
; Load vars and users of proper user
; (careful to retain $result until %!user set later)
_dirhash
.timer.loadit 1 1 .write " $+ $mircdirconfig\ $+ $result $+ \vars.mrc" $chr(124) .load -rv " $+ $mircdirconfig\ $+ $result $+ \vars.mrc" | .timer.loadit -e
.timer.loadit 1 1 .write " $+ $mircdirconfig\ $+ $result $+ \users.mrc" $chr(124) .load -ru " $+ $mircdirconfig\ $+ $result $+ \users.mrc" | .timer.loadit -e
; Var cleanup
if ($gettok(%!away,1,32) !== $me) if ($ifmatch != $null) .nick $ifmatch
if ($gettok(%!away,4,32)) .ebeeps on
if ($gettok(%!away,5,32)) .sound on
unset %~* %_* %@* %-* %.* %!* %>* %<*
%!user = $result
%!net = Offline
%!ext = 0
%_newpages = 0
%_totalpages = 0
;;; OLD SCRIPT REMOVAL
if ($exists(script\dialog.mrc)) { .unload -rs script\dialog.mrc | .remove script\dialog.mrc }
if ($exists(script\dialogs.mrc)) { .unload -rs script\dialogs.mrc | .remove script\dialogs.mrc }
if ($exists(script\themes.mrc)) { .unload -rs script\themes.mrc | .remove script\themes.mrc }
if ($exists(script\adpopups.mrc)) { .unload -rs script\adpopups.mrc | .remove script\adpopups.mrc }
if ($exists(script\servers.mrc)) { .unload -rs script\servers.mrc | .remove script\servers.mrc }
; Startup sequence
_startup.add _timetest _dde.init Initializing DDE...
; Perform startup or get profile or kill starting mirc?
var %ask = $readini config\profiles.ini startup ask
if ($gettok(%ask,1,32) == once) {
writeini config\profiles.ini startup ask $gettok(%ask,3,32)
_startup.add _fix.dde $gettok(%ask,2,32) Closing previous mIRC...
var %ask
}
; Connect to server on startup?
var %connect = $readini config\profiles.ini startup connect
if (%connect) {
remini config\profiles.ini startup connect
%_startupconnect = %connect
}
_startup.add _timetest _ck.script Verifying loaded scripts...
_startup.add _ssplay startup Startup sound...
_startup.add _timetest _ck.order1 Verifying script order...
_startup.add _timetest _ck.addon Verifying loaded addons...
_startup.add _timetest _ck.order2 Verifying end script order...
_startup.add _timetest _rehash Loading settings...
_startup.add _timetest _rechash Loading recent menus...
_startup.add _timetest _upd.markup Setting display scheme...
_startup.add _timetest _upd.texts Setting text scheme...
_startup.add _timetest _q.fkey.clr Preparing FKey queues...
_startup.add _timetest _clrtauth Clearing expired authorizations...
_startup.add _timetest _mischash Misc. settings...
_startup.add _timetest _tut.on Starting timers...
_startup.add _timetest _unlock.tb Starting timers...
if (%ask) {
if ($group(#pnpdde) == on) .ddeserver on startup $+ $_pprand(9999)
; Cancel any impending connection-on-startup too
var %opt0 = $readini -n $mircini options n0
if ($gettok(%opt0,1,44)) .timer -o 1 0 .disconnect $chr(124) profile startup
else .timer -o 1 0 profile startup
return
}
.timer -o 1 0 _startup.perform
}
alias -l _fix.dde dde $1 command "" /exit | .timer.saveini -o 1 30 saveini
alias _startup.add inc %~ref | %~c [ $+ [ %~ref ] ] = $1-
alias _startup.perform {
; Cancel any impending connection-on-startup
var %opt0 = $readini -n $mircini options n0
if (($gettok(%opt0,1,44)) && ($1 == $null)) .disconnect
.timer.start.resume -o 1 1 _startup.perform R N
if ($1) { if ($2) inc %~cur | goto resume }
%~t = $ticks
%~hide = $readini -n config\ $+ %!user $+ \config.ini cfg hidesplash
if (%~hide) window -c @Startup
else {
window -pfarodhk +bdL @Startup $int($calc(($window(-1).w - 250) / 2)) $int($calc(($window(-1).h - 350) / 2)) 250 350
if ($exists(script\pp400title-b.bmp)) drawpic -c @Startup 0 0 script\pp400title-b.bmp
}
:loop
inc %~cur
:resume
if (%~cur <= %~ref) {
if ($window(@Startup)) {
if ($exists(script\pp400title-b.bmp)) drawpic -cn @Startup 27 211 27 211 203 36 script\pp400title-b.bmp
drawrect -rfn @Startup $rgb(255,0,150) 1 31 213 $calc(%~cur / %~ref * 196) 16
drawtext -n @Startup $rgb(0,0,0) Arial 12 40 235 $gettok(%~c [ $+ [ %~cur ] ] ,3-,32)
drawdot @Startup
}
$gettok(%~c [ $+ [ %~cur ] ] ,1-2,32)
goto loop
}
.timer.start.resume off
drawpic -c
;;; fix in non beta
if ($script(devstuff.mrc)) incbuild
disps Startup completed in $:t($calc(($ticks - %~t) / 1000)) seconds
disps-div
disps Welcome to P&P $:t($:ver)
disps Press Alt+E for mIRC Setup
disps Right-click in this window for server-related options
disps Use the 'P&P' menu for configuration and other P&P options
disps-div
window -c @Startup
.timer 1 0 unset %~*
if (%~errors) _doerror Startup- %~errors $iif(%~errors > 1,errors,error) encountered during startup!See status window (red lines) for details
; Do connection-on-startup now
if (%_startupconnect) {
.timer 1 0 .server %_startupconnect
unset %_startupconnect
}
elseif ($gettok(%opt0,1,44)) .server !
;;; More temp for upgrades from prev betas
if (%`popups.1 == $null) {
`set popups.1 111100111111
`set popups.2 010111111011
`set popups.3 111111110111
`set popups.4 001111111111
`set popups.5 111111111111
`set popups.6 111001111111
`set serv.notice %`reg.notice
`set horizline ¯
`set popupmark ø
}
if ($_cfgi(dccmaxsendone) == $null) {
_cfgw dccmaxsendone 5
_cfgw dccmaxsendall 20
_cfgw dccmaxqone 2
_cfgw dccmaxqall 0
_cfgw dccqueuehide 1
_cfgw dccsendhide 0
`set dccqueueclean 01101
}
if ($numtok($gettok(%`nickcol,1,32),45) > 3) {
var %lp = 1,%nc = %`nickcol
:nnloop
%nc = $puttok(%nc,$deltok($gettok(%nc,%lp,32),3,45),%lp,32)
if (%lp < 8) { inc %lp | goto nnloop }
`set nickcol %nc
}
if ($_texts.name == In progress) {
if ($exists(schemes\progress.txs)) {
if (<dowrap> var * !iswm $read -nl4 $_cfg(text.dat)) .text schemes\progress.txs
}
}
set -u %.soundini $_cfg(sound.ini)
if ($exists(%.soundini)) {
_fixsini wav msg
_fixsini wav msgdesc
_fixsini mid msg
_fixsini mid msgdesc
_fixsini mp3 msg
_fixsini mp3 msgdesc
}
}
alias _st.error inc %~errors | echo 4 -sti2 $iif($:*,$:*,***) $1-
;;; this is used above in temp upgrades; to remove later
alias -l _fixsini {
var %line = $readini -n %.soundini $1 $2
if ((&size isin %line) && (&size& !isin %line)) writeini %.soundini $1 $2 $replace(%line,&size,&size&)
}
;
; Make sure directory structure, files, etc. are intact
;
;;; later make specific checks within CONFIG dir
;;; check for certain files present- mirc.ini? display.dat? config.ini? cfgvar.dat? (only important ones)
;;; download/logs dirs are for my use, to be removed
;;; in profiles.mrc, see if we can have mirc.ini not required in defcfg dir (since it's not needed here)
alias -l _dirhash {
mkdir SCRIPT\TEMP | mkdir CONFIG
mkdir DOWNLOAD | mkdir LOGS | mkdir SOUNDS
; user
if ($mircdirconfig\ isin $mircini) var %user = $gettok($mircini,$calc($numtok($mircini,92) - 1),92)
else var %user = $readini config\profiles.ini startup main
var %dir = config\ $+ %user
if ($isdir(%dir) == $false) var %user,%dir
if ($exists(CONFIG\profiles.ini) == $false) {
echo 4 -sti2 *** profiles.ini missing, recreating...
writeini config\profiles.ini startup ask 0
}
if (($null == $readini -n config\profiles.ini startup main) || (%user == $null)) {
if ($finddir(config\,*,1)) {
writeini config\profiles.ini startup main $remove($ifmatch,config\)
if (%user == $null) %user = $readini config\profiles.ini startup main
}
else {
echo 4 -sti2 *** Config directories missing, recreating a default configuration...
if (%user == $null) { %user = default | %dir = config\default }
writeini config\profiles.ini startup main %user
writeini config\profiles.ini %user name %user
mkdir %dir
.copy script\defcfg\* %dir
}
}
;;; Temp for upgrade from prior betas
var %j = $findfile(CONFIG\,DISPLAY.DAT,0,_dirhash2 $1-)
return %user
}
alias -l _dirhash2 {
if ($lines($1-) < 117) {
write -il108 " $+ $1- $+ " Please do not deop &nick&
write -il109 " $+ $1- $+ " Please do not ban &ban&, it matches &nick&, a protected user
write -il115 " $+ $1- $+ " Please do not kick &nick&
write -il116 " $+ $1- $+ " Please do not ban &nick&
}
if ($lines($1-) < 120) {
write -il74 " $+ $1- $+ " &nick&
write -il114 " $+ $1- $+ " &msg&
write -il115 " $+ $1- $+ " &msg&
.timer 1 10 `set nci.char ;
.timer 1 10 _cfgw nc.askin 1
}
if ($lines($1-) < 122) {
write -il40 " $+ $1- $+ " .
write -il41 " $+ $1- $+ " .
}
}
; Check that all scripts are loaded
alias _ck.script return $findfile($mircdirscript\,*.mrc,0,1,_ck.script2 $1-)
alias -l _ck.script2 {
var %line = $read -tnl1 $1-
if (($script($1-) == $null) && ($alias($1-) == $null) && (*#= P&P -* iswm %line)) {
if ($window(@Startup)) window -u @Startup
_st.error Reloading $1-
var %top = $read -tnl1 $1-
if ($wildtok(%top,-*,1,32) == -a) .load -a " $+ $1- $+ "
else .load -rs $+ $calc($script(0) - 2) " $+ $1- $+ "
}
elseif ((*#= P&P.temp * iswm %line) && ($script($1-))) {
.unload -rs " $+ $1- $+ "
}
}
; _remove.all filemask directory
; Deletes all matching files; returns count found
alias _remove.all return $findfile($2-,$1,0,.remove " $+ $1- $+ ")
; Check that certain scripts are loaded first
alias _ck.order1 {
var %moved,%file
; Make sure first.mrc is first, and unload any nonexistant script.inis
:loop1
if ($exists($script(1)) == $false) {
.unload -rs " $+ $script(1) $+ "
goto loop1
}
elseif (*#= P&P -rs 1 !iswm $read -tnl1 $script(1)) {
%file = " $+ $script(1) $+ "
if ($window(@Startup)) window -u @Startup
inc %moved
.reload -rs $+ $calc($script(0) + 1) %file
goto loop1
}
; Make sure all '0' scripts are next, and unload any remaining script.inis
var %num = 2,%spot = 2
:loop2
if ($script(%num)) {
if ($exists($script(%num)) == $false) { .unload -rs " $+ $script(%num) $+ " | dec %num }
elseif (*#=*-rs 0 iswm $read -tnl1 $script(%num)) {
if (%num != %spot) {
.reload -rs $+ %spot " $+ $script(%num) $+ "
inc %moved
}
inc %spot
}
inc %num | goto loop2
}
if (%moved) disps Moved %moved scripts
}
; Check addons loaded; check 3.20 compat
;;; gah.. needs rewurking BAD
alias _ck.addon {
var %num,%load320,%redopop,%addons,%codes,%inc,%id,%ppa,%name,%scr,%unload,%file,%ppver,%top
;;; prev. beta had addons / serverlist in old spot.. remove later
if ($readini -n config\profiles.ini addons ids != $null) {
var %import = $ifmatch
_cfgxw addons ids %import
:loop
%num = $gettok(%import,1,32)
_cfgxw addons %num $readini -n config\profiles.ini addons %num
%import = $gettok(%import,2-,32)
if (%import) goto loop
remini config\profiles.ini addons
%redopop = 1
}
if (script isin $script(adpopups.mrc)) %redopop = 1
if ($readini -n config\profiles.ini serverlist on != $null) {
_cfgxw serverlist on $readini -n config\profiles.ini serverlist on
_cfgxw serverlist last $readini -n config\profiles.ini serverlist last
_cfgxw serverlist groups $readini -n config\profiles.ini serverlist groups
remini config\profiles.ini serverlist
}
; Get list of all non-P&P files
window -hnl @.allscript
%num = 1
:loop1
if ($script(%num)) {
if (*#= P&P* -rs* !iswm $read -tnl1 $script(%num)) aline @.allscript $script(%num)
inc %num | goto loop1
}
; Go through loaded addons
%addons = $_cfgx(addons,ids)
if (%addons) {
%num = 1
:loop2
%inc = 1
%id = $gettok(%addons,%num,32)
%ppa = $_cfgx(addons,%id)
if ($exists(%ppa) == $false) {
_st.error Addon file ' $+ %ppa $+ ' missing!
%addons = $deltok(%addons,%num,32)
%inc = 0
%redopop = 1
}
elseif ($_averify(%ppa)) {
%name = $readini %ppa addon name
; Check script files from PPA
%scr = 1
%unload = 0
:loop3
%file = $readini %ppa files %scr
if (%file) {
%file = $nofile($_truename.fn(%ppa)) $+ %file
if ($script(%file) == $null) {
if ($exists(%file)) {
if ($window(@Startup)) window -u @Startup
_st.error Reloading addon script %file ( $+ %name $+ )
.load -rs " $+ %file $+ "
}
else { %unload = 1 | _st.error Addon file ' $+ %file $+ ' missing! Addon will be unloaded. }
%redopop = 1
}
else dline @.allscript $fline(@.allscript,%file,1)
inc %scr | goto loop3
}
if (%unload) { %inc = 0 | %addons = $deltok(%addons,%num,32) }
else {
%ppver = $readini %ppa addon ppver
if ((%ppver isnum) && (%ppver < 4.00)) %load320 = 1
%codes = %codes $readini %ppa addon code
; Check other files from PPA
%scr = 1
:loop4
%file = $readini %ppa other %scr
if (%file) {
%file = $nofile(%ppa) $+ %file
if ($exists(%file) == $false) {
_st.error Addon file ' $+ %file $+ ' missing! Addon ( $+ %name $+ ) may not function properly
%redopop = 1
}
inc %scr | goto loop4
}
}
}
else {
_st.error Addon file ' $+ %ppa $+ ' corrupted!
%addons = $deltok(%addons,%num,32)
%inc = 0
%redopop = 1
}
inc %num %inc
if (%num <= $numtok(%addons,32)) goto loop2
_cfgxw addons ids %addons
%!addon.ids = %addons
%!addon.codes = %codes
disps Addons loaded- %!addon.codes
}
if ($line(@.allscript,0)) {
%num = $line(@.allscript,0)
:loop5
%file = $line(@.allscript,%num)
%top = $read -tnl1 %file
if (*#= * -rs* iswm %top) {
_st.error Unloading ' $+ %file $+ ' (addon is not properly loaded; use /addon to load it)
%redopop = 1
.unload -rs " $+ %file $+ "
}
elseif ($readini -n config\profiles.ini warn $shortfn(%file) == $null) {
disps Unrecognized file ' $+ %file $+ ' loaded (non-P&P addons may not work properly)
writeini config\profiles.ini warn $shortfn(%file) 1
}
if (%num > 1) { dec %num | goto loop5 }
}
window -c @.allscript
;;; beta11 -> 12 or 12 -> 13 (uses these vars to help keep it a one time change, not cause they really matter)
if (%`soundtarg == $null) {
`set soundtarg -a
%redopop = 1
}
elseif (%`popups.hideop == $null) {
`set popups.hideop 0
%redopop = 1
}
; Update popups, calculate interfaces
if ((%redopop) || ($exists($_cfg(adpopups.mrc)) == $false)) _apopups
%!addon.i = $_addon.names(4)
; 3.20 compat?
if (%load320) {
if ($script(addon320.mrc) == $null) .load -rs script\addon320.mrc
_startup.add _timetest _pnp320compat Configuring PnP 3.xx addon compatibility...
}
elseif ($script(addon320.mrc)) {
.unload -rs " $+ $ifmatch $+ "
unset %col.* %= %font.fixtab %pp.ver %pp.net
}
}
; Check that certain scripts are last
alias _ck.order2 {
var %top,%bad,%file
; Determine scripts to be reloaded
window -hnls @.reload
var %num = $script(0)
:loop1
%top = $read -tnl1 $script(%num)
if (*#=*-rs* iswm %top) if ($gettok(%top,$numtok(%top,32),32) isnum) if ($ifmatch < 0) aline @.reload $ifmatch $script(%num)
if (%num > 1) { dec %num | goto loop1 }
; Check for order, don't reload if already in order
var %check = $script(0)
%num = 1
:loop2
%file = $gettok($line(@.reload,%num),2-,32)
if ($script(%check) != %file) %bad = 1
else {
if (%num < $line(@.reload,0)) { dec %check | inc %num | goto loop2 }
}
if (%bad) {
if ($window(@Startup)) window -u @Startup
%num = $line(@.reload,0)
:loop3
%file = $gettok($line(@.reload,%num),2-,32)
.reload -rs $+ $calc($script(0) + 1) " $+ %file $+ "
if (%num > 1) { dec %num | goto loop3 }
}
window -c @.reload
}
;
; more events
;
on *:DNS:{
var %who = $iif($nick,$nick,$iif($raddress == $naddress,$iaddress,$naddress)),%do = %_dns. [ $+ [ %who ] ]
unset %_dns. [ $+ [ %who ] ]
if (%do) {
if ($raddress == $null) $_p2s($gettok(%do,2,32))
else $_p2s($gettok(%do,1,32))
halt
}
}
alias -l _dnsshow _Q.fkey 1 $calc($ctime + 300) clipboard $raddress | <dns.end> $iif($raddress == $iaddress,$naddress) $iaddress $iif($raddress != $iaddress,$naddress) $result
alias -l _dnsfail {
if (($nick) && ($iaddress == $null) && ($naddress == $null)) <dns.fail1> $nick
elseif ($iaddress == $null) <dns.fail2> $naddress
else { _Q.fkey 1 $calc($ctime + 300) clipboard $iaddress | <dns.fail3> $iaddress $result }
}
; for _recseen and nick completion; for input cross-compatibility
alias _getcc set -u1 %.cmdchar $readini -n $mircini text commandchar
on *:INPUT:*:{
set -u1 %.from-input-nc 1
if (($target !ischan) && ($query($target) == $null) && (=* !iswm $target)) return
if (%_lastsrec) .timer 1 0 unset % $+ _lastsrec
_getcc
if (($left($1,1) != %.cmdchar) || ($mouse.key & 2)) { if (($1- == $null) && ($left($1,1) == $null)) halt | set -u1 %.input.text /say $1- | set -u1 %.input.type say }
elseif (?me iswm $1) { set -u1 %.input.text $1- | set -u1 %.input.type me }
else { set -u1 %.input.text $1- | set -u1 %.input.type cmd }
; Do inline nick completion -now-
if (($target ischan) && ($mouse.key !& 2) && (%`nci.char isin $1-)) {
var %num = 1,%check = $ifmatch $+ ?*
:loop
if ($wildtok(%.input.text,%check,%num,32)) {
var %tok = $ifmatch,%old = $right($ifmatch,$calc(- $len(%`nci.char))),%aft
:loopc | if ($right(%old,1) isin -!"#$%&'()*+,./:;<=>?@~) { %aft = $ifmatch $+ %aft | %old = $left(%old,-1) | goto loopc }
var %found = $_nci(%old,$chan)
if (($numtok(%found,32) > 1) && ($_cfgi(nc.askin))) { if (%.input.type == say) set -u1 %.input.text $deltok(%.input.text,1,32) | _juryrig2 _ncin2 %old $_s2c(%found) $chan %tok $+ %aft %.input.type %.input.text | halt }
if (%found ison $chan) %aft = $_ncin3(%found,$chan,%.input.type) $+ %aft
else { %aft = %`nci.char $+ %old $+ %aft | inc %num }
set -u1 %.input.text $reptok(%.input.text,%tok,%aft,1,32)
goto loop
}
}
}
alias _ncin2 set %.part $1 | set %.found $2 | var %aft = $_ncin3($$dialog(nickcomp,nickcomp,-4),$3,$6) $+ $right($5,-1) | editbox -n $3 $reptok($7-,$4,%aft,1,32)
alias _ncin3 if ($3 == cmd) return $1 | return $_finalmsg($replace($_msg(nci),&op&,$_stsym($1,$2),&nick&,$1,&chan&,$2))
; For invite checking
raw 324:*:{
if ($istok(%-invited,$2,32)) {
%-invited = $remtok(%-invited,$2,1,32)
%-invited2 = %-invited2 $2
if ($_optn(3,11)) { <invite.found> $2 %-invn. [ $+ [ $2 ] ] 1 $3- | join -n $2 }
else { <invite.found> $2 %-invn. [ $+ [ $2 ] ] 0 $3- | _recseen chan $2 }
_ssplay invite
unset %-invn. $+ $2
_recseen nick %-invn. [ $+ [ $2 ] ]
halt
}
}
raw 329:*:if ($istok(%-invited2,$2,32)) { %-invited2 = $remtok(%-invited2,$2,1,32) | halt }
raw 403:*no such channel*:{
if ($istok(%-invited,$2,32)) {
%-invited = $remtok(%-invited,$2,1,32)
<invite.fail> $2 %-invn. [ $+ [ $2 ] ]
unset %-invn. $+ $2
_recseen nick %-invn. [ $+ [ $2 ] ]
_recseen chan $2
halt
}
}
;
; On notices so we know if they are 'sort of' opnotices
;
on ^*:NOTICE:*:?:{
if (($chr(35) isin $1-3) && ($istok(%!servnick,$nick,32) == $false)) {
var %num = $comchan($nick,0)
:loop
if (%num) {
if (($comchan($nick,%num) isin $1-3) && ($comchan($nick,%num).op) && ($nick isop $comchan($nick,%num))) {
set -u1 %.opnotice $comchan($nick,%num) | return
}
dec %num | goto loop
}
}
unset %.opnotice
}
;
; Pre-determine any standard DCC to be invalid
; %.dcc.invalid = invalid status, %.dcc.file = filename, %.dcc.port %.dcc.size %.dcc.id %.dcc.ip set also
;
ctcp *:DCC:{
unset %.dcc.invalid
if ($istok(CHAT SEND RESUME ACCEPT,$2,32)) {
; if (standard) DCC, check for invalid
if ((" isin $3-) && (($2 == CHAT) || (& "* *" * !iswm $2-) || ($count($2-,") != 2))) { set -u1 %.dcc.invalid Invalid quotes | return }
if (("* iswm $3) && ($2 != CHAT)) { set -u1 %.dcc.file $gettok($2-,2,34) | var %rest = $gettok($2-,3-,34) }
else { set -u1 %.dcc.file $3 | var %rest = $4- }
if ($istok(RESUME ACCEPT,$2,32)) {
set -u1 %.dcc.port $gettok(%rest,1,32) | set -u1 %.dcc.size $gettok(%rest,2,32) | set -u1 %.dcc.id $gettok(%rest,3,32)
if (%.dcc.port == $null) { set -u1 %.dcc.invalid Missing parameters | return }
}
else {
set -u1 %.dcc.ip $gettok(%rest,1,32) | set -u1 %.dcc.port $gettok(%rest,2,32) | set -u1 %.dcc.size $gettok(%rest,3,32) | set -u1 %.dcc.id $gettok(%rest,4,32)
if (%.dcc.port == $null) { set -u1 %.dcc.invalid Missing parameters | return }
if ((%.dcc.ip !isnum) || (. isin %.dcc.ip) || ($longip(%.dcc.ip) == $null)) { set -u1 %.dcc.invalid Invalid IP- %.dcc.ip | return }
if (($gettok($longip(%.dcc.ip),1,46) == 127) || ($gettok($longip(%.dcc.ip),1,46) > 223) || ($gettok($longip(%.dcc.ip),1,46) == 0) || ($gettok($longip(%.dcc.ip),1-2,46) == 128.0) || ($gettok($longip(%.dcc.ip),1,46) == 192.0.0)) { set -u1 %.dcc.invalid Invalid IP- $longip(%.dcc.ip) | return }
}
if (($2 != CHAT) && ($remove(%.dcc.file,<,>,$chr(124),:,*,?,/,\,") != %.dcc.file)) set -u1 %.dcc.invalid Invalid filename
elseif ((%.dcc.size != $null) && ((%.dcc.size !isnum) || (. isin %.dcc.size) || (%.dcc.size < 1) || ($len(%.dcc.size) > 9))) set -u1 %.dcc.invalid Invalid size
elseif (%.dcc.port == 0) { if ((%.dcc.id !isnum) || (. isin %.dcc.id) || (%.dcc.id < 0)) set -u1 %.dcc.invalid Invalid SOCKS parameters }
elseif ((%.dcc.port !isnum 1024-65535) || (. isin %.dcc.port)) set -u1 %.dcc.invalid Invalid port
}
}
;
; Predetermine who is banned
; If over 10 users, only stores count
;
on *:BAN:#:{
set -u1 %.ban.count $ialchan($banmask,$chan,0)
if (%.ban.count < 11) {
var %who,%num = %.ban.count
:loop
%who = %who $ialchan($banmask,$chan,%num).nick
if (%num > 1) { dec %num | goto loop }
set -u1 %.ban.who %who
}
else unset %.ban.who
}
;
; Allow any number of routines to trigger for a whois-on-join
;
on *:JOIN:#:unset %.joinwhois.do | %.joinwhois.show = 0
;
; Pre-halt any non-DCC, non-VERSION CTCPs if being ignored
;
ctcp *:*:{
if ($1 != VERSION) {
if ((%-ignore.ctcp) || (%-ignore.ctcp. [ $+ [ $site ] ] )) halt
}
}
;
; Support for multiple instances
;
; For recognition
alias _ispnp return 1
; DDE stuff can be disabled
#pnpdde on
; Selects a DDE name (run at startup)
; May be desired to clear window afterwards
alias _dde.init {
; Only one copy should do this at a time
if ($lof(script\temp\semaphor.) > 0) {
if ($window(@Startup)) window -h @Startup
if ($read -nl1 script\temp\semaphor. < $calc($ctime - 60)) {
echo 4 -sti2 *** Startup problems detected from earlier
echo 4 -sti2 *** Disabling DDE (may cause problems if you open multiple mIRCs)
.remove script\temp\semaphor.
.disable #pnpdde
.ddeserver off
%!ext = 0
echo -sti2 *** Performing P&P startup... (profile - %!user $+ )
return
}
inc %_dde.skip
if (%_dde.skip == 1) {
echo -sti2 *** Waiting for other copies of PnP to finish starting... (use /ddeoff if having DDE problems)
editbox -s /ddeoff
}
if (%_dde.skip < 12) { .timer.start.resume -o 1 1 _startup.perform R | halt }
echo 4 -sti2 *** Timed out waiting, PnP must have crashed during startup earlier or in another copy?
editbox -s
write -c script\temp\semaphor. $calc($ctime - 60)
}
else write -c script\temp\semaphor. $ctime
.timer.oops -o 1 1 .remove script\temp\semaphor.
; Temporarily switch DDE off
.ddeserver off
var %dat,%dde,%ext
; Scan mIRC IDs file and 'clean out' any unused entries
if ($lof(script\temp\mircids.) > 0) {
var %num = 1
:clean
%dat = $read -tnl [ $+ [ %num ] ] script\temp\mircids.
if (%dat) {
%dde = $gettok(%dat,1,32)
var %dde. $+ %dde = $isdde(%dde)
if (%dde. [ $+ [ %dde ] ] ) { inc %num | goto clean }
; Unused- delete temps and remove entry
_remove.all $gettok(%dat,2,32)) $+ .* $mircdirscript\temp\
.write -dl [ $+ [ %num ] ] script\temp\mircids.
goto clean
}
}
; Find the first available dde
:loop
%dde = mIRC $+ %ext
if (%dde. [ $+ [ %dde ] ] == $null) { if ($isdde(%dde)) { inc %ext | goto loop } }
elseif (%dde. [ $+ [ %dde ] ] ) { inc %ext | goto loop }
.ddeserver on %dde
if (%ext == $null) %ext = 0
; Reserve this DDE
write script\temp\mircids. %dde %ext
%!ext = %ext
.timer.oops off
.remove script\temp\semaphor.
echo -sti2 *** Performing P&P startup... (profile - %!user $+ )
}
; _broadcast command
; Causes all other copies of P&P to run a command
alias _broadcast {
if ($lof(script\temp\mircids.) > 0) {
var %dat,%num = 1
:loop
%dat = $read -tnl [ $+ [ %num ] ] script\temp\mircids.
if (%dat) {
if ($gettok(%dat,1,32) != $ddename) {
dde $ifmatch command "" /if ($_ispnp) $1-
}
inc %num
goto loop
}
}
}
; _broadcastp command
; Causes all other copies of P&P with same profile to run a command
alias _broadcast {
if ($lof(script\temp\mircids.) > 0) {
var %dat,%num = 1
:loop
%dat = $read -tnl [ $+ [ %num ] ] script\temp\mircids.
if (%dat) {
if ($gettok(%dat,1,32) != $ddename) {
dde $ifmatch command "" /if (($_ispnp) && (%!user == [ %!user ] $+ )) $1-
}
inc %num
goto loop
}
}
}
; Check if an ini is in use, other than by us
alias _inuse {
if ($lof(script\temp\mircids.) > 0) {
var %dat,%num = 1
:loop
%dat = $read -tnl [ $+ [ %num ] ] script\temp\mircids.
if (%dat) {
if ($gettok(%dat,1,32) != $ddename) {
if ($1- == $dde $gettok(%dat,1,32) inifile "") return 1
}
inc %num
goto loop
}
}
return 0
}
#pnpdde end
alias _dde.init %!ext = 0 | echo -sti2 *** Performing P&P startup... (profile - %!user $+ )
alias _broadcast return
alias _broadcastp return
alias _inuse return 0
; Enable or disable dde things
alias ddeoff {
write -c script\temp\semaphor.
.ddeserver off
.disable #pnpdde
disps DDE features disabled. If you open multiple copies of PnP (from the same copy of mIRC) things may not work properly.
}
alias ddeon {
if ($group(#pnpdde) == on) disps DDE features are already enabled.
else {
disps DDE features enabled. You should restart PnP for this to properly take effect.
.ddeserver on PNPTEMP
.enable #pnpdde
}
}