on *:quit:{
if (*.* *.* iswm $1-) {
; Quit was a result of a netsplit
if (!$hget(netsplit)) hmake netsplit 10
elseif (!$hfind(netsplit, $replace($1-,$chr(32),@), 0, w)) timer 1 5 netsplit_show $1-
; If hash table 'netsplit' doesn't exist, create it
; Else if there are no entries in 'netsplit' for a split between servers $1 & $2 (first detection of this netsplit) then start timer
var %i = 1, %item
while $comchan($nick, %i) {
%item = $replace($1- $ifmatch,$chr(32),@)
if ($hget(netsplit,%item) == $null) echo -c info $comchan($nick, %i) * Netsplit occurring between $+(,$1,) and $+(,$2,...)
; If no item already exists with the name %item (the first detection of this netsplit in this channel) then echo to that channel
hadd netsplit %item $addtok(%item,$nick,32)
; Add this nick to the list of nicks split from this channel
inc %i
}
}
}
alias netsplit_show {
var %i = 1
while $hfind(netsplit, $+($replace($1-,$chr(32),@),@*), %i, w) {
echo -c info $gettok($ifmatch,-1,64) * Following nicks lost in netsplit: $&
$replace($hget(netsplit,$ifmatch), $chr(32),$+($chr(44),$chr(32)))
; For each entry in 'netsplit' matching for the split between servers $1 and $2 echo the list of nicks that have split
inc %i
}
hdel -w netsplit $+($replace($1-,$chr(32),@),@*)
; Delete all trace of this netsplit
}