|
Joined: Feb 2004
Posts: 714
Hoopy frood
|
OP
Hoopy frood
Joined: Feb 2004
Posts: 714 |
Hi there Let's say i have a code similar to this one: (syntax is /ctcp <nick> deop #chan <nick>)
ctcp 900:deop *:*: {
if ($ulevel < [color:red]$level($$3)[/color]) { .notice $nick You cannot deop users with higher access than yours. | halt }
.
.
rest of the command
.
.
} I have something similar that i'm trying to put into my bot. The $level($$3) isn't working, since it only searches in the userlist for the nick of the person, and not a matching mask. If there a way to make the script check the $$3's address and see if matches a user in the userlist? I tried with this: if ($ulevel > $level($address($$3,2))) { command } but, with this, it only looks the mask 2. All help is welcome Thank you, Zyzzy.
"All we are saying is give peace a chance" -- John Lennon
|
|
|
|
Joined: Aug 2003
Posts: 325
Fjord artisan
|
Fjord artisan
Joined: Aug 2003
Posts: 325 |
Try this: ctcp 900:deop *:*: {
.
.
rest of the command
.
.
}
ctcp *:deop *:*:.notice $nick You cannot deop users with higher access than yours. If they don't meet/exceed level 900 anyway, they won't get the first ctcp to activate. The 2nd one would tell them that they can't use that feature.
|
|
|
|
Joined: Apr 2004
Posts: 871
Hoopy frood
|
Hoopy frood
Joined: Apr 2004
Posts: 871 |
The easiest way to get someone's level, is to pass the person's full address to $level(). You can get someone's full address using $ial(nickname) or $address(nickname,5). For example, in your case: if ($ulevel < $level($ial($$3))) { ... }
Saturn, QuakeNet staff
|
|
|
|
Joined: Feb 2004
Posts: 714
Hoopy frood
|
OP
Hoopy frood
Joined: Feb 2004
Posts: 714 |
Hmm.. that wasnt quite was i was looking for.. In the bot i have levels, like 900 are Managers, 500 are Regular Ops, 1000 is the owner, 300 voices and so on.. I want something that prevents the person from deopping another user with lower or equal access they've got. For example, 600 can only deop 599 and lower; 900 only 899 and lower, and etc.
"All we are saying is give peace a chance" -- John Lennon
|
|
|
|
Joined: Aug 2003
Posts: 325
Fjord artisan
|
Fjord artisan
Joined: Aug 2003
Posts: 325 |
ctcp 300:deop *:*: {
if ( !$botrank($3) ) { .notice $nick $3 outranks you, you may not deop them. | return }
.
.
rest of the command
.
.
}
ctcp 2:deop *:*:.notice $nick You cannot deop users with higher access than yours.
alias botrank {
var %me = $replace($level($fulladdress),$chr(44),$chr(32))
var %victim = $replace($level($address($1,5)),$chr(44),$chr(32))
var %x = 0, %y = 0
while ( %me ) {
if ( %x < $gettok(%me,1,32) ) { %x == $gettok(%me,1,32) }
var %me == $deltok(%me,1,32)
}
while ( %victim ) {
if ( %y < $gettok(%victim,1,32) ) { %y == $gettok(%victim,1,32) }
var %victim == $deltok(%victim,1,32)
}
if ( %x >= %y ) { return $true }
return $false
} I haven't tested it, but that should work.
|
|
|
|
Joined: Feb 2004
Posts: 714
Hoopy frood
|
OP
Hoopy frood
Joined: Feb 2004
Posts: 714 |
Oh, it works great! I used $address(nickname,5) instead of the $ial because the IAL may not be updated, but ill always get the $address Thanks for the help you both! Zyzzy.
"All we are saying is give peace a chance" -- John Lennon
|
|
|
|
Joined: Jan 2003
Posts: 2,523
Hoopy frood
|
Hoopy frood
Joined: Jan 2003
Posts: 2,523 |
*deleted* (I was too late once more)
Last edited by qwerty; 27/04/04 11:56 PM.
/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com
|
|
|
|
Joined: Jan 2003
Posts: 2,523
Hoopy frood
|
Hoopy frood
Joined: Jan 2003
Posts: 2,523 |
No, $address() (NOT $address) relies on the IAL, so either both $address() and $ial() work or neither of them.
/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com
|
|
|
|
Joined: Aug 2003
Posts: 325
Fjord artisan
|
Fjord artisan
Joined: Aug 2003
Posts: 325 |
My understanding is that if $ial doesn't have it, then $address won't either. $ial(nickname) would actually be easier, I think, than $address(nickname,5) as I was using. And are you using the code I put up (if so is it working? Like I said it's untested). Reason for the extra botrank code is to consider those users with multiple levels.
|
|
|
|
Joined: Feb 2004
Posts: 714
Hoopy frood
|
OP
Hoopy frood
Joined: Feb 2004
Posts: 714 |
Oh, i see... so $address() and $ial() do the same thing btw, that script didnt work very well.. the client freezed
"All we are saying is give peace a chance" -- John Lennon
|
|
|
|
Joined: Aug 2003
Posts: 325
Fjord artisan
|
Fjord artisan
Joined: Aug 2003
Posts: 325 |
$address looks up the nick in the $ial, and then applies the $mask function to it. $mask($ial($nick),2) would return *!*@host for example. $address($nick,2) does the same thing but is easier. $ial($nick) and $address($nick,5) are the same thing and as for the script not working.. :-\ it should but like I said, I didn't test it so.. oh well.
|
|
|
|
Joined: Feb 2004
Posts: 714
Hoopy frood
|
OP
Hoopy frood
Joined: Feb 2004
Posts: 714 |
Oh, cool Didnt know those 2 were connected :P
"All we are saying is give peace a chance" -- John Lennon
|
|
|
|
Joined: Feb 2004
Posts: 714
Hoopy frood
|
OP
Hoopy frood
Joined: Feb 2004
Posts: 714 |
Btw.. does that work with IBL too? For example, if i have a script that goes:
alias unban {
mode $chan -b $address($$1,5)
} Would it look up in the IBL for a matching address of the nick? Thanks, Zyzzy.
"All we are saying is give peace a chance" -- John Lennon
|
|
|
|
Joined: Aug 2003
Posts: 325
Fjord artisan
|
Fjord artisan
Joined: Aug 2003
Posts: 325 |
In the matter of not being able to search the IBL, yes. if ( !$chan(#).ibl ) { echo -a # : Internal Ban List is empty! }
if ( !$chan(#).ial ) { echo -a # : Internal Address List is empty! } That's just a simple example of testing the IAL/IBL for a room. For your script, if you ever have problems flooding off, and wish to help reduce that risk (as an example, one unban is small scale, really)... alias unban {
if ( !$chan(#).ibl ) { mode # -b $ial($1) | return }
if ( $ial($$1) !isban ) { return }
var %x = $ibl(#,0), %b, %a = %ial($1)
while (%x) { if ($ibl(#,%x) iswm %a) { var %b = %b $ibl(#,%x) } | dec %x }
if ( %b ) { mode # $+(-,$str(b,$numtok(%b,32))) %b }
} More work than it's really worth in some ways, but if you go to unban someone, that *should* lift all the bans related to that person if the ibl is filled for that channel.
|
|
|
|
Joined: Feb 2004
Posts: 714
Hoopy frood
|
OP
Hoopy frood
Joined: Feb 2004
Posts: 714 |
I have a problem with this line: if ( $ial($$1) !isban ) { return } It tells me /if: invalid formatBut, if i take that line out of the script, it works perfect! Oh, btw.. i tested it on an empy channel. I joined, banned the nick with 3 different masks (like nick!*@* and *!*identd*@*) and, when i checked for the existance of IBLwith if ( !$chan(#).ibl ) { echo -a # : Internal Ban List is empty! }, it warned me it was empty, even if I was the one setting the bans! Thanks, Zyzzy.
"All we are saying is give peace a chance" -- John Lennon
|
|
|
|
Joined: Aug 2003
Posts: 325
Fjord artisan
|
Fjord artisan
Joined: Aug 2003
Posts: 325 |
I keep messing that up, sorry... alias unban {
if ( !$chan(#).ibl ) { mode # -b $ial($1) | return }
if ( $ial($$1) !isban # ) { return }
var %x = $ibl(#,0), %b, %a = %ial($1)
while (%x) { if ($ibl(#,%x) iswm %a) { var %b = %b $ibl(#,%x) } | dec %x }
if ( %b ) { mode # $+(-,$str(b,$numtok(%b,32))) %b }
} Try that.. I forgot the # in that line you had a problem with. The purpose of that line is to cut down on script usage. Why search the ibl if it's there are no matching bans?
|
|
|
|
Joined: Feb 2004
Posts: 714
Hoopy frood
|
OP
Hoopy frood
Joined: Feb 2004
Posts: 714 |
Works perfectly! Thanks for the help, i learnt quite a few tips with that script Grettings, Zyzzy.
"All we are saying is give peace a chance" -- John Lennon
|
|
|
|
|