bind msg - .say msg_say
proc msg_say {nick uhost hand args} {
global botnick
if {[llength [lindex $args 0]]<2} {
putserv "NOTICE $nick :/msg $botnick .say #chan_name <text>"
} else {
set chan [lindex [lindex $args 0] 0]
if { ![validchan $chan]} {
putserv "NOTICE $nick :\"$chan\": invalid chan."
return 0
}
## FIX ME this condition is never reached
if { ![onchan $botnick $chan] } {
putserv "NOTICE $nick :je ne suis pas sur le chan \"$chan\"."
return 0
}
## END FIX ME
# comment this next 4 lines if you want to be able to talk in a chan you're not in
if { ![onchan $nick $chan] } {
putserv "NOTICE $nick :tu n'es pas sur le chan \"$chan\"."
return 0
}
set msg [lrange [lindex $args 0] 1 end]
}
proc massslap {nick uhost hand chan text args} {
# dump only 25 nicks per line
set chanList [chanlist $chan]
while {[llength $chanList] != 0} {
puthelp "PRIVMSG $chan :[join [lrange $chanList 0 25]]"
set chanList [lrange $chanList 25 end]
}
}
putchan $chan $msg
}
if {[llength [lindex $args 0]]<2} {
# becomes to the eggdrop every single time
if {1 < 2 } {
Here is your problem. "[llength [lindex $args 0]]" will always be 1. It has no choice but to be because of how you've used it in your procedure declaration.
Stop using "[lindex $args 0]" all over the place. Everywhere you have that change it to "[split $arg]".
Also, change this part:
proc msg_say {nick uhost hand args} {
to this:
proc msg_say {nick uhost hand arg} {
There are more errors than this in your script concerning list to string errors. But I will let you figure those out. Only in certain conditions with certain characters should you notice the bugs.
http://www.peterre.info/characters.html wrote:A point worthy of note about args
Putting args as the last argument of a Tcl procedure allows the use of a variable number of input arguments. But there is a potential source of confusion if the procedure is one that is called by an eggdrop bind command.
In a script that I downloaded I saw code similar to the following:
The author was no doubt thinking that if a user typed
.m2f aaa bbb ccc
then the value of args would be a list of three elements, aaa, bbb and ccc, and that therefore the value of [llength $args] would be 3.
In fact, the value of args would be a list of one element, that element being the string aaa bbb ccc. Whatever string the user types, the value of [llength $args] will always be 1.
Similarly, the value of [lindex $args 0] will not be the string aaa, but the string aaa bbb ccc.
The eggdrop pub and msg binds behave in the same way.
The above properties of eggdrop's bind command have been confirmed by testing with eggdrop version 1.6.6.