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