egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

multi cmdchars

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests
View previous topic :: View next topic  
Author Message
edu
Voice


Joined: 29 Oct 2006
Posts: 31

PostPosted: Fri Jun 20, 2008 8:11 pm    Post subject: multi cmdchars Reply with quote

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
View user's profile Send private message
strikelight
Owner


Joined: 07 Oct 2002
Posts: 708

PostPosted: Fri Jun 20, 2008 8:22 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
edu
Voice


Joined: 29 Oct 2006
Posts: 31

PostPosted: Sat Jun 21, 2008 4:25 am    Post subject: Reply with quote

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 Smile
_________________
Seek the truth
Back to top
View user's profile Send private message
strikelight
Owner


Joined: 07 Oct 2002
Posts: 708

PostPosted: Sat Jun 21, 2008 10:14 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
edu
Voice


Joined: 29 Oct 2006
Posts: 31

PostPosted: Sat Jun 21, 2008 1:21 pm    Post subject: Reply with quote

you dont get it -- I'll make it with only one cmdchar

Thanks anyway
_________________
Seek the truth
Back to top
View user's profile Send private message
Nor7on
Op


Joined: 03 Mar 2007
Posts: 185
Location: Spain - Barcelona

PostPosted: Sat Jun 21, 2008 2:27 pm    Post subject: Reply with quote

Code:
bind pub -|- !say pub:say
bind pub -|- .say pub:say
bind pub -|- `say pub:say
Back to top
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger
strikelight
Owner


Joined: 07 Oct 2002
Posts: 708

PostPosted: Sat Jun 21, 2008 2:58 pm    Post subject: Reply with quote

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.
Rolling Eyes
Back to top
View user's profile Send private message Visit poster's website
edu
Voice


Joined: 29 Oct 2006
Posts: 31

PostPosted: Sat Jun 21, 2008 3:23 pm    Post subject: Reply with quote

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
View user's profile Send private message
strikelight
Owner


Joined: 07 Oct 2002
Posts: 708

PostPosted: Sat Jun 21, 2008 3:28 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber