|
Joined: Feb 2006
Posts: 307
Fjord artisan
|
OP
Fjord artisan
Joined: Feb 2006
Posts: 307 |
hello can you tell me please how to make these protect entries to expire (be deleted from the protect list) when I leave the channels or I quit mirc? I think I have to use /protect -r but I cant figure out how -r switch works thanks! on me:^&*:join:#: {
.timer 1 1 checkregs #
}
alias checkregs {
if (!$1) { return }
var %loop = 1, %regs = $nick($1,0,a,r)
while (%loop <= %regs) {
protect $nick($1,%loop,a,r) 2
inc %loop
}
}
|
|
|
|
Joined: Aug 2004
Posts: 7,252
Hoopy frood
|
Hoopy frood
Joined: Aug 2004
Posts: 7,252 |
The -r switch will remove the specified nick/address from the protection list. Using the -r switch without any parameters removes all entries. The format of the /protect command is the same whether adding or removing nick/address. With the exception of needing the -r switch, of course.
|
|
|
|
Joined: Jan 2007
Posts: 1,156
Hoopy frood
|
Hoopy frood
Joined: Jan 2007
Posts: 1,156 |
Sorry if Im stating the obvious, but you would want to put that in a part, quit & exit event. Probably a disconnect event as well.
|
|
|
|
Joined: Jun 2006
Posts: 508
Fjord artisan
|
Fjord artisan
Joined: Jun 2006
Posts: 508 |
Removing the channel from the channels user is protected on will remove them from the list unless there is another channel remaining. So loop through the protect list and remove the channel you just parted. When you part a channel... on me:*:part:#:{
var %i = 1
while $protect(%i) {
if $istok($protect(%i).type,#,44) { protect -r $protect(%i) # }
else inc %i
}
} When you quit, you can use the disconnect event to to loop through all open channels, and remove the matches. on *:disconnect:{
var %i = x
while $chan(%x) {
var %i = 1,%c = $v1
while $protect(%i) {
if $istok($protect(%i).type,%c,44) { protect -r $protect(%i) %c }
else inc %i
}
inc %x
}
} I think you'd be better off using raw 366 (End of names list) to populate your protects. (At the time you join a #, mIRC doesn't yet know if any other users are in the room, that info only comes from the names list, which is also where mIRC learns who (if anyone) is opped/voiced/etc. raw 366:*:checkregs $2
alias checkregs {
var %i = 1
while $nick($$1,%i,$prefix) {
protect $v1 $1 2
inc %i
}
}
|
|
|
|
Joined: Feb 2006
Posts: 307
Fjord artisan
|
OP
Fjord artisan
Joined: Feb 2006
Posts: 307 |
thank you very much
but I dont understand the first two scripts
they will remove ALL my protects or the protects that have been added with the script of the first topic?
and the last script doesnt need on join?
thanks
|
|
|
|
Joined: Jun 2006
Posts: 508
Fjord artisan
|
Fjord artisan
Joined: Jun 2006
Posts: 508 |
First of all, I see a mistake in the disconnect script, the line " var %i = x" should read " var %x = 1" You should correct that line before using it. Sorry! I dont understand the first two scripts they will remove ALL my protects or the protects that have been added with the script of the first topic? The 1st (me:*:part:#) script will remove ALL protects for the channel you are parting. The 2nd (disconnect) script will remove ALL protects from ANY channels you're on when you disconnect. the last script doesnt need on join? That's right, the 3rd script above is to replace your me:*:join event because Raw 366 ("End of /NAMES list")is the earliest mIRC can know the userlist for a channel. No need for a timer guesstimating when the names list is filled. I added the #channel to the paramaters though, assuming you had wanted those users protected.If that's not what you want, just try and explain more.
|
|
|
|
Joined: Feb 2006
Posts: 307
Fjord artisan
|
OP
Fjord artisan
Joined: Feb 2006
Posts: 307 |
The 1st (me:*:part:#) script will remove ALL protects for the channel you are parting. The 2nd (disconnect) script will remove ALL protects from ANY channels you're on when you disconnect.
I dont need ALL protects to be removed, I only need the protects that have been added with the first script I posted to be removed, EITHER when leaving a channel OR when closing mirc That's right, the 3rd script above is to replace your me:*:join event because Raw 366 ("End of /NAMES list")is the earliest mIRC can know the userlist for a channel. No need for a timer guesstimating when the names list is filled. I added the #channel to the paramaters though, assuming you had wanted those users protected.the raw is better than the timer? I mean the script with the timer may fail due to slow internet speed, where the userlist may not load before the timer ends the raw will never fail to get the userlist completely? what I want to do is mentioned in the first post with the script: I want to /protect the non-regular users' ip/hosts when I join any channel I wouldnt like this protect to work for specific channels, but it would be ok to work for the specific network the ip/host should be added regardless channel and network PS: I am not familiar with the raw script you posted, can I just replace the 'on me:^&*:join:#:' with 'raw 366:*:' in the first script I posted? thanks!
Last edited by nataliad; 08/05/07 12:37 AM.
|
|
|
|
Joined: Feb 2006
Posts: 307
Fjord artisan
|
OP
Fjord artisan
Joined: Feb 2006
Posts: 307 |
|
|
|
|
Joined: Jun 2006
Posts: 508
Fjord artisan
|
Fjord artisan
Joined: Jun 2006
Posts: 508 |
OK that complicates things a little, to protect a user by hostmark, they must be in the IAL. "/who #" will ensure that the IAL is filled. To remove them from protect list, you need to identify the entries added this way. A hash table could track these auto-added entries. This code should work but is untested
; 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
}
|
|
|
|
Joined: Feb 2006
Posts: 307
Fjord artisan
|
OP
Fjord artisan
Joined: Feb 2006
Posts: 307 |
thanks
but with the first script, I dont need IAL to include the ip/hosts of the nicks I want to protect
I just want to add the remove-after-leaving-or-closing feature...
|
|
|
|
|