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.

catching binds

Old posts that have not been replied to for several years.
Locked
f
freakyy

catching binds

Post by freakyy »

Hi all. I was wondering if it is possible (without patching eggdrop)
to have the last bind used stored in a variable.
I'd need not only the lastbind variable, but also the parameters the proc,
which the bind triggered, got triggered with. (n uh h c text f.e.)

So, if f.e. the bot wants to voice someone, and gets the RAW-error that it
doesn't have op in 'channel', it ops itself via chanserv or some other
network channel-service, and triggers the last bind (which is probably
responsible for the RAW-error) again.

Thanks for helping ;DD

~freaky :)
User avatar
GodOfSuicide
Master
Posts: 463
Joined: Mon Jun 17, 2002 8:00 pm
Location: Austria

Post by GodOfSuicide »

way a) you would have to add it manual to each proc

Code: Select all

proc myproc { arg1 arg2 arg3 } {
global lastproc
set lastproc "myproc $arg1 $arg2 $arg3"
....
}
proc repeat_last { } {
eval [$::lastproc]
}
way b) include this:

Code: Select all

proc opme { nick hand uhost chan text } {
if {![isop $::botnick $chan]} { <the cmd to op your bot via chanserv> ; utimer 5 "opme $nick $hand $uhost $chan $text" ; return 0 } else {
<the stuff to op the user>
}
}
not tested, but it should work (at least with some small adjustments)
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

Code: Select all

proc record_stack {} {
  lappend ::_stack [info level -1]
}
This will help record a stack of previous binds.

You will have to call record_stack at the begining of each bind, so that recording takes place.

You will also have to take care of cleaning the stack, so it doesn't grow too large. Presently, it will grow forever.

The stack is a list stored in the global variable $_stack. It is recorded in a fasion of last oldest item at the start, newest at the end.
f
freakyy

Post by freakyy »

ppslim wrote: The stack is a list stored in the global variable $_stack. It is recorded in a fasion of last oldest item at the start, newest at the end.
thx :D I will play with this tonight. ;) (i'm from germany (GMT+1)) ;o)

but, ppslim, where did you learn that? :o)
and, what is "info level -1" for? (o:

and, that means I have to add record_stack to all procs I want to have
recorded?
well, is there a way to have this beeing done automatically? so, if
someone loads the script, it records all procs executed, no matter in
which script, without having to add record_stack to every proc which might
cause a "channel :you don't have operator rights" error?

thx for help ;DD
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

I got this and more from the Tcl manual (search for "tcl/tk man" on google, and hit "Am I feeling lucky")

There probably is a way. You following would need some major adaption, but could work

Code: Select all

if {![info exists _bindgone]} {
  set _bindgone 1
  rename bind _bind

proc bind {args} {
  set cmd [lindex $args [expr [llength $args] - 1]]
  set body "record_stack; "
  if {[string range [info body $cmd] 0 [expr [string length $body] - 1]] != $body} {
    append body [info body $cmd]
    proc $cmd [info args $cmd] $body
  }
  eval _[info level 0]
}
}

proc record_stack {} { 
  lappend ::_stack [info level -1] 
}
That should be loaded as you first script (ie, just before all others).

It likely won't work or I have misunderstood somthign around the eval code, but the idea is sound.

It replaces the bind command with a custom version. When it is called, it makes sure that the new code includes the "record_stack" command (making sure it isn't duplicate).

It would have been easier to use the redo the proc command, however, that would mean every command is stacked, and not just binds.
f
freakyy

Post by freakyy »

hm, I don't even really understand what it is doing exactly. lol ...

I will look at the mans ;)

thx for your help ((:
Locked