| View previous topic :: View next topic |
| Author |
Message |
GeeX Voice
Joined: 19 Sep 2005 Posts: 29
|
Posted: Mon May 08, 2006 4:09 pm Post subject: Ban user |
|
|
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 |
|
 |
Sir_Fz Revered One

Joined: 27 Apr 2003 Posts: 3793 Location: Lebanon
|
|
| Back to top |
|
 |
GeeX Voice
Joined: 19 Sep 2005 Posts: 29
|
Posted: Tue May 09, 2006 8:04 am Post subject: |
|
|
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 |
|
 |
Sir_Fz Revered One

Joined: 27 Apr 2003 Posts: 3793 Location: Lebanon
|
Posted: Tue May 09, 2006 12:19 pm Post subject: |
|
|
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 |
|
 |
GeeX Voice
Joined: 19 Sep 2005 Posts: 29
|
Posted: Tue May 09, 2006 12:27 pm Post subject: |
|
|
Doens't work  |
|
| Back to top |
|
 |
De Kus Revered One

Joined: 15 Dec 2002 Posts: 1361 Location: Germany
|
Posted: Tue May 09, 2006 12:32 pm Post subject: |
|
|
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:
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 |
|
 |
GeeX Voice
Joined: 19 Sep 2005 Posts: 29
|
Posted: Wed May 10, 2006 6:59 am Post subject: |
|
|
Thanks, i solved the problem  |
|
| Back to top |
|
 |
|