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.

catch die in tcl

Old posts that have not been replied to for several years.
Locked
c
cez
Voice
Posts: 10
Joined: Mon May 26, 2003 5:19 pm

catch die in tcl

Post by cez »

is there some bind i could do to run a process when catching a .die so that i can save some stuff which i dont want to do every time the value changes??
User avatar
Papillon
Owner
Posts: 724
Joined: Fri Feb 15, 2002 8:00 pm
Location: *.no

Post by Papillon »

check the bind evnt in tcl-commands.doc
Elen sila lúmenn' omentielvo
c
cez
Voice
Posts: 10
Joined: Mon May 26, 2003 5:19 pm

Post by cez »

hmm doesnt work it seems, tried like this and did a .die from telnet

Code: Select all

bind evnt -|- sighup quit
bind evnt -|- sigterm quit
bind evnt -|- sigill quit
bind evnt -|- rehash quit
bind evnt -|- prerehash quit
bind evnt -|- prerehash quit
bind evnt -|- prerestart quit

proc quit { type } {
   putlog "got event, $type"
}
User avatar
caesar
Mint Rubber
Posts: 3777
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

As far as I can see there is no such binding for what you've asked. You still can rebind the .die in another proc, save your stuff then complete the die. See the bind filt in the docs/tcl-commands.doc file.
Once the game is over, the king and the pawn go back in the same box.
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

This has the be the first and last Monday morning in existance that you or any1 will ever get some good stuff from me. No I didn't get some last night, though that would have set you up for a week of good stuff :P

Code: Select all

if {![info exists arewealive]} {
  catch {unbind dcc n die *dcc:die}
  bind dcc n die our:dcc:die
  rename die our:die
  proc die {rsn} {
    our:dcc:die $::botnick 0 $rsn
  }
}
set arewealive 1

proc our:dcc:die {hand idx arg} {
  set a 0
  set b 0
  foreach x [binds evnt] {
    if {![string equal -nocase [lindex $x 2] predie]} { continue }
    incr a
    incr [numberize [[lindex $x 4] $hand $arg]]
  }
  if {$a == $b} { die "($hand) $arg" }
}

proc numberize {n} {
  if {$n == ""} { return 0}
  if {$n == "0"} { return 0 }
  return 1
}
This is untested

You use it by using the EVNT bind, and saying you wish to trigger the "predie" event.

EG

Code: Select all

bind EVNT - predie my:event:proc
You code will be called with 2 arguments, the handle of the person doing this, or the nickname of the bot (when the Tcl die command is triggered), and the reason.

Your code should return 1 if you wish for the bot to exit normaly, and 0 if your wish to stall the exiting.

This will allow you to use some form of security script, to require a password to die, or to confirm the die.

Code: Select all

proc my:die:function {hand rsn} {
  if {![matchattr $hand Z]} { return 0 }
  if {([uptime] - $uptime) < 600} { return }
  return 1
}
bind EVNT - predie my:die:function
Do not die if the user does not have customer flag Z
Do not die if the bot has been online less than 10 mins.
Otherwise say that we are willing to let the bot die (note, other procedures you may not).
User avatar
caesar
Mint Rubber
Posts: 3777
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

So basicaly wich is wich? I failed to understand what you mean by the things you've said at the begining, oh well.. Some things are made not to be understood, just to be done/executed :)
Once the game is over, the king and the pawn go back in the same box.
Locked