aIRC — File Browser
aIRCv0.8.69 / aIRCv0.8.69 / script / ident2.mrc
ident2.mrc — 17.35 KB — Download this file
;/**********************************************************************
; *
; * aIRC
; * Identifiers
; *
; **********************************************************************/
;
;;
;
; -( Nick and Address Identifiers )-
;
;;
;
;;
;
; $_nicks(channel,include,exclude,exclude2)
; returns a string of nicks
; include/exclude can contain one or more of:
; a = all nicks, o = ops, h = helpers, v = voiced, r = regular
; exclude2 can contain:
; p = protecteds, o = protecteds by op
; if you use "o" you must also use "p"
; include/exclude can be $null
_nicks {
tokenize 32 #$1 $iif($2 != $null,$2,a) $iif($3 != $null,$3,$null) $4
var %i = $nick($1,0,$2,$3),%n,%r,%a
while (%i) {
var %n = $nick($1,%i,$2,$3),%a = $_address(%n,5)
if ((p isin $4) && ($_isprot(%a,$1,$iif(o isin $4,1,0)))) { }
else { %r = %r %n }
dec %i
}
return %r
}
; $_isanybodyhome(#chan,nicks)
;
_isanybodyhome {
var %chan = $1,%nicks = $replace($2,$chr(44),$chr(32))
if ($me !ison %chan) { return }
while ($gettok(%nicks,1,32) != $null) {
if ($ifmatch ison %chan) { return $ifmatch }
%nicks = $deltok(%nicks,1,32)
}
return
}
; $_isvalidircnickname(nick)
_isvalidircnickname {
if ($chr(32) !isin $1-) && ($chr(44) !isin $1-) { return 1 }
return 0
}
; $_clonmask(nick|mask)
; if can't get mask from $1 , use $fulladdress or $address
_clonmask {
if ($_ismask($1)) { return $_mask($1,%_maskclon) }
if ($_address($1,%_maskclon) != $null) || ($_mask($fulladdress,%_maskclon) != $null) { return $ifmatch }
if ($address != $null) { return *!*@ $+ $ifmatch }
return
}
; $_normask(nick|mask)
; if can't get mask from $1 , use $fulladdress
; if cant't get mask, and "$2" , return nick if available
_normask {
if ($_ismask($1)) { return $_mask($1,%_masknorm) }
if ($_address($1,%_masknorm) != $null) || ($_mask($fulladdress,%_masknorm) != $null) { return $ifmatch }
if ($2) && (? !isin $gettok($1,1,33)) && (* !isin $gettok($1,1,33)) { return $gettok($1,1,33) }
return
}
; $_iservice(nick)
_iservice {
if ($istok(%.netbots,$gettok($1,1,33),32)) { return 1 }
return 0
}
; $_isop(nick|mask,[channel])
;
_isop {
if ($_not($_ismask($1))) {
if ($_ischan($2)) {
if ($1 isop $2) || ($1 isowner $2) { return 1 }
return 0
}
tokenize 32 $1 $+ !*@* $2
}
if ($_not($_ischan($2))) { tokenize 32 $1 * }
var %i = $ialchan($1,$2,0)
while (%i) {
if ($__isop($ialchan($1,$2,%i).nick,$2)) { return 1 }
dec %i
}
return 0
}
__isop {
if ($2 == *) {
var %i = $comchan($1,0)
while (%i) {
if ($1 isop $comchan($1,%i)) || ($1 isowner $comchan($1,%i)) { return 1 }
dec %i
}
}
elseif ($1 isop $2) || ($1 isowner $2) { return 1 }
return 0
}
; $_ialnicksov(mask,channel,n,except)
; Returns nicks prefixed with @+
_ialnicksov {
var %mask = $1,%chan = $2,%max = $3,%nonick = $4,%i,%n,%r,%nick,%f = 0
if ($_not($_ischan(%chan))) { return }
if ($_not($_isint(%max))) { %max = 0 }
%i = 1
%n = $ialchan(%mask,%chan,0)
while (%i <= %n) {
%nick = $ialchan(%mask,%chan,%i).nick
if (%nonick == $null) || (%nonick != %nick) {
%r = %r $nick(%chan,%nick).pnick
inc %f
if (%max) && (%f == %max) { return %r }
}
inc %i
}
return %r
}
; $_ialnicks(mask,channel|*,n,except)
_ialnicks {
var %mask = $1,%chan = $2,%max = $3,%nonick = $4,%i,%n,%r,%nick,%f = 0
if (%chan == $null) { %mask = * }
if ($_not($_isint(%max))) { %max = 0 }
%i = 1
%n = $ialchan(%mask,%chan,0)
while (%i <= %n) {
%nick = $ialchan(%mask,%chan,%i).nick
if (%nonick == $null) || (%nonick != %nick) {
%r = %r %nick
inc %f
if (%max) && (%f == %max) { return %r }
}
inc %i
}
return %r
}
; $_mychans
_mychans {
var %i = $chan(0),%r
while (%i) {
%r = %r $chan(%i)
dec %i
}
return %r
}
; $_myOPchans
; Returns channels where you are opped
; if $1 returns "1" if you have ops in any channel, else returns "0"
_myOPchans {
var %i = $chan(0),%r
while (%i) {
if ($me isop $chan(%i)) {
if ($1) { return 1 }
%r = %r $chan(%i)
}
dec %i
}
if ($1) { return 0 }
return %r
}
; $_comchans(nick,[oponly])
_comchans {
var %i = $comchan($1,0),%r
while (%i) {
if ($2) {
if ($me isop $comchan($1,%i)) { %r = %r $comchan($1,%i) }
}
else { %r = %r $comchan($1,%i) }
dec %i
}
return %r
}
; $_comchansattr(nick)
_comchansattr {
var %i = $comchan($1,0),%r,%s,%c
while (%i) {
%c = $comchan($1,%i)
if ($1 isowner %c) { %c = . $+ %c }
elseif ($1 isop %c) { %c = @ $+ %c }
elseif ($1 isvo %c) { %c = + $+ %c }
%r = %r %c
dec %i
}
return %r
}
; $_comchansOP(nick,channel)
; "channel" is ignored
_comchansOP {
var %i = $comchan($1,0)
while (%i) {
if ($me isop $comchan($1,%i)) && ($comchan($1,%i) != #$2) { return 1 }
dec %i
}
return 0
}
; $_chanpending(chan)
; joined channel, waiting end of who
_chanpending {
if ($me ison $1) && ($istok(%c.reial.c,$1,32)) { return 1 }
return 0
}
; $_nick2mask(nicks,mask)
_nick2mask {
var %masks
tokenize 32 $iif($2,$2,%_masknorm) $replace($1,$chr(44),$chr(32))
while ($2 != $null) {
if ($_address($2,$1) != $null) { %masks = $addtok(%masks,$ifmatch,32) }
tokenize 32 $1 $3-
}
return %masks
}
; $_snicks2mask(mask type) {
_snicks2mask { return $replace($_nick2mask($snicks,$1),$chr(32),$chr(44)) }
; $_gethost(nick)
_gethost {
var %addy = $1 $+ !*@*
if ($ial(%addy,1).host) || ($chat($1).ip) || ($fserv($1).ip) || ($gettok($query($1).address,2,64)) { return $ifmatch }
return
}
; $_mask(address,type)
; damn lame crazy IRCX!
; to khaled: $mask(nick!ident@123.45.67.XXX,3) != *!*ident@*.45.67.XXX
; $mask(nick!ident@123.45.67.XXX,3) == *!*ident@123.45.67.*
_mask {
var %address = $1,%nick = $gettok(%address,1,33),%userhost = $gettok(%address,2,33),%ident = $gettok(%userhost,1,64),%host = $gettok(%userhost,2,64),%type = $2,%temp = %address
if (%address == $null) { return }
if (%type !isnum 0-19) { %type = 5 }
if ($numtok(%host,46) == 4) && ($remove($gettok(%host,-1,46),x) == $null) && ($gettok(%host,1,46) isnum 0-255) && ($gettok(%host,2,46) isnum 0-255) && ($gettok(%host,3,46) isnum 0-255) {
%temp = %nick $+ ! $+ %ident $+ @ $+ $puttok(%host,100,4,46)
%temp = $mask(%temp,%type)
if ($gettok(%temp,-1,46) == 100) { return $gettok(%temp,1,64) $+ @ $+ $puttok($gettok(%temp,2,64),$gettok(%host,-1,46),4,46) }
return %temp
}
return $mask(%address,%type)
}
; $_address(nickname,type)
_address { return $_mask($address($1,5),$2) }
; $_getaddress(nick,masktype)
_getaddress {
var %h,%m = $iif($2,$2,5),%mask
if ($fulladdress != $null) && ($gettok($fulladdress,1,33) == $1) { %h = $fulladdress }
elseif ($_address($1,5) != $null) { %h = $ifmatch }
elseif ($query($1).address != $1) { %h = $1 $+ ! $+ $ifmatch }
if (%h != $null) { %mask = $_mask($ifmatch,%m) }
if ($_ismask(%mask)) { return %mask }
return
}
; $_ishost(host)
_ishost {
if ($_isint($remove($1,.))) && ($_not($_isip($1))) { return }
if ($__ishost($1-)) { return $1 }
return
}
__ishost {
if ($1- == $1) && ($1- != #$1) && (.* !iswm $1) && (*. !iswm $1) && (.. !isin $1) && ($len($remove($1,.))) && ($len($remove($1,@,$chr(44),:,?,*,/,<,>,[,])) == $len($1)) { return $1 }
return
}
; $_ischanban(hostmask,#channel)
_ischanban {
if ($me !ison $2) { return 0 }
var %mask = $1,%chan = $2,%i = $ibl(%chan,0)
while (%i) {
if ($ibl(%chan,%i) == %mask) { return %i }
dec %i
}
return 0
}
; $_isban(hostmask,#channel)
_isban {
var %file = $_baninifile
if ($isfile(%file)) {
if ($2) {
_dummy $read -ns" $+ $2 $1 $+ " %file
if ($readn) { return $readn }
}
_dummy $read -ns"global $1 $+ " %file
if ($readn) { return $readn }
}
return 0
}
; $_matchban(address,#channel)
_matchban {
var %h = _aircinternalbanlist,%chan = $2,%m,%tmp
%m = global $1
if ($hmatch(%h,%m,1).data) { %tmp = $hget(%h,$ifmatch) }
else {
if ($_not($_ischan(%chan))) { var %chan }
if (%chan) {
%m = %chan $1
if ($hmatch(%h,%m,1).data) { %tmp = $hget(%h,$ifmatch) }
}
}
if (%tmp != $null) {
var %x = $read -ns" $+ %tmp $+ " $_baninifile
if ($readn) { return $gettok(%tmp,1,32) %x }
}
}
; $_ismask(mask)
_ismask {
tokenize 32 $1-
if ($2- != $null) || ($count($1,@) > 1) || ($count($1,!) > 1) || ($pos($1,!,1) > $pos($1,@,1)) || (.* iswm $gettok($1,2,64)) || (*. iswm $gettok($1,2,64)) { return }
if ($gettok($1,2,64) != $null) && ($gettok($1,1,33) != $null) && ($gettok($gettok($1,1,64),2,33) != $null) { return $1 }
if (* isin $1) || (? isin $1) { return $1 }
return
}
; $_ismask2(mask)
; *!*@* only
_ismask2 {
if ($_ismask($1-)) && (*?!*@?* iswm $1) { return $1 }
return
}
; $_isfullmask(fullmask)
_isfullmask {
if ($1- == $1) && ($gettok($1,2,64) != $null) && ($gettok($1,2,33) != $null) && ($count($1,!) == 1) && ($count($1,@) == 1) && ($pos($1,!,1) < $pos($1,@,1)) && (.* !iswm $gettok($1,2,64)) && (*. !iswm $gettok($1,2,64)) && ($gettok($gettok($1,1,64),2,33) != $null) && (* !isin $1) && (? !isin $1) { return $1 }
return
}
; $_fixmask(mask)
_fixmask {
if ($1 == $null) || ($count($1,!) > 1) || ($count($1,@) > 1) || (*@*!* iswm $1) { return }
var %m,%n = *,%i = *,%h = *
if (*!*@* iswm $1) { %m = $1 }
elseif (*!* iswm $1) { %m = $1 $+ @* }
elseif (*@* iswm $1) { %m = *! $+ $1 }
elseif (*.* iswm $1) { %m = *!*@ $+ $1 }
else { %m = $1 $+ !*@* }
%m = $replace(%m,!@,!*@)
if (!* iswm %m) { %m = * $+ %m }
if (*@ iswm %m) { %m = %m $+ * }
%n = $gettok(%m,1,33)
%i = $gettok($gettok(%m,2,33),1,64)
%h = $gettok(%m,2,64)
if (.* iswm %h) { %h = * $+ %h }
if (*. iswm %h) { %h = %h $+ * }
return %n $+ ! $+ %i $+ @ $+ %h
}
_randip { return $rand(150,255) $+ . $+ $rand(10,255) $+ . $+ $rand(10,255) $+ . $+ $rand(10,255) }
_activequery {
if ($active == notify list) { return $snotify }
if (=* iswm $active) { return $right($active,-1) }
if ($query($active)) { return $active }
return
}
_active {
if ($active == notify list) { return $snotify }
if (=* iswm $active) { return $right($active,-1) }
if ($query($active)) || ($chan(#)) { return $active }
return
}
; $_chats
_chats {
var %i = $chat(0),%r
while (%i) {
if ($chat(%i).status == active) { %r = $addtok(%r,$chat(%i),32) }
dec %i
}
return %r
}
; $_myqueries
_myqueries {
var %i = $query(0),%r
while (%i) {
%r = %r $query(%i)
dec %i
}
return %r
}
`ifm {
if ($1 $2 $3) { return $^popupon }
return $^popupoff
}
`ifmm {
if ($1) { return $^popupon }
return $^popupoff
}
`mask {
var %h
if ($_getaddress($1,$2) != $null) { %h = $ifmatch }
else { %h = $_mask(nick!user@host.domain.com,$2) }
return & $+ $2 %h
}
`channel {
if ($gettok($_recent.get(channel,$1),1,32) != $null) { return $iif($1 == 10,1&0,& [ $+ [ $1 ] ] ) $replace($gettok($_recent.get(channel,$$1),1,32),&,&&) }
}
`bl {
if ($_recent.get($1,1) != $null) { return &clear list... }
}
`nicklistquery {
if ($2- == $null) || (($1) && ($_not($_connected))) { return }
if ($menu == nicklist) {
if ($snick(#,0)) { return $2- }
return
}
return $2-
}
`recent {
var %t = $_recent.get($1,$2)
if (%t != $null) { return $iif($2 == 10,1&0,& [ $+ [ $2 ] ] ) $replace(%t,&,&&) }
}
`nicklist.pre {
unset %`pn.*
set -u3 %`pn.snicks $snicks
set -u3 %`pn.numnicks $snick(#,0)
set -u3 %`pn.nick $snick(#,1)
set -u3 %`pn.isop $iif($me isop #,1,0)
if (%`pn.numnicks) && ($_connected) {
`nq.pre
set -u3 %`pn.dcc &dcc
set -u3 %`pn.ctcp c&tcp
set -u3 %`pn.commands &commands
if (%`pn.numnicks > 1) {
set -u3 %`pn.info.m &info
set -u3 %`pn.notify.m ¬ify
if (%`pn.isop) {
set -u3 %`pn.opvoice.m &op/voice
set -u3 %`pn.kickban.m &kick/ban
}
if ($ialchan(*!*@0.0.0.0,#,0) == 0) && ($ialchan(*!*@x.x.x.x,#,0) == 0) { %`pn.wclones.m = with &clones }
if ($_myOPchans(1)) { set -u3 %`pn.allchans.m &all chans }
}
elseif (%`pn.numnicks) && (%`pn.isop) {
set -u3 %`pn.kick.s kick
set -u3 %`pn.opvoice.s &op/voice
set -u3 %`pn.kickban.s &kick/ban
if ($_getclones(%`pn.fulladdress,#,0,$null).number) {
set -u3 %`pn.wclones.s with &clones
set -u3 %`pn.clonicks $_ialnicksov(%`pn.maskclon,#,20,$null)
}
}
}
}
`query.pre {
unset %`pn.*
set -u3 %`pn.numnicks 1
set -u3 %`pn.nick $_activequery
set -u3 %`pn.dcc &dcc
set -u3 %`pn.ctcp c&tcp
set -u3 %`pn.commands &commands
if ($_connected) { `nq.pre }
}
`nq.pre {
var %handle,%addy
if (%`pn.nick != $null) {
set -u3 %`pn.ignore.m &ignore
if (%`pn.numnicks == 1) {
set -u3 %`pn.notify.s ¬ify
if ($_comchansOP(%`pn.nick,#)) { set -u3 %`pn.allchans.s &all chans }
}
if (o isin $usermode) {
set -u3 %`pn.ircop.i ircop
if (%`pn.numnicks == 1) { set -u3 %`pn.ircop.s k&line }
else { set -u3 %`pn.ircop.m k&line }
}
if ($_getaddress(%`pn.nick,5) != $null) {
set -u3 %`pn.fulladdress $ifmatch
%addy = %`pn.fulladdress
set -u3 %`pn.maskclon $_mask(%`pn.fulladdress,%_maskclon)
if (%`pn.nick != $me) && ($_finduser(%`pn.fulladdress) != $null) {
%handle = $ifmatch
set -u3 %`pn.handle %handle
set -u3 %`pn.flags $_nickflags(%handle,$chan)
if (b isincs %`pn.flags) && (B isincs %`pn.flags) && ($_getuserfield(%handle,botprofile) == eggdrop) { set -u3 %`pn.boteggp &eggdrop }
set -u3 %`pn.hosts $_ruini(%`pn.handle,hosts)
if (%`pn.hosts != $null) { set -u3 %`pn.remhost &remhost }
}
if (%`pn.handle != $null) { set -u3 %`pn.users.u &users }
else { set -u3 %`pn.users.n &users }
}
else { %addy = nick!user@host.domain.com }
set -u3 %`pn.addy.0 &0 $_mask(%addy,0)
set -u3 %`pn.addy.1 &1 $_mask(%addy,1)
set -u3 %`pn.addy.2 &2 $_mask(%addy,2)
set -u3 %`pn.addy.3 &3 $_mask(%addy,3)
set -u3 %`pn.addy.4 &4 $_mask(%addy,4)
set -u3 %`pn.addy.5 &5 $_mask(%addy,5)
set -u3 %`pn.addy.6 &6 $_mask(%addy,6)
set -u3 %`pn.addy.7 &7 $_mask(%addy,7)
set -u3 %`pn.addy.8 &8 $_mask(%addy,8)
set -u3 %`pn.addy.9 &9 $_mask(%addy,9)
if (%`pn.numnicks == 1) { set -u3 %`pn.info.s &info }
}
set -u3 %`pn.addy2.0 &0 *!user@host.domain.com
set -u3 %`pn.addy2.1 &1 *!*user@host.domain.com
set -u3 %`pn.addy2.2 &2 *!*@host.domain.com
set -u3 %`pn.addy2.3 &3 *!*user@*.domain.com
set -u3 %`pn.addy2.4 &4 *!*@*.domain.com
set -u3 %`pn.addy2.5 &5 nick!user@host.domain.com
set -u3 %`pn.addy2.6 &6 nick!*user@host.domain.com
set -u3 %`pn.addy2.7 &7 nick!*@host.domain.com
set -u3 %`pn.addy2.8 &8 nick!*user@*.domain.com
set -u3 %`pn.addy2.9 &9 nick!*@*.domain.com
}
;;
;
; -( Misc )-
;
;;
_server {
if ($server) {
if ($gettok($_mini(mirc,host),2,58) != $null) { return $ifmatch }
}
return
}
_write-s { write -s" $+ $2 $+ " " $+ $1 $+ " $3- }
_askactchan { return $_parameter($chan,1,$null,ischan,$chan(1),Channel:) }
_access {
var %handle = $1,%flags = $_nickflags(%handle),%c,%i = 1,%channels = $_ruini(%handle,channels),%n = $numtok(%channels,32)
if (%flags != $null) { %flags = [[ $+ Global %flags $+ ]] }
while (%i <= %n) {
%c = $gettok(%channels,%i,32)
if ($_ruini(%handle,%c) != $null) { %flags = %flags [[ $+ %c $ifmatch $+ ]] }
inc %i
}
return %flags
}
; $_range(<string>,[max numbers])
_range {
var %string = $replace($1,$chr(32),$chr(44)),%i = 1,%n = $numtok(%string,44),%t,%x,%r,%max = 0
if ($_isint($2)) { %max = $ifmatch }
while (%i <= %n) {
%t = $gettok(%string,%i,44)
if (%t isnum) { %r = $addtok(%r,$ifmatch,44) }
elseif ($gettok(%t,1,45) isnum) && ($gettok(%t,2-,45) isnum) {
%x = $gettok(%t,1,45)
while (%x <= $gettok(%t,2,45)) {
%r = $addtok(%r,%x,44)
if (%max) && ($numtok(%r,44) >= %max) { return %r }
inc %x
}
}
if (%max) && ($numtok(%r,44) >= %max) { return %r }
inc %i
}
return %r
}
_numrango {
tokenize 32 $replace($1-,$chr(32),$chr(44))
if ($1 == $null) { return 0 }
if (- !isin $1) { return $numtok($1,44) }
var %i = 1,%r = 0
while ($gettok($1,%i,44) != $null) {
if ($numtok($gettok($1,%i,44),45) == 2) { inc %r $calc($gettok($gettok($1,%i,44),2,45) - $gettok($gettok($1,%i,44),1,45) + 1) }
else { inc %r }
inc %i
}
return %r
}
_group { return $iif($group($1).status == on,1,0) }
_iif {
if ($1) { return $2 }
return $3
}
_result2null { return $null }
_strip {
var %t = $1,%f = $lower($2),%p
%p = $remove(%f,c,m,o)
if (g isin %f) { %t = $remove(%t,$chr(7)) }
if (%p != $null) { %t = $strip(%t,%p) }
if (c isin %t) { return $strip(%t,c) }
return %t
}
_getlocalip {
if ($ip == $null) {
.localinfo -h
info.a Looking up your I.P...
.timer -o 1 1 __getlocalip 1 $1-
return 1
}
return 0
}
__getlocalip {
if ($ip != $null) {
if ($2- != $null) { $2- }
}
elseif ($1 == 5) { error.a Your IP is unknown. Press "ALT+O", go to "Local Info" and configure your I.P. }
else { .timer -o 1 1 __getlocalip $calc($1 + 1) $2- }
}