This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

chattr |+v on detect /mode $chan +v $nick

Old posts that have not been replied to for several years.
Locked
User avatar
stere0
Halfop
Posts: 47
Joined: Sun Sep 23, 2001 8:00 pm
Location: Brazil

Post by stere0 »

bind mode - * flag

proc flag {nick host handle channel change victim} {
if {([string match "*[string tolower +v]*" [string tolower $change]])} {
if {[validuser $victim]} { chattr $victim |+v $channel }
return
}
if {([string match "*[string tolower -v]*" [string tolower $change]])} {
if {[validuser $victim]} { chattr $victim |-v $channel }
return
}
}


Hi all,
I wrote this code to give voice to user if detected ´mode +v´ in the channel, but it is with problem when trying to take off flag. The procedure is being called two times, one to take off flag and other to place again, somebody knows to say me why? Perhaps some of you could improve my code.
[]s
P
Petersen
Owner
Posts: 685
Joined: Thu Sep 27, 2001 8:00 pm
Location: Blackpool, UK

Post by Petersen »

why its being called twice I cannot say, but $victim is a nick, not a handle, so running handle based commands on it (validuser and chattr) is kinda pointless. Use nick2hand to get a handle.
User avatar
stere0
Halfop
Posts: 47
Joined: Sun Sep 23, 2001 8:00 pm
Location: Brazil

Post by stere0 »

ok, I made the changes.
Ahh, and I discovered why it calls the proc twice when removing the voice of an user with the flag. It is because of some internal routine of eggdrop, that autovoice the user thus that it loses the voice, ignoring if he has the flag or not. To resolve the problem, I used a verification to know who calls the proc, if $nick == $botnick, so do nothing.
[]s
g
guppy
eggdrop engineer
Posts: 199
Joined: Mon Sep 24, 2001 8:00 pm
Location: Canada
Contact:

Post by guppy »

you don't need to string tolower +v .. its already lowercase, also +V and +v are not the same on IRC .. you don't want to change $change to lowercase.

bind mode - "% +v" mode:plusvoice
bind mode - "% -v" mode:minusvoice

is what I prefer to use .. that way I have two seperate procs and its all nice and tidy.

oops, one other things ..
if {$change == "+v"} { or if {$change == "-v"} { would work fine .. no sense wasting CPU using string match.

Jeff

<font size=-1>[ This Message was edited by: guppy on 2002-06-06 09:50 ]</font>
Locked