mIRC Home    About    Download    Register    News    Help

Print Thread
expire #176127 04/05/07 12:46 AM
Joined: Feb 2006
Posts: 307
N
nataliad Offline OP
Fjord artisan
OP Offline
Fjord artisan
N
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!

Code:
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
  }
}

Re: expire [Re: nataliad] #176130 04/05/07 01:19 AM
Joined: Aug 2004
Posts: 7,252
R
RusselB Offline
Hoopy frood
Offline
Hoopy frood
R
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.

Re: expire [Re: nataliad] #176132 04/05/07 03:13 AM
Joined: Jan 2007
Posts: 1,156
D
DJ_Sol Offline
Hoopy frood
Offline
Hoopy frood
D
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. smile

Re: expire [Re: nataliad] #176134 04/05/07 05:23 AM
Joined: Jun 2006
Posts: 508
D
deegee Offline
Fjord artisan
Offline
Fjord artisan
D
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...
Code:
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.
Code:
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.
Code:
raw 366:*:checkregs $2
alias checkregs {
  var %i = 1
  while $nick($$1,%i,$prefix) {
    protect $v1 $1 2
    inc %i
  }
}

Re: expire [Re: deegee] #176192 05/05/07 12:55 PM
Joined: Feb 2006
Posts: 307
N
nataliad Offline OP
Fjord artisan
OP Offline
Fjord artisan
N
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

Re: expire [Re: nataliad] #176202 05/05/07 06:02 PM
Joined: Jun 2006
Posts: 508
D
deegee Offline
Fjord artisan
Offline
Fjord artisan
D
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" shocked You should correct that line before using it. Sorry!

Quote:
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.


Quote:
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. smile
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. smile

Re: expire [Re: deegee] #176309 08/05/07 12:30 AM
Joined: Feb 2006
Posts: 307
N
nataliad Offline OP
Fjord artisan
OP Offline
Fjord artisan
N
Joined: Feb 2006
Posts: 307
Originally Posted By: deegee

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

Originally Posted By: deegee

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. smile
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.
Re: expire [Re: nataliad] #176585 11/05/07 10:14 PM
Joined: Feb 2006
Posts: 307
N
nataliad Offline OP
Fjord artisan
OP Offline
Fjord artisan
N
Joined: Feb 2006
Posts: 307
any help please

Re: expire [Re: nataliad] #176777 14/05/07 02:20 AM
Joined: Jun 2006
Posts: 508
D
deegee Offline
Fjord artisan
Offline
Fjord artisan
D
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 wink
Code:
;  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
}


Re: expire [Re: deegee] #176884 15/05/07 09:11 PM
Joined: Feb 2006
Posts: 307
N
nataliad Offline OP
Fjord artisan
OP Offline
Fjord artisan
N
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...