Code: Select all
bind pub o|f .kick cmd:kick
proc cmd:kick {nick host hand chan text} {
putkick "$chan :$text"
puthelp "Privmsg $nick :Kicked $text from $chan"
}
Code: Select all
bind pub o|f .kick cmd:kick
proc cmd:kick {nick host hand chan text} {
putkick "$chan :$text"
puthelp "Privmsg $nick :Kicked $text from $chan"
}
Code: Select all
putkick $chan $target $reason
Code: Select all
proc cmd:kick {nick host hand chan text} {
Code: Select all
proc cmd:kick {nick host hand chan args} {
Code: Select all
set args [join $args]
set target [lindex $args 0]
set reason [lrange $args 1 end]
Code: Select all
bind pub o|f .kick cmd:kick
proc cmd:kick {nick host hand chan args} {
set args [join $args]
set target [lindex $args 0]
set reason [lrange $args 1 end]
putkick "$chan [lindex $arg 1] [lrange $arg 2 end] ($nick)"
puthelp "Privmsg $nick :Kicked [lindex $arg 1] from $chan"
}
Do you have the slightest idea what you're doing? First you use a special argument name (args - read about it here: http://tcl.tk/man/tcl8.4/TclCmd/proc.htm) that's not needed for this kind of task (a predefined number of arguments), then you join the list created by it, so you're left with the string that was passed to the proc, and THEN you start using list commands on that string. (not a good idea)Dw2k wrote:Code: Select all
set args [join $args] set target [lindex $args 0] set reason [lrange $args 1 end]
No..you didn't listen to what Dw2k said about putkick (the only thing he got right) Try something like this (lots of extra bloat added, sorry):kazoo wrote:Is this what I should have?Code: Select all
...
Code: Select all
bind pub o|f .kick cmd:kick
proc cmd:kick {nick uhost hand chan arg} {
# extract the first word and the remaining ones (if any)
# into separate vars and store the return value from 'scan'
set i [scan $arg "%s %\[^\n\]" victim reason]
# if scan returned something > 0 we know there's a victim...
if {$i>0} {
# checking to see if there's someone by that nick present...
if {[onchan $victim $chan]} {
# did the scan find a reason or do we have to provide a default value?
if {$i!=2} {
set reason "$nick doesn't seem to like you."
}
putkick $chan $victim $reason
} else {
puthelp "NOTICE $nick :$victim is not on $chan"
}
} else {
# no arguments were provided, so we tell the stupid user
# how it should be done ;)
puthelp "NOTICE $nick :Syntax: $::lastbind nick ?reason?"
}
}
As noted in my previous post to arcane in another thread, if we were speaking of plain old vanilla TCL, you would be right about him using args improperly... However because of the way bind calls procedures, it produces a list of lists in this scenario... so join'ing the list of lists produces a single list..... But Again, I don't agree with using this method any more than you do....user wrote:Do you have the slightest idea what you're doing? First you use a special argument name (args - read about it here: http://tcl.tk/man/tcl8.4/TclCmd/proc.htm) that's not needed for this kind of task (a predefined number of arguments), then you join the list created by it, so you're left with the string that was passed to the proc, and THEN you start using list commands on that string. (not a good idea)Dw2k wrote:Code: Select all
set args [join $args] set target [lindex $args 0] set reason [lrange $args 1 end]
How about NOT doing all that?
Since when does eggdrop do that? And what exactly do you mean? It's passed to the proc as a string in my 1.6.13 test bot.strikelight wrote:As noted in my previous post to arcane in another thread, if we were speaking of plain old vanilla TCL, you would be right about him using args improperly... However because of the way bind calls procedures, it produces a list of lists in this scenario... so join'ing the list of lists produces a single list.....
[13:20] (@user) % bind pub n !doit doit; proc doit {n u h c args} {putserv "PRIVMSG $c :[join $args]"}
[13:21] (@user) !doit { [
[13:21] (@sh) { [