; Send /who # when you join. The var and group are to catch and halt the replies display
on me:*:join:#:inc -e $+(%,mejoin.who.,#) | who # | .enable #mejoin.who
; Catch the /who replies
#mejoin.who off
raw 315:*:{
; Check for the var set on joining
if $($+(%,mejoin.who.,$2),2) {
; Unset the var
unset $+(%,mejoin.who.,$2)
; This is a check to see if all joined chans have been processed
if !$var(%mejoin.who.*,1) {
; disable this group
.disable #mejoin.who
; and save the hash table data to file
hsave protects protects.hsh
}
; add protects for this channel
do.protects $2
; halt the display of this raw
halt
}
}
; Halt this display of raw 352
raw 352:*:if $($+(%,onjoin.who.,$2),2) { halt }
#mejoin.who end
alias do.protects {
var %i = 1
; loop non-regular nicks
while $nick($1,%i,$prefix) {
var %a = $v1
; check if they are protected on this network
if $protect(%b).network == $network {
; skip if they are
inc %i | continue
}
; add to a hash table
hadd -m protects %a $network
; protect them
.protect %a $network
inc %i
}
}
; A disconnect event to remove the nicks from protect list for this network
on *:disconnect:{
; find all items from this network
while $hfind(protects,$network,1).data {
; remove from protect list
.protect -r $v1 $network
; remove from hash table
hdel protects $v1
}
; save the data after entries are deleted
hsave protects protects.hsh
}
; A start event to create the hash table, and purge any possible leftovers from previous session
on *:start:{
; Create the hash table
hmake 1 protects
; If hash table data file exists, load it
if $file(protects.hsh) { hload protects protects.hsh }
; purge the entries it contains (if any)
var %i = 1
while $hget(protects,%i).item {
; if any entries are left from last session, remove them from protect list
.protect -r $v1 $hget(protects,%i).item
; delete all entries from hash table
.hdel -w protects *
}
inc %i
; clear data file (or create blank new one).
write -d protects.hsh
}