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.

Simple little query - binds formatting

Old posts that have not been replied to for several years.
Locked
W
Weirdo
Master
Posts: 265
Joined: Sat Apr 27, 2002 8:00 pm
Location: Manchester, England

Simple little query - binds formatting

Post by Weirdo »

Code: Select all

bind dcc n testchan dcc:testchan
proc dcc:testchan {hand idx nick} {
So i have a normal bind, use this format for most of my commands on my bot. but i have a feeling i havent done it right. for example.

doing

.testc

on partyline activates the script, which i dont want. Is there a simple bit of formatting of the bind which will make the need of the whole command to be typed in order to be executed.

Thanks

Weirdo
User avatar
strikelight
Owner
Posts: 708
Joined: Mon Oct 07, 2002 10:39 am
Contact:

Re: Simple little query - binds formatting

Post by strikelight »

Eggdrop auto-completes text for dcc commands to find the nearest matching command... (ie. if you do .bott , it will show you the output for .bottree). There isn't much you can do about this, other than possibly
making additional binds for all possible incomplete commands, which isn't really efficient. If I were you, I wouldn't worry about it, it's not a big deal, it is actually more useful than hurtful.

Mod:

After thinking about it, there is another possibility...
Using a "filt" binding, and checking there...

Something like...

Code: Select all

bind filt - ".te*" testcheck
proc testcheck {idx text} {
  set key [string tolower [lindex [split $text] 0]]
  if {$key == ".testchan"} { return $text }
  return ""
}
Of course, this too can have side effects, such as if you have other commands that start with ".te" .. you'd have to incorporate them into the
filt procedure as well.
Weirdo wrote:

Code: Select all

bind dcc n testchan dcc:testchan
proc dcc:testchan {hand idx nick} {
So i have a normal bind, use this format for most of my commands on my bot. but i have a feeling i havent done it right. for example.

doing

.testc

on partyline activates the script, which i dont want. Is there a simple bit of formatting of the bind which will make the need of the whole command to be typed in order to be executed.

Thanks

Weirdo
W
Weirdo
Master
Posts: 265
Joined: Sat Apr 27, 2002 8:00 pm
Location: Manchester, England

Post by Weirdo »

Right, so thats what it does. Thankies :)
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

This does have it's added advantages, however, you can disable this inside one proc, without haveing to use the filt proc.

There is a global variable called $lastbind, which you can use to see how the command was called.

This will allow a single procedure, to act for multiple commands. In any help information, you can use it, to output the command name used, rather than a fixed one.

See more information in tcl-commands.doc
User avatar
strikelight
Owner
Posts: 708
Joined: Mon Oct 07, 2002 10:39 am
Contact:

Post by strikelight »

ppslim wrote:This does have it's added advantages, however, you can disable this inside one proc, without haveing to use the filt proc.

There is a global variable called $lastbind, which you can use to see how the command was called.

This will allow a single procedure, to act for multiple commands. In any help information, you can use it, to output the command name used, rather than a fixed one.

See more information in tcl-commands.doc
Ofcourse, for this to work, you would still need multiple bindings, such as:

Code: Select all

bind dcc n te proc_to_call
bind dcc n tes proc_to_call
...
bind dcc n testcha proc_to_call
bind dcc n testchan proc_to_call
Otherwise, $lastbind would contain the value of the nearest-matched command of course. (ie. doing .testc [without the additional bindings in place] will set lastbind to "testchan")

This method itself alone is very inefficient as stated before,
not to mention that it too will have problems if there are other commands
that start with "te", etc.. which would have to be dealt with some how as well.. You may have 2 procedures using filt, but less lines taken by excessive bindings if you were to utilize $lastbind... Overall, you'd save time and space by filt'ing, if you really must worry about it at all.
User avatar
stdragon
Owner
Posts: 959
Joined: Sun Sep 23, 2001 8:00 pm
Contact:

Post by stdragon »

How about a combo approach?

Use a filt bind to store the actual command as typed by the user. Have it set a global variable "actual_command".

Then in your proc, look at the value of 'actual_command' and if it's not "testchan" then return without doing anything.

Code: Select all

bind filt - ".t*" testchan_filt
proc testchan_filt {idx text} {
  global actual_command
  set actual_command [lindex [split $text] 0]
  return $text
}
proc dcc n testchan testchan_dcc
proc testchan_dcc {hand idx text} {
  global actual_command
  if {[string compare -nocase $actual_command ".testchan"]} {return 0}
  ...
}
User avatar
strikelight
Owner
Posts: 708
Joined: Mon Oct 07, 2002 10:39 am
Contact:

Post by strikelight »

stdragon wrote:How about a combo approach?

Use a filt bind to store the actual command as typed by the user. Have it set a global variable "actual_command".

Then in your proc, look at the value of 'actual_command' and if it's not "testchan" then return without doing anything.

Code: Select all

bind filt - ".t*" testchan_filt
proc testchan_filt {idx text} {
  global actual_command
  set actual_command [lindex [split $text] 0]
  return $text
}
proc dcc n testchan testchan_dcc
proc testchan_dcc {hand idx text} {
  global actual_command
  if {[string compare -nocase $actual_command ".testchan"]} {return 0}
  ...
}
Yea, that'd work.. good solution!
W
Weirdo
Master
Posts: 265
Joined: Sat Apr 27, 2002 8:00 pm
Location: Manchester, England

Post by Weirdo »

It does work indeedy :)

So, why , whoever it was that added this particular feature/bug/whatever into the eggdrop core, was this implemented? What does it really achieve anyways?

stdragon's approach tends to work the fastest on the bot. Will have a go at using his :)
User avatar
strikelight
Owner
Posts: 708
Joined: Mon Oct 07, 2002 10:39 am
Contact:

Post by strikelight »

Weirdo wrote: So, why , whoever it was that added this particular feature/bug/whatever into the eggdrop core, was this implemented? What does it really achieve anyways?
As already mentioned, it can be useful.. Much like scripts built for irc clients that do auto-nick completion when you only type part of someone's nick... It can save you time (albeit not much) and energy from having
to type the entire command out.
W
Weirdo
Master
Posts: 265
Joined: Sat Apr 27, 2002 8:00 pm
Location: Manchester, England

Post by Weirdo »

Well mirc has the lazy bastard feel to a lot of its commands. I could understand it might save a little time, would have thought the easiest way of saving time would have been making the syntax shorter or whatnot.

Meh, at least i know what its doing. Time to make lots of totally different commands to confuse this autocompleter :)
Locked