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.
Conc
Voice
Posts: 6 Joined: Sat Oct 31, 2009 4:38 pm
Post
by Conc » Sat Oct 31, 2009 4:48 pm
I made a "say" script.
it works so:
botnick say
text
Part of code:
Code: Select all
putserv "PRIVMSG $c :[lrange $t 1 end]"
but this has a problem, look at this:
<Conc> Egg say [Hi]
<Egg> {[Hi]}
Why does it says {} when i type a bracket?
nml375
Revered One
Posts: 2860 Joined: Fri Aug 04, 2006 2:09 pm
Post
by nml375 » Sat Oct 31, 2009 4:52 pm
Because lrange operates on lists (not strings), and returns a list (not a string).
At minimum, you should use join to merge the list into a single string.
Also, if $t is simply the text you wrote to trigger the binding, then you must also use split to convert it into a list before using lrange.
NML_375
Conc
Voice
Posts: 6 Joined: Sat Oct 31, 2009 4:38 pm
Post
by Conc » Sat Oct 31, 2009 5:00 pm
$t isnt just the text to send... it has also the word "say".
Well... i am not very good with tcl, can you do it for me?
nml375
Revered One
Posts: 2860 Joined: Fri Aug 04, 2006 2:09 pm
Post
by nml375 » Sat Oct 31, 2009 5:02 pm
I suppose you'd like something like this...
Code: Select all
bind pub - "egg" someproc
proc someproc {nick host handle channel text} {
puthelp "PRIVMSG $channel :[join [lrange [split $text] 1 end]]"
}
NML_375
Conc
Voice
Posts: 6 Joined: Sat Oct 31, 2009 4:38 pm
Post
by Conc » Sat Oct 31, 2009 5:10 pm
It works fine.
Thanks
blake
Master
Posts: 201 Joined: Mon Feb 23, 2009 9:42 am
Contact:
Post
by blake » Fri Dec 04, 2009 10:04 am
I also get this problem but i use
Code: Select all
bind msg ho|ho act cmd:act
proc cmd:act {nick uhost hand arg} {
set chan [lindex [split $arg] 0]
set text [lrange [split $arg] 1 end]
putserv "PRIVMSG botserv act $chan $text (Issued By $nick"
}
tried adding it like this
Code: Select all
bind msg ho|ho act cmd:act
proc cmd:act {nick uhost hand arg} {
set chan [lindex [split $arg] 0]
set text [join [lrange [split $arg] 1 end]
putserv "PRIVMSG botserv act $chan $text (Issued By $nick"
}
but get error on partyline Tcl error [cmd:act]: missing close-bracket
Sir_Fz
Revered One
Posts: 3794 Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:
Post
by Sir_Fz » Fri Dec 04, 2009 10:54 am
Code: Select all
set text [join [lrange [split $arg] 1 end]
should be
Code: Select all
set text [join [lrange [split $arg] 1 end]]
You should also consider adding ":" before the privmsg text (i.e. "privmsg botserv :act ...").
blake
Master
Posts: 201 Joined: Mon Feb 23, 2009 9:42 am
Contact:
Post
by blake » Fri Dec 04, 2009 12:05 pm
Cool thanks sir_fz also changed act to :act