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.

Trouble with args, *PROB SOLVED*

Help for those learning Tcl or writing their own scripts.
Post Reply
User avatar
Vexor
Voice
Posts: 18
Joined: Fri Jul 21, 2006 4:22 am
Location: Washington Court House
Contact:

Trouble with args, *PROB SOLVED*

Post by Vexor »

Greetings all,

I'm creating a small user's help guide for my bot so people can know all channel commands for the bot. This works to some degree. If I type in "!help google" I get the small help text that explains how to use it. But if I just use "!help" I get no response at all. It's probably just a total brain fart but I can't put my finger on it.

Code: Select all

proc send:help {nick uhost hand chan args} {

        #Bring in the default list
        global helplist

        if { $args != "" } {
                put:help $args $nick
        } else {
                putserv "privmsg $nick :Current general commands include: $helplist"
                putserv "privmsg $nick :For more information on a topic use \"!help topic\" (such as !help google)"
        }
}
put:help is what calls if args is not blank, (ie, the "!help google", which works) What's not working is the else statement block. :?

Any suggestions?
Last edited by Vexor on Tue Jul 25, 2006 5:40 am, edited 2 times in total.
Z
Zero
Voice
Posts: 4
Joined: Tue Jul 25, 2006 4:17 am

Post by Zero »

Try this:

Code: Select all

proc send:help {nick uhost hand chan args} {

        #Bring in the default list
        global helplist

        if { [llength $args] > 0 } {
                put:help $args $nick
        } else {
                putserv "privmsg $nick :Current general commands include: $helplist"
                putserv "privmsg $nick :For more information on a topic use \"!help topic\" (such as !help google)"
        }
} 
Maybe llength $args works...
User avatar
krimson
Halfop
Posts: 86
Joined: Wed Apr 19, 2006 8:12 am

Post by krimson »

you should use

Code: Select all

proc send:help {nick uhost hand chan {args ""}}
User avatar
Vexor
Voice
Posts: 18
Joined: Fri Jul 21, 2006 4:22 am
Location: Washington Court House
Contact:

Post by Vexor »

Code: Select all

proc send:help {nick uhost hand chan {args ""}}
Just isn't working :?

I'm at a total loss. [llength $args] didn't work either.

*UPDATE* I said the hell with it and just rewrote the code. Thanks for your suggestions, and sorry for the trouble. *mutters to himself*
User avatar
rosc2112
Revered One
Posts: 1454
Joined: Sun Feb 19, 2006 8:36 pm
Location: Northeast Pennsylvania

Post by rosc2112 »

Code: Select all

bind - pub !help myproc
proc myproc {nick uhost hand chan text} {
     set cmd [lindex [split $text] 0]
     if {$cmd == "google"} {
              puthelp "PRIVMSG $nick :Google help line 1"
              puthelp "PRIVMSG $nick :Google help line 2 etc."
              return  
     }
     if {$cmd == "something"} {
              # more stuff here
              return
     }
     if {$cmd == ""} {
              # Whatever you want..
              # could also just use the next "else" part after any "if", for default help..
               return
     } else {
              # default help stuff here...
              return
     }
}
Post Reply