egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Ban user

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help
View previous topic :: View next topic  
Author Message
GeeX
Voice


Joined: 19 Sep 2005
Posts: 29

PostPosted: Mon May 08, 2006 4:09 pm    Post subject: Ban user Reply with quote

Can you tell why it says: set protection(banuser) [lindex [split $arg] 0] ...": variable references require preceding $
when I use this proc?

Code:

        proc protection:ban { nick host hand chan arg } {
            global protection
            if {![channel get $chan protection(flag)]} {
                putserv "NOTICE $nick :Error. Protection is disabled. Enable it by typing $protection(trigger)protection on in order to use ban."
                return
            } elseif {$arg == ""} {
                putserv "NOTICE $nick :Error. Wrong syntax. Use $protection(trigger)ban 'nick' 'duration' 'reason'."
            } elseif {
                set protection(banuser) [lindex [split $arg] 0]
                set protection(banhost) "*![getchanhost $protection(banuser) $chan]"
                set protection(duration) [lindex [split $arg] 1]
                set protection(reason) [join [lrange [split $arg] 2 end]]
                if {![isnumber $protection(duration)]} {
                    set protection(reason) [join [lrange [split $arg] 1 end]]
                    set protection(duration) "60"
                }
                if {![onchan $protection(banuser) $chan] && ![string match "*!*" $protection(banuser)} {
                    set protection(banhost) "$protection(banuser)*!*@"
                    putquick "MODE $chan +b $protection(banhost)"
                    putserv "NOTICE $nick :Done. $protection(banhost) successfully added."
                }
                if {[string match "*!*" $protection(banuser)] && [matchattr [nick2hand $nick] n|n $chan]} {
                    set protection(banhost) "$protection(banuser)"
                    if {$protection(banhost) == "*!*@*"} {
                        return
                    } else {
                        putquick "mode $chan +b $protection(banhost)"
                        putserv "NOTICE $nick :Done. $protection(banhist) successfully added."
                    }
                }
                if {[isbot $protection(banuser)]} {
                    putserv "NOTICE $nick :Error. You cannot ban the bot."
                    return
                }
                if {[matchattr [nick2hand $nick] o|o $chan] && [matchattr [nick2hand $protection(banuser)] mn|mn $chan]} {
                    putserv "NOTICE $nick :Error. You cannot ban $protection(banuser) from $chan (higher access level)."
                    return
                }
                if {[matchattr [nick2hand $nick] m|m $chan] && [matchattr [nick2hand $protection(banuser)] n|n $chan]} {
                    putserv "NOTICE $nick :Error. You cannot ban $protection(banuser) from $chan (higher access level)."
                    return
                }
                if {[isdynamicip $protection(banhost)]} {
                    set protection(banhost) "[maskhost $protection(banhost)]"
                }
                set protection(id) [channel get $chan "$protection(kickid)"]
                incr protection(id)
                channel set $chan protection(kickid) "$protection(id)"
                regsub -all -- {:reason:} $protection(kickmsg) $protection(reason) protection(kickmsg)
                regsub -all -- {:id:}     $protection(kickmsg) $protection(id) protection(kickmsg)
                newchanban $chan $protection(banhost) $handle "$protection(kickmsg)" $protection(duration)
                putquick "KICK $chan $protection(banuser) :$protection(kickmsg)"
            }
        }
Back to top
View user's profile Send private message
Sir_Fz
Revered One


Joined: 27 Apr 2003
Posts: 3793
Location: Lebanon

PostPosted: Mon May 08, 2006 7:25 pm    Post subject: Reply with quote

Show us the info from .set errorInfo.
_________________
Follow me on GitHub

- Opposing

Public Tcl scripts
Back to top
View user's profile Send private message Visit poster's website
GeeX
Voice


Joined: 19 Sep 2005
Posts: 29

PostPosted: Tue May 09, 2006 8:04 am    Post subject: Reply with quote

Errorinfo:

Code:

result: syntax error in expression "
set protection(banuser) [lindex [split $arg...": variable references require preceding $ 
("if" test expression) 
while compiling
"if {![channel get $chan protection(flag)]} {
putserv "NOTICE $nick :Error. Protection is disabled. Enable it by typing $protection(tri..."
(compiling body of proc "protection:ban", line 3)
invoked from within 
"protection:ban $_pub1 $_pub2 $_pub3 $_pub4 $_pub5"
Back to top
View user's profile Send private message
Sir_Fz
Revered One


Joined: 27 Apr 2003
Posts: 3793
Location: Lebanon

PostPosted: Tue May 09, 2006 12:19 pm    Post subject: Reply with quote

Try changing
Code:
if {![channel get $chan protection(flag)]} {

to
Code:
if {![channel get $chan $protection(flag)]} {

_________________
Follow me on GitHub

- Opposing

Public Tcl scripts
Back to top
View user's profile Send private message Visit poster's website
GeeX
Voice


Joined: 19 Sep 2005
Posts: 29

PostPosted: Tue May 09, 2006 12:27 pm    Post subject: Reply with quote

Doens't work Sad
Back to top
View user's profile Send private message
De Kus
Revered One


Joined: 15 Dec 2002
Posts: 1361
Location: Germany

PostPosted: Tue May 09, 2006 12:32 pm    Post subject: Reply with quote

This is a really stupid mistake. It took me looking 3 times at it to find it. And I only found it, because I recognized that this error can only occur within if expressions and the I noticed something:
Code:
} elseif {

this is supposed to be just an "else", it tries to evaluate the whole body after elseif as an if expression. therefore the string "set" without an equalizer operator doesnt make any sense for if and returns an error for the whole line which starts with the first line.
_________________
De Kus
StarZ|De_Kus, De_Kus or DeKus on IRC
Copyright © 2005-2009 by De Kus - published under The MIT License
Love hurts, love strengthens...
Back to top
View user's profile Send private message MSN Messenger
GeeX
Voice


Joined: 19 Sep 2005
Posts: 29

PostPosted: Wed May 10, 2006 6:59 am    Post subject: Reply with quote

Thanks, i solved the problem Wink
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber