| View previous topic :: View next topic |
| Author |
Message |
edu Voice
Joined: 29 Oct 2006 Posts: 31
|
Posted: Fri Jun 20, 2008 8:11 pm Post subject: multi cmdchars |
|
|
| Code: |
set cmdchar ". ! `"
proc cmd { } {
global cmdchar
foreach cmd_char $cmdchar {
return $cmd_char
}
}
bind pub -|- [cmd]say pub:say
proc pub:say {nickname hostname handle channel text} {
global cmd
set text [split $text]
if {$text == ""} {
putquick "NOTICE $nickname :syntax: [cmd]say <text>"
return
}
putquick "PRIVMSG $channel :$text"
}
|
how can I make this script to work when I type .say <text> / !say <text> or `say <text> -- and if no "text" is specified to return .say <text> / !say <text> or `say <text>
Thank you, please help me. _________________ Seek the truth |
|
| Back to top |
|
 |
strikelight Owner

Joined: 07 Oct 2002 Posts: 708
|
Posted: Fri Jun 20, 2008 8:22 pm Post subject: |
|
|
I think more of what you are after is this:
| Code: |
set cmdchars ".!`"
foreach cmdchar [split $cmdchars ""] {
bind pub - ${cmdchar}say pub:say
}
|
and then your proc... |
|
| Back to top |
|
 |
edu Voice
Joined: 29 Oct 2006 Posts: 31
|
Posted: Sat Jun 21, 2008 4:25 am Post subject: |
|
|
I dont need it this way..
I need to make the [cmd] proc to use it, like:
proc -|- [cmd]say say_proc
proc -|- [cmd]die die_proc
etc..
and then into the "code" if $text isn't specified to do: putquick "notice $nickname :[cmd]say <text>"
pls help me  _________________ Seek the truth |
|
| Back to top |
|
 |
strikelight Owner

Joined: 07 Oct 2002 Posts: 708
|
Posted: Sat Jun 21, 2008 10:14 am Post subject: |
|
|
You can't do what you are trying to do that way. What []'s do is evaluate a command immediately. For example:
| Code: |
proc test {} {
return "moo boo who"
}
bind pub - "[test]unf" proc:unf
|
This will cause the pub event to be bound to "moo boo who".
ie. To trigger the proc, you would have to say in a channel:
<user> moo boo whounf
NOT "moounf" or "boounf" or "whounf"
You will need to create multiple bindings as I just provided you the code for, or you will need to bind a pubm to * and check inside the proc itself. |
|
| Back to top |
|
 |
edu Voice
Joined: 29 Oct 2006 Posts: 31
|
Posted: Sat Jun 21, 2008 1:21 pm Post subject: |
|
|
you dont get it -- I'll make it with only one cmdchar
Thanks anyway _________________ Seek the truth |
|
| Back to top |
|
 |
Nor7on Op

Joined: 03 Mar 2007 Posts: 185 Location: Spain - Barcelona
|
Posted: Sat Jun 21, 2008 2:27 pm Post subject: |
|
|
| Code: | bind pub -|- !say pub:say
bind pub -|- .say pub:say
bind pub -|- `say pub:say |
|
|
| Back to top |
|
 |
strikelight Owner

Joined: 07 Oct 2002 Posts: 708
|
Posted: Sat Jun 21, 2008 2:58 pm Post subject: |
|
|
| Nor7on wrote: | | Code: | bind pub -|- !say pub:say
bind pub -|- .say pub:say
bind pub -|- `say pub:say |
|
That's what my code above did. He doesn't want that apparently.
 |
|
| Back to top |
|
 |
edu Voice
Joined: 29 Oct 2006 Posts: 31
|
Posted: Sat Jun 21, 2008 3:23 pm Post subject: |
|
|
so, let me explain it again.. more clearly.. (I hope)
I want to make this script that has a lot of binds, and I want to use more cmdchars, for this reason I want to make this proc [cmd] and set more binds, like:
| Code: |
bind pub -|- [cmd]say proc_say
bind pub -|- [cmd]die proc_die
|
and so on..
I dont want to set 3 times the same thing..
help me if you can, thank you & for your time. _________________ Seek the truth |
|
| Back to top |
|
 |
strikelight Owner

Joined: 07 Oct 2002 Posts: 708
|
Posted: Sat Jun 21, 2008 3:28 pm Post subject: |
|
|
As I told you, you can't do it like that.
You will either have to set multiple binds, or create a pubm bind to match against * and parse the text inside the proc. Both have their benefits and fallbacks. Multiple binds means, well, multiple bindings (which isn't a bad thing unless you create a million binds, so I don't know why you wouldn't want this). A pubm bound procedure would have to process all text in a channel, which isn't too efficient.
So again... I repeat to you the solution I posted above, commented:
| Code: |
# Set below the characters you wish to use prior to your command
# ie: 1) !command 2) .command 3)`command
set cmdchars ".!`"
# now we will set up the bindings based on that information provided above, you don't need to edit this part
foreach cmdchar [split $cmdchars ""] {
bind pub - ${cmdchar}say pub:say
}
#done
|
This does exactly what you ask, despite how many times you say it isn't what you are asking. |
|
| Back to top |
|
 |
|