| View previous topic :: View next topic |
| Author |
Message |
Conc Voice
Joined: 31 Oct 2009 Posts: 6
|
Posted: Sat Oct 31, 2009 4:48 pm Post subject: Bracket Conflict |
|
|
I made a "say" script.
it works so:
botnick say text
Part of code:
| Code: |
putserv "PRIVMSG $c :[lrange $t 1 end]"
|
but this has a problem, look at this:
| Quote: | <Conc> Egg say [Hi]
<Egg> {[Hi]} |
Why does it says {} when i type a bracket? |
|
| Back to top |
|
 |
nml375 Revered One
Joined: 04 Aug 2006 Posts: 2857
|
Posted: Sat Oct 31, 2009 4:52 pm Post subject: |
|
|
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, idling at #eggdrop@IrcNET |
|
| Back to top |
|
 |
Conc Voice
Joined: 31 Oct 2009 Posts: 6
|
Posted: Sat Oct 31, 2009 5:00 pm Post subject: |
|
|
$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? |
|
| Back to top |
|
 |
nml375 Revered One
Joined: 04 Aug 2006 Posts: 2857
|
Posted: Sat Oct 31, 2009 5:02 pm Post subject: |
|
|
I suppose you'd like something like this...
| Code: | bind pub - "egg" someproc
proc someproc {nick host handle channel text} {
puthelp "PRIVMSG $channel :[join [lrange [split $text] 1 end]]"
} |
_________________ NML_375, idling at #eggdrop@IrcNET |
|
| Back to top |
|
 |
Conc Voice
Joined: 31 Oct 2009 Posts: 6
|
Posted: Sat Oct 31, 2009 5:10 pm Post subject: |
|
|
It works fine.
Thanks  |
|
| Back to top |
|
 |
blake Master
Joined: 23 Feb 2009 Posts: 201
|
Posted: Fri Dec 04, 2009 10:04 am Post subject: |
|
|
I also get this problem but i use
| Code: | 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: | 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 _________________ Blake
UKEasyHosting UKStormWatch |
|
| Back to top |
|
 |
Sir_Fz Revered One

Joined: 27 Apr 2003 Posts: 3793 Location: Lebanon
|
Posted: Fri Dec 04, 2009 10:54 am Post subject: |
|
|
| Code: | | set text [join [lrange [split $arg] 1 end] |
should be
| Code: | | set text [join [lrange [split $arg] 1 end]] |
You should also consider adding ":" before the privmsg text (i.e. "privmsg botserv :act ..."). _________________ Follow me on GitHub
- Opposing
Public Tcl scripts |
|
| Back to top |
|
 |
blake Master
Joined: 23 Feb 2009 Posts: 201
|
Posted: Fri Dec 04, 2009 12:05 pm Post subject: |
|
|
Cool thanks sir_fz also changed act to :act _________________ Blake
UKEasyHosting UKStormWatch |
|
| Back to top |
|
 |
|