on &^*:join:# {
if ($nick != $me) {
cntry.main join $address $chan
unset %cntry.*
}
}
on &^*:part:# {
if ($nick != $me) {
cntry.main part $address $chan
unset %cntry.*
}
}
on &^*:quit {
;; on quit has no easy way of telling which channels the quit occurred on
;; so we have to figure it out by hand (using $comchan)
if ($nick != $me) {
;; didn't have to worry about addresses in quit until 5.71
if ($version < 5.71) return
;; now we have to find out all the chans the quitter is on
set %cntry.i 1
:loop {
set %cntry.quitchans %cntry.quitchans $+ $comchan($nick,%cntry.i) $+ ,
if (%cntry.i >= $comchan($nick,0)) goto end
inc %cntry.i
goto loop
}
:end
cntry.main quit $address $left(%cntry.quitchans,$calc($len(%cntry.quitchans)-1)) $1-
unset %cntry.*
}
}
alias cntry.main {
;; we retrieve user settings from mirc.ini
;; show user addresses? (n0:2)
set %cntry.tmp $readini -n $mircini options n0
;; no need to continue if user addresses aren't shown
if ($gettok(%cntry.tmp,2,44) == 0) return
;; alternative (short) join/parts? (n2:19)
set %cntry.tmp $readini -n $mircini options n2
set %cntry.shortjp $gettok(%cntry.tmp,19,44)
;; joins/parts in chan?
if ($version < 5.7) {
;; settings stored in mirc.ini [options] (n3:25)
set %cntry.tmp $readini -n $mircini options n3
set %cntry.jchan $gettok(%cntry.tmp,25,44)
set %cntry.pchan $gettok(%cntry.tmp,25,44)
}
else {
;; 5.7 added [events] section with channel specific settings
;; default 0=chan, 1=status, 2=hide
;; chan 0=default, 1=chan, 2=status, 3=hide
set %cntry.tmp $readini -n $mircini events default
set %cntry.jchan $calc($gettok(%cntry.tmp,1,44) + 1)
set %cntry.pchan $calc($gettok(%cntry.tmp,2,44) + 1)
if ($ini($mircini,events,$3)) {
set %cntry.tmp $readini -n $mircini events $3
set %cntry.jchan.tmp $gettok(%cntry.tmp,1,44)
if (%cntry.jchan.tmp != 0) set %cntry.jchan %cntry.jchan.tmp
set %cntry.pchan.tmp $gettok(%cntry.tmp,2,44)
if (%cntry.pchan.tmp != 0) set %cntry.pchan %cntry.pchan.tmp
}
if (($1 == join) && (%cntry.jchan == 3)) return
if (($1 == part) && (%cntry.pchan == 3)) return
}
;; get the country
cntry.get $gettok($2,$gettok($2,0,46),46)
;; echo the join/part/quit, if needed
if ($result) {
;; $1=join|part, $2=address, $3=chan
if (($1 == join) || ($1 == part)) {
if ((($1 == join) && (%cntry.jchan == 1)) || (($1 == part) && (%cntry.pchan == 1))) {
;; in chan
set %cntry.echo -t $3
set %cntry.extra :
}
elseif ((($1 == join) && (%cntry.jchan == 2)) || (($1 == part) && (%cntry.pchan == 2))) {
;; in status
set %cntry.echo -tse
set %cntry.extra $chr(32) $+ $3 $+ :
}
if (%cntry.shortjp == 1) {
echo $colour($1) %cntry.echo *** $upper($mid($1,1,1)) $+ $mid($1,2,$mid($1,2,0)) $+ s $+ %cntry.extra $nick ( $+ $2 ( $+ $result $+ ) $+ ) $+
}
else {
echo $colour($1) %cntry.echo *** $nick ( $+ $2 ( $+ $result $+ ) $+ ) has $1 $+ ed $chan $+
}
}
elseif ($1 == quit) {
;; this is me trying to emulate mirc's default quit behaviour as much as possible
if ($4 != $null) set %cntry.quitmsg ( $+ $4- $+ )
set %cntry.defs $readini -n $mircini events default
set %cntry.i 1
:qloop {
if (%cntry.i > $numtok($3,44)) goto qend
set %cntry.qchan $calc($gettok(%cntry.defs,3,44) + 1)
if ($ini($mircini,events,$gettok($3,%cntry.i,44))) {
set %cntry.tmp $readini -n $mircini events $gettok($3,%cntry.i,44)
set %cntry.qchan.tmp $gettok(%cntry.tmp,3,44)
if (%cntry.qchan.tmp != 0) set %cntry.qchan %cntry.qchan.tmp
}
if (%cntry.qchan == 4) {
inc %cntry.i
goto qloop
}
if (%cntry.qchan == 1) {
if (%cntry.shortjp == 1) {
echo $colour($1) -t $gettok($3,%cntry.i,44) *** Quits: $nick ( $+ $2 ( $+ $result $+ ) $+ ) %cntry.quitmsg $+
}
else {
echo $colour($1) -t $gettok($3,%cntry.i,44) *** $nick ( $+ $2 ( $+ $result $+ ) $+ ) Quit %cntry.quitmsg $+
}
}
elseif (%cntry.qchan == 2) {
if (%cntry.instatus != 1) {
set %cntry.instatus 1
echo $colour($1) -tse *** $nick ( $+ $2 ( $+ $result $+ ) $+ ) Quit %cntry.quitmsg $+
}
}
elseif (%cntry.qchan == 3) {
if (%cntry.shortjp == 1) {
echo $colour($1) -t $gettok($3,%cntry.i,44) *** Quits: $nick ( $+ $2 ( $+ $result $+ ) $+ ) %cntry.quitmsg $+
}
else {
echo $colour($1) -t $gettok($3,%cntry.i,44) *** $nick ( $+ $2 ( $+ $result $+ ) $+ ) Quit %cntry.quitmsg $+
}
if (%cntry.instatus != 1) {
set %cntry.instatus 1
echo $colour($1) -tse *** $nick ( $+ $2 ( $+ $result $+ ) $+ ) Quit %cntry.quitmsg $+
}
}
inc %cntry.i
goto qloop
}
:qend
}
haltdef
}
}