PnP addon that indexes all aliases in $alias(0) and $script(0)
Save the following as AC.PPA and place in %APPDATA%\mIRC\addons folder:
Code: |
; #= ppac -rs
; ########################################
; Peace and Protection
; PnP Alias Central (standard addon)
; ########################################
#.ppa.info off
[addon]
name=Alias Central
group=Core
popup=Alias Central
author=kapot
version=1.00
url=
email=
id=ppac
ppver=4.22
unload=
[files]
1=ac.ppa
[notes]
1=This addon adds the ability to index PnP aliases in $script(0) and $alias(0)
[menu]
1=Show:{ _dialog -md ppac ppac }
2=Reindex and show:{ if ($dialog(ppac)) { dialog -x ppac } | if $hget(pnp.ac.index) { hfree pnp.ac.index } | _dialog -md ppac ppac }
#.ppa.info end
on *:LOAD:{
; PnP check
if (!$_ispnp) {
echo 4 -ati2 *** This addon requires Peace and Protection by pai to use.
echo 4 -ati2 *** You can download Peace and Protection at http://www.kristshell.net/pnp/
.timer -mio 1 0 .unload -rs " $+ $script $+ "
halt
}
; Invalid load method check
if (!$istok($_cfgx(addons,ids),$readini($script,n,addon,id),32)) {
.timer -mio 1 0 .unload -rs " $+ $script $+ "
dispa Unloading ' $+ $script $+ ' $chr(40) $+ addon is not properly loaded; use /addon to load it $+ $chr(41)
halt
}
}
;
; Alias Central
;
alias ppac.scan {
if $hget(pnp.ac.index) { hfree pnp.ac.index }
hmake pnp.ac.index 100
; Scan alias files
var %a = 1, %numalias = $alias(0)
_progress.1 Scanning alias files...
while (%a <= %numalias) {
var %n = $lines($alias(%a))
var %slots = $int($calc(%n / 5))
hmake pnp.ac.scan $iif(%slots,%slots,10)
hload -n pnp.ac.scan $alias(%a)
var %b = 1, %num3 = $hget(pnp.ac.scan,0).item
while (%b <= %num3) {
tokenize 32 $hget(pnp.ac.scan,%b)
if ($1) {
if (($1 != ;) || ($left($1,1) != ;)) {
if ($isalias($1)) {
if $hget(pnp.ac.index,$1) { hadd pnp.ac.index $1 $addtok($hget(pnp.ac.index,$1),%b $+ $chr(44) $+ $alias(%a),127) }
else { hadd pnp.ac.index $1 %b $+ $chr(44) $+ $alias(%a) }
var %numleft = 0, %numright = 0
:loop
if ($chr(123) isin $hget(pnp.ac.scan,%b)) { inc %numleft }
if ($chr(125) isin $hget(pnp.ac.scan,%b)) { inc %numright }
if (%numleft > %numright) { inc %b | goto loop }
}
}
}
inc %b
}
hfree pnp.ac.scan
_progress.2 $int($calc(%a / %numalias * 100)) $nopath($alias(%a))
inc %a
}
; Scan remote script files
var %x = 1, %num = $script(0), %total
_progress.1 Scanning remote script files...
while (%x <= %num) {
var %n = $lines($script(%x))
var %slots = $int($calc(%n / 10))
hmake pnp.ac.scan $iif(%slots,%slots,10)
hload -n pnp.ac.scan $script(%x)
var %num2 = $hfind(pnp.ac.scan,alias*,0,w).data
var %y = 1
;var %total = $calc(%num2 + %total)
while (%y <= %num2) {
var %item = $hfind(pnp.ac.scan,alias*,%y,w).data
tokenize 32 $hget(pnp.ac.scan,%item)
var %alias = $iif($2 == -l,$3,$2)
if $hget(pnp.ac.index,%alias) { hadd pnp.ac.index %alias $addtok($hget(pnp.ac.index,%alias),%item $+ $chr(44) $+ $script(%x),127) }
else { hadd pnp.ac.index %alias %item $+ $chr(44) $+ $script(%x) }
inc %y
}
hfree pnp.ac.scan
_progress.2 $int($calc(%x / %num * 100)) $nopath($script(%x))
inc %x
}
;echo -atg *** Total aliases found: %total
}
dialog ppac {
title "Alias Central"
icon script\pnp.ico
option dbu
size -1 -1 500 222
box "", 1, 5 5 100 200
list 2, 15 15 80 105, sort
box "", 3, 110 5 380 200
edit "", 4, 120 15 360 180, read, multi, vsbar, hsbar
list 5, 15 120 80 80, sort
}
on *:DIALOG:ppac:init:0:{
if !$hget(pnp.ac.index) { ppac.scan }
var %x = 1
while $hget(pnp.ac.index,%x).item {
var %alias = $ifmatch
if ($numtok($hget(pnp.ac.index,%x).data,127) > 1) { did -a $dname 5 %alias }
did -a $dname 2 %alias
inc %x
}
did -a $dname 1 Alias(es): $did(2).lines - Duplicate(s): $did(5).lines
}
on *:DIALOG:ppac:sclick:*:{
if (($did == 2) || ($did == 5)) {
did -r $dname 3,4
var %found = $numtok($hget(pnp.ac.index,$did($did).seltext),127)
did -a $dname 3 Found: %found instance(s)
var %tok = 1
while $gettok($hget(pnp.ac.index,$did($did).seltext),%tok,127) {
var %line = $gettok($ifmatch,1,44)
var %script = $gettok($ifmatch,2,44)
did -a $dname 4 ; $str(-,40) $+ $crlf
did -a $dname 4 ; Line: %line Script : $nopath(%script) $+ $crlf
did -a $dname 4 ; $str(-,40) $+ $str($crlf,2)
if $hget(pnp.ac.script) { hfree pnp.ac.script }
hmake pnp.ac.script 100
hload -n pnp.ac.script %script
var %l = %line
var %numleft = 0, %numright = 0
:loop
did -a $dname 4 $hget(pnp.ac.script,%l) $+ $crlf
if ($chr(123) isin $hget(pnp.ac.script,%l)) { inc %numleft }
if ($chr(125) isin $hget(pnp.ac.script,%l)) { inc %numright }
if (%numleft > %numright) { inc %l | goto loop }
did -a $dname 4 $crlf
inc %tok
}
if $hget(pnp.ac.script) { hfree pnp.ac.script }
}
}
|
|