This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.
For more information, see this announcement post . Click the X in the top right-corner of this box to dismiss this message.
Help for those learning Tcl or writing their own scripts.
cleaner
Voice
Posts: 15 Joined: Mon Apr 13, 2009 6:35 pm
Post
by cleaner » Thu Apr 30, 2009 9:20 am
Hello,
Can anybody help me fix it ?
I don't know what is wrong with this...
I mean that good function "!xxx ccc" show 2 responses:
Code: Select all
15:14:45 <A> good
15:14:46 <A> bad
The: "!xxx ccc", as only to show: "good".
Code: Select all
bind pub -|- !xxx pub_do_ccc
proc pub_do_ccc {nick host handle channel text} {
if {[string match -nocase "ccc" [string trim $text]]} {
putserv "PRIVMSG $channel : good"
}elseif {[string match -nocase "ccc1" [string trim $text]]} {
putserv "PRIVMSG $channel : good1"
}elseif {[string match -nocase "ccc2" [string trim $text]]} {
putserv "PRIVMSG $channel : good2"
}
putserv "PRIVMSG $channel : bad"
}
tsukeh
Voice
Posts: 31 Joined: Thu Jan 20, 2005 6:22 am
Post
by tsukeh » Thu Apr 30, 2009 9:48 am
Code: Select all
bind pub -|- !xxx pub_do_ccc
proc pub_do_ccc {nick host handle channel text} {
set text [string trim $text]
if {[string match -nocase "ccc" $text]} {
putserv "PRIVMSG $channel : good"
} elseif {[string match -nocase "ccc1" $text]} {
putserv "PRIVMSG $channel : good1"
} elseif {[string match -nocase "ccc2" $text]} {
putserv "PRIVMSG $channel : good2"
} else {
putserv "PRIVMSG $channel : bad"
}
}
cleaner
Voice
Posts: 15 Joined: Mon Apr 13, 2009 6:35 pm
Post
by cleaner » Thu Apr 30, 2009 10:05 am
Thanks
speechles
Revered One
Posts: 1398 Joined: Sat Aug 26, 2006 10:19 pm
Location: emerald triangle, california (coastal redwoods)
Post
by speechles » Thu Apr 30, 2009 5:36 pm
Code: Select all
bind pub -|- !xxx pub_do_ccc
proc pub_do_ccc {nick host handle channel text} {
switch -- [string tolower [string trim $text]] {
"ccc" { putserv "PRIVMSG $channel :good" }
"ccc1" { putserv "PRIVMSG $channel :good1" }
"ccc2" { putserv "PRIVMSG $channel :good2" }
default { putserv "PRIVMSG $channel :bad" }
}
}
There are many ways to accomplish this, but the faster method is usually preferred. The command "switch" is probably faster than nesting if's and else's in this case.
cleaner
Voice
Posts: 15 Joined: Mon Apr 13, 2009 6:35 pm
Post
by cleaner » Fri May 01, 2009 11:15 am
Thanks, I think that I most rewrite some scripts hehe
.