mIRC Home    About    Download    Register    News    Help

Print Thread
Page 1 of 2 1 2
#184419 28/08/07 06:26 PM
Joined: Jul 2006
Posts: 248
B
bwuser Offline OP
Fjord artisan
OP Offline
Fjord artisan
B
Joined: Jul 2006
Posts: 248
hello

this script adds ops mask/ip/domain in the protect list in every channel I join

I want these entries to work only when I am in this channel, so how do I make those entries expire when I close mirc? or any other way?

Code:
on me:^&*:join:#: {
  .timer 1 3 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
  }
}


thanks !

bwuser #184421 28/08/07 07:56 PM
Joined: Jan 2006
Posts: 111
N
Vogon poet
Offline
Vogon poet
N
Joined: Jan 2006
Posts: 111
Try this:
Quote:

ON *:DISCONNECT: {
protect -r
}

noMen #184423 28/08/07 09:05 PM
Joined: Jul 2006
Posts: 248
B
bwuser Offline OP
Fjord artisan
OP Offline
Fjord artisan
B
Joined: Jul 2006
Posts: 248
there are more protect entries than the ones added with the above script and there are more added during mirc session

I want to remove the specific entries, not all

bwuser #184429 28/08/07 11:07 PM
Joined: Nov 2006
Posts: 1,559
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
Not a beauty, this code... A hash table instead of the variables and a smarter remove routine would prettify it a lot smile
I tested only a bit, hope it's all working.
Code:
menu channel {
  Temp Protection
  .$iif(($group(#autoprotection) == on),$style(1)) switch $qt(auto add/-remove) $iif(($group(#autoprotection) == on),off,on): $iif(($group(#autoprotection) == on),.disable,.enable) #autoprotection
  .-
  .temp-protect the nonreg users of $qt($active) now : add.protect $network $active
  .clear temp-protects of $qt($active) : rem.protect $network $active
  .clear temp-protects of $qt($network) : rem.protect $network net
  .clear all temp-protects : rem.protect
}

; group of events (menu switch)

#autoprotection on
; add temp protections if joining a chan
on me:*:join:#: { add.protect $network $chan }

; remove temp protections on kick/part/quit/disconnect/exit
on *:kick:#: { if ($knick == $me) rem.protect $network $chan }
on me:*:part:#: { rem.protect $network $chan }
on me:*:quit: { rem.protect $network net }
on *:disconnect: { rem.protect $network net }
on *:exit: { rem.protect }
#autoprotection end

; alias: add the nonreg users of a chan to temp protection 
alias add.protect {
  if ($me ison $2) {
    ; ial for that chan is up to date:
    if ($chan($2).ial) { 
      var %nr = 1
      ; loop all "regular" users
      while ($nick($2,%nr,a,r)) {
        !protect $v1 $2 2 $1
        ; set a variable for this protect entry/switch
        set $+(%,tempprotect+,$1,+,$2,+,$address($v1,2))
        inc %nr
      }
    }
    ; ial is not up to date: update ial, and try again
    else {
      .who $2
      .timer 1 10 add.protect $network $2
    }
  }
}

; alias: remove the protection of users added before
alias rem.protect {
  ; loop all variables
  var %nr = 1

  ; remove all temp entries of a chan
  if ($2 != net) {
    var %net = $1, %chan = $2
    while $var($+(%,tempprotect+,%net,+,%chan,+*),%nr) {
      tokenize 43 $v1
      !protect -r $4 $3 $2
      inc %nr
    }
    ; unset the variables for that chan
    unset $+(%,tempprotect+, [ %net ] ,+, [ %chan ] ,+*)
  }

  ; remove all temp entries of a network
  elseif ($2 == net) {
    var %net = $1
    while $var($+(%,tempprotect+,%net,+*),%nr) {
      tokenize 43 $v1
      !protect -r $4 $3 $2
      inc %nr
    }
    ; unset the variables for that net
    unset $+(%,tempprotect+, [ %net ] ,+*)
  }

  ; remove all temp entries
  else {
    while ($var(%tempprotect+*),%nr) {
      tokenize 43 $v1
      !protect -r $4 $3 $2
      inc %nr
    }
    ; unset all variables
    unset %tempprotect+*
  }

}

2 Notes:

1) The individual protect commands are not silenced yet (for you to check how it works). You can disable this output with ease: change the four occurrences of "!protect" to ".protect".

2) Atm, this will not add/remove protection on op/deop and the like, nor will it remove the protection entries of parting/quitting users.

Last edited by Horstl; 28/08/07 11:26 PM.
Horstl #184540 30/08/07 05:23 AM
Joined: Jul 2006
Posts: 248
B
bwuser Offline OP
Fjord artisan
OP Offline
Fjord artisan
B
Joined: Jul 2006
Posts: 248
thanks!
Originally Posted By: Horstl

2) Atm, this will not add/remove protection on op/deop and the like, nor will it remove the protection entries of parting/quitting users.


but that would be essential..

you mean it wont add to protect a person that gets op after I join the channel?

and it wont remove the protect when an op quits or leaves the channel?

I wish it could do these...

bwuser #184579 30/08/07 12:51 PM
Joined: Nov 2006
Posts: 1,559
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
Originally Posted By: bwuser
but that would be essential..
I did not know exactly in what circumstances you wanted to protect smile

This code will add protection on +o/+h/+v, and remove that protection on part/quit of that user - if the "auto" switch was turned on in menu.
In addition, now you can add/remove temp protection for single users via menu.

Code:
; ---------- menu ----------

menu channel,nicklist {
  $iif((!$protect),$style(2)) Temp Protection $iif((!$protect),[disabled])
  ; toggle auto add/remove 
  .$iif(($group(#autoprotection) == on),$style(1)) switch $qt(auto add/-remove) $iif(($group(#autoprotection) == on),OFF,ON) : {
    $iif(($group(#autoprotection) == on),.disable,.enable) #autoprotection
  }
  .-
  ; add/remove single users
  .$iif(($check.protect($$1,$active,$network)),$style(1) REMOVE,ADD) protection for user $qt($$1) on $qt($active) : {
    $iif(($check.protect($$1,$active,$network)),rem.single.protect,add.single.protect) $network $active $$1
  }
  .-
  ; add/remove all nonreg users of a chan
  .ADD temp-protecs for nonreg users of $qt($active) : add.protect $network $active
  .REMOVE temp-protects of $qt($active) : rem.protect $network $active
  .-
  ; remove all network entries
  .CLEAR temp-protects of network $qt($network) : rem.protect $network net
  ; remove all entries
  .CLEAR ALL temp-protects : rem.protect
}

; ---------- events ----------

; group (switch): automated protection events
#autoprotection off
; add temp protections if you're joining a chan
on me:*:join:#: { add.protect $network $chan }

; add temp protection if v/h/o is granted
on *:op:#: { add.single.protect $network $chan $opnick }
on *:help:#: { add.single.protect $network $chan $hnick }
on *:voice:#: { add.single.protect $network $chan $vnick }

; remove temp protections on kick/part/quit/disconnect/exit (you)
on *:kick:#: { if ($knick == $me) rem.protect $network $chan }
on me:*:part:#: { rem.protect $network $chan }
on me:*:quit: { rem.protect $network net }
on *:disconnect: { rem.protect $network net }
on *:exit: { rem.protect }

;remove temp protections on part/quit (protected users)
on !*:part:#: { rem.single.protect $network $chan $nick }
on !*:quit: { rem.single.protect $network * $nick }
#autoprotection end

; ---------- aliases ----------

; return whether or not a user is protected on that chan and network
; note: checking protections, not vars for tempprotections!
alias -l check.protect {
  var %nr = 1, %address = $address($1,2)
  while ($protect(%nr)) {
    if (($v1 == %address) && ($istok($protect(%nr).type,$2,44)) && ($protect(%nr).network == $3)) { return %nr }
    inc %nr
  }
}

; add a temp protection
alias -l add.single.protect {
  !protect $3 $2 2 $1
  set $+(%,tempprotect+,$1,+,$2,+,$address($3,2))
}

; add all nonreg users of a chan to temp protection 
alias -l add.protect {
  if ($me ison $2) {
    ; ial for that chan is up to date:
    if ($chan($2).ial) { 
      var %nr = 1
      ; loop all "regular" users
      while ($nick($2,%nr,a,r)) {
        !protect $v1 $2 2 $1
        ; set a variable for this protect entry/switch
        set $+(%,tempprotect+,$1,+,$2,+,$address($v1,2))
        inc %nr
      }
    }
    ; ial is not up to date: update ial, and try again
    else {
      .who $2
      .timer 1 10 add.protect $network $2
    }
  }
}

; remove a temp protection
alias -l rem.single.protect {
  if ($var($+(%,tempprotect+,$1,+,$2,+,$address($3,2)),1)) { 
    tokenize 43 $v1
    !protect -r $4 $3 $2
    unset  $v1
  }
  else { echo -c info $2 The protection for $3 on $2 $+([,$1,]) was not added temporarily  - remove it manually. }
}

; remove protections of users added before
alias -l rem.protect {
  ; loop all variables
  var %nr = 1

  ; remove all temp protections of a chan
  if ($2 != net) {
    var %net = $1, %chan = $2
    while ($var($+(%,tempprotect+,%net,+,%chan,+*),%nr)) {
      tokenize 43 $v1
      !protect -r $4 $3 $2
      inc %nr
    }
    ; unset the variables for that chan
    unset $+(%,tempprotect+, [ %net ] ,+, [ %chan ] ,+*)
  }

  ; remove all temp protections of a network
  elseif ($2 == net) {
    var %net = $1
    while ($var($+(%,tempprotect+,%net,+*),%nr)) {
      tokenize 43 $v1
      !protect -r $4 $3 $2
      inc %nr
    }
    ; unset the variables for that net
    unset $+(%,tempprotect+, [ %net ] ,+*)
  }

  ; remove all temp protections 
  else {
    while ($var(%tempprotect+*),%nr) {
      tokenize 43 $v1
      !protect -r $4 $3 $2
      inc %nr
    }
    ; unset all variables
    unset %tempprotect+*
  }
}
; ---------- end ----------


Horstl #184616 30/08/07 09:52 PM
Joined: Jul 2006
Posts: 248
B
bwuser Offline OP
Fjord artisan
OP Offline
Fjord artisan
B
Joined: Jul 2006
Posts: 248
mm thanks

sorry, I dont want to remove the protect of an op when he leaves or quits

I want to remove them when I leave or quit

and I want to protect people that get +o/+h/+v and to remove them when I quit or leave

thanks

can you tell me please how the full script should be

bwuser #184623 30/08/07 11:40 PM
Joined: Nov 2006
Posts: 1,559
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
If you don't want to un-protect the (host of) users who had been op/hop/voice if they part/quit, remove these lines:

Code:
;remove temp protections on part/quit (protected users)
on !*:part:#: { rem.single.protect $network $chan $nick }
on !*:quit: { rem.single.protect $network * $nick }

...keep the rest smile

Horstl #184641 31/08/07 07:57 AM
Joined: Feb 2006
Posts: 307
N
Fjord artisan
Offline
Fjord artisan
N
Joined: Feb 2006
Posts: 307
thanks

but, excuse me, do I just paste all the above code in my remote and I am done? its very big code!

nataliad #184718 31/08/07 07:45 PM
Joined: Nov 2006
Posts: 1,559
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
Paste the "last" big code block to a new remote file, and remove the three lines mentioned later (these lines would remove temp protect of parting/quitting users). Then save this file, and you should be done. smile

You can enable/disable the whole "auto temp protect" via popup menu (right-click in a channel window). There you'll see other options too - I added them as I thought they might be useful.

The code is that big as some "loop routines" are required; I also added a couple of comments to the code; and I use comments like "; ---- aliases ----" to sort scripts optically if they reach a certrain length - this might have confused you.

If you encounter other problems with this temp protect script, feel free to ask smile

Horstl #184753 01/09/07 08:01 AM
Joined: Feb 2006
Posts: 307
N
Fjord artisan
Offline
Fjord artisan
N
Joined: Feb 2006
Posts: 307
mm thanks but I wouldnt like a menu to add (on me join and on user op) and remove (on me leave or quit) protects of nonregs in channels, since I want to do it automaticaly, would that save some space?

something else, when I 'enable' it I get many of these in my status:

* The protection for XXX on * [DALNet] was not added temporarily - remove it manually.

but nothing is added! and ofcourse these are not ops when I join or get op when I am in the channel

last, I hope the protects are added at the bottom of the list...

thanks

Last edited by nataliad; 01/09/07 08:29 AM.
nataliad #184782 01/09/07 03:00 PM
Joined: Nov 2006
Posts: 1,559
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
Quote:
something else, when I 'enable' it I get many of these in my status:
* The protection for XXX on * [DALNet] was not added temporarily - remove it manually.
but nothing is added! and ofcourse these are not ops when I join or get op when I am in the channel
The only possible reason for this can be a mis-pasted code: this echo is produced by a single alias - which can only be called "once", via menu popups.

However, if you really don't need a menu switch (imho it's always a good idea to have a switch vor automated things wink ), use the code below. With the menu, it's functions, and all comments removed, you'll save a total of 2.6kb hard disc space. cool
Code:
on me:*:join:#: { add.protect $network $chan }
on *:op:#: { add.single.protect $network $chan $opnick }
on *:help:#: { add.single.protect $network $chan $hnick }
on *:voice:#: { add.single.protect $network $chan $vnick }

on *:kick:#: { if ($knick == $me) rem.protect $network $chan }
on me:*:part:#: { rem.protect $network $chan }
on me:*:quit: { rem.protect $network net }
on *:disconnect: { rem.protect $network net }
on *:exit: { rem.protect }

alias -l add.single.protect {
  !protect $3 $2 2 $1
  set $+(%,tempprotect+,$1,+,$2,+,$address($3,2))
}

alias -l add.protect {
  if ($me ison $2) {
    if ($chan($2).ial) { 
      var %nr = 1
      while ($nick($2,%nr,a,r)) {
        !protect $v1 $2 2 $1
        set $+(%,tempprotect+,$1,+,$2,+,$address($v1,2))
        inc %nr
      }
    }
    else {
      .who $2
      .timer 1 10 add.protect $network $2
    }
  }
}

alias -l rem.protect {
  var %nr = 1
  if (!$2) {
    while ($var(%tempprotect+*,%nr)) {
      echo -s tokenize 43 $v1
      echo -s !protect -r $4 $3 $2
      inc %nr
    }
    unset %tempprotect+*
  }
  elseif ($2 == net) {
    var %net = $1
    while ($var($+(%,tempprotect+,%net,+*),%nr)) {
      tokenize 43 $v1
      !protect -r $4 $3 $2
      inc %nr
    }
    unset $+(%,tempprotect+, [ %net ] ,+*)
  }
  else {
    var %net = $1, %chan = $2
    while ($var($+(%,tempprotect+,%net,+,%chan,+*),%nr)) {
      tokenize 43 $v1
      !protect -r $4 $3 $2
      inc %nr
    }
    unset $+(%,tempprotect+, [ %net ] ,+, [ %chan ] ,+*)
  }
}

Quote:
last, I hope the protects are added at the bottom of the list...
mIRC sorts the list automatically (think e.g. of adding/changing/removing only parameters of a protection). You cannot assign a list position manually.


bwuser #184785 01/09/07 03:04 PM
Joined: Nov 2006
Posts: 1,559
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
I did an error in the code above: use the "big" code block and remove the three lines as mentioned. But replace the "alias -l rem.protect" with the one I posted in my reply to nataliad. Sorry for this lapse. You also can send me a PM if you have problems with doing so. Regards.
(...being a bit uncertain if I'm responding to two users ore one crazy)

Horstl #185048 04/09/07 05:43 AM
Joined: Feb 2006
Posts: 307
N
Fjord artisan
Offline
Fjord artisan
N
Joined: Feb 2006
Posts: 307
thanks very much for your script

can you tell me please the correct code?

as for the sorting of lists, mirc doesn't autosort the protect/ignore list, it adds new entries at the bottom and it sorts them only if you click the sort button

so this way, if I know the last entry I can check whether new entries have been added and if those have been removed succesfuly by the script

nataliad #185074 04/09/07 07:13 PM
Joined: Nov 2006
Posts: 1,559
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
Originally Posted By: nataliad
can you tell me please the correct code?
...try the one I pasted in response to your last reply.

Originally Posted By: nataliad
as for the sorting of lists, mirc doesn't autosort the protect/ignore list, it adds new entries at the bottom and it sorts them only if you click the sort button
so this way, if I know the last entry I can check whether new entries have been added and if those have been removed succesfuly by the script
...not if you add "other" protections in the meantime, or change switches for existing protections (you might have run across e.g. the message "* Updated protect channels for xy" already). Thus, there's no guarantee for the temp protections of this scripts to be located at the bottom of the list.

Horstl #185116 05/09/07 04:59 AM
Joined: Feb 2006
Posts: 307
N
Fjord artisan
Offline
Fjord artisan
N
Joined: Feb 2006
Posts: 307
1)you said to remove the three lines, are they removed now? you updated the code?

2) what you mean "other" protections?

3) ok, if the protection already exists, it wont be added in the bottom, it will stay where it is, but in this situation, I wont have an unwanted protect entry! (this is the main concern)

4) also can you make the script to work only for people in #channel1 and #channel2 in every server?

thank you very much!

nataliad #185148 05/09/07 07:54 PM
Joined: Nov 2006
Posts: 1,559
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
Originally Posted By: nataliad
1)you said to remove the three lines, are they removed now? you updated the code?
That's why i pasted the code again in post #184782.

Originally Posted By: nataliad
2) what you mean "other" protections?
All protections that had not been added by this temp-script.

Originally Posted By: nataliad
4) also can you make the script to work only for people in #channel1 and #channel2 in every server?
Add the channel names to all event definitions that contain a # char: join, op, help, voice, kick, part.
Change e.g.:
Code:
on *:op:#:
to
Code:
on *:op:#channel1,#channel2:


Horstl #185193 06/09/07 08:49 AM
Joined: Feb 2006
Posts: 307
N
Fjord artisan
Offline
Fjord artisan
N
Joined: Feb 2006
Posts: 307
thanks

can you tell me please when I part ANY of #channel1,#channel2 it will remove ALL temp protect entries (from the ops of ALL channels)?

if this happens, then I would like to remove the temp entries only when I quit/disconnect/close mirc and not when I get kicked or I part a channel

also I get this in my status:
Code:
tokenize 43 %tempprotect+#channel1+op1+
!protect -r




Last edited by nataliad; 06/09/07 08:52 AM.
nataliad #185264 07/09/07 08:31 AM
Joined: Feb 2006
Posts: 307
N
Fjord artisan
Offline
Fjord artisan
N
Joined: Feb 2006
Posts: 307
also I get these lines in the status:

#Hellas somenick H x@83.73.77.52 :0 x

does the script /who all the channel??? I dont think the first script I pasted does this, it only whoises the ops...

nataliad #185275 07/09/07 01:37 PM
Joined: Nov 2006
Posts: 1,559
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
Originally Posted By: nataliad
can you tell me please when I part ANY of #channel1,#channel2 it will remove ALL temp protect entries (from the ops of ALL channels)?

change:
Code:
on me:*:part:#chan1,#chan2: { rem.protect $network $chan }
to
Code:
on me:*:part:#chan1,#chan2: { rem.protect $network net }


Originally Posted By: nataliad
if this happens, then I would like to remove the temp entries only when I quit/disconnect/close mirc and not when I get kicked or I part a channel
hum? This is i contradictory to the request above and, anyway, why keep protections for a channel you are not on? If you rejoin that channel, the temp protections will be added again.

Originally Posted By: nataliad
also I get this in my status:
Code:
tokenize 43 %tempprotect+#channel1+op1+
!protect -r
You might have mis-pasted the code, I see no other reason for this happening.

Originally Posted By: nataliad
also I get these lines in the status:
#Hellas somenick H x@83.73.77.52 :0 x
does the script /who all the channel??? I dont think the first script I pasted does this, it only whoises the ops...
The script did always do a /who if not all the users of that chan are in your internal address list (which is most likely... whistle).

Why?

- If you join a (specified) chan, you want to protect all nonreg users by host (mask type 2).

- mIRC is able to look up the hosts of these users if needed (not a mask but a mask type is specified), e.g. /protect nick #chan 2 network
Quoting "/help /protect":
Quote:
If you specify a type then the users address is looked up via the server.
...But the script request was about temp protection. As long as there is no "remove on exit" switch for the /protect command, a scripted sollution has to remember (store) which of the protections are temp protections - thus has to store distinct data about that. I used variables like %tempprotect+<network>+<channel>+<host> . The "host" part is the crucial point: it's looked up via internal address list.
Thus, a /who #channel is mandatory in most cases - /who-ing a chan is faster than /whois-ing ops only; you cannot who ops only.

Page 1 of 2 1 2

Link Copied to Clipboard