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.

How to get a script to reload itself in eggdrop?

Help for those learning Tcl or writing their own scripts.
Post Reply
s
sparc317
Voice
Posts: 11
Joined: Wed Jan 23, 2008 9:34 am

How to get a script to reload itself in eggdrop?

Post by sparc317 »

Hiya,

I have a script that monitors a TCP connection and dumps it to a channel, all working great.

However I would like to have a handler so that when the connection drops, it sleeps for a minute and then reloads the TCL script.

Is there a way to do this, as at present I just call a shell script that restarts the bot but it would be much nicer if I can just reload the specific script that is running.

Thanks!
User avatar
De Kus
Revered One
Posts: 1361
Joined: Sun Dec 15, 2002 11:41 am
Location: Germany

Post by De Kus »

You should have made the effort to look into that "partyline" stuff. You can do great things with it.
Best solution would however be to contact the writer of the script to reinitialize itself using a timer after the connection dropped. If you are unable to do that, you might want to search for "loadtcl" on these forums.
De Kus
StarZ|De_Kus, De_Kus or DeKus on IRC
Copyright © 2005-2009 by De Kus - published under The MIT License
Love hurts, love strengthens...
s
sparc317
Voice
Posts: 11
Joined: Wed Jan 23, 2008 9:34 am

Post by sparc317 »

I am the writer of the script :)

My question is how to get just the script to reinitialize itself.

I have rejigged my script to do the following when the connection drops:

Code: Select all

sleep 120
restart
This is fine but it causes the entire eggdrop to reload (bot leaves and rejoins channel etc.)

I might try this instead:

Code: Select all

sleep 120
unloadmodule nameofmymod
loadmodule nameofmymod
Haven't tried the above yet but I guessed it wouldn't hit the loadmodule as it unloads itself.

Was wondering really if there was a command to "reload current module" as doesn't seem to be anything like this in tcl-commands.doc

Thanks
m
metroid
Owner
Posts: 771
Joined: Wed Jun 16, 2004 2:46 am

Post by metroid »

Is it a mod or a script?
Your information seems to be conflicting.

Furthermore, we can't help you if you don't post the script.
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

if the unloadmod and loadmod commands are placed within a proc, there should be no problem using that code. Keep in mind however, that these commands only work with modules, not scripts.

Also, if the proc is created and registered by the module, care would have to be made not to unregister it upon unloading the module.
NML_375
s
sparc317
Voice
Posts: 11
Joined: Wed Jan 23, 2008 9:34 am

Post by sparc317 »

Hey,

Cheers for the replies.

Sorry I was being a bit dumb (long day) its a script I wrote so load/unload mod will be pointless.

I've achieved what I need now using the following though:

Code: Select all

"onDisc" { 
     sleep 120
     exec "/bin/kill -HUP `cat /usr/home/xxx/eggdrop/pid.xxxx`"
}
Noticed that sending the eggdrop SIGHUP causes it to stay connected to the network and in the channel but rehash and reload its TCL scripts.
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

Could just use the rehash tcl command then, has the exact same behaviour.
NML_375
m
metroid
Owner
Posts: 771
Joined: Wed Jun 16, 2004 2:46 am

Post by metroid »

sparc317 wrote:Hey,

Cheers for the replies.

Sorry I was being a bit dumb (long day) its a script I wrote so load/unload mod will be pointless.

I've achieved what I need now using the following though:

Code: Select all

"onDisc" { 
     sleep 120
     exec "/bin/kill -HUP `cat /usr/home/xxx/eggdrop/pid.xxxx`"
}
Noticed that sending the eggdrop SIGHUP causes it to stay connected to the network and in the channel but rehash and reload its TCL scripts.
I'm guessing that your script executes something the moment it is loaded.
Why don't you just place that code in a proc and simply execute that proc on startup and execute it again when the bot is disconnected?

You seem to be to be overdoing it.
"The best solution is often the most simple one"
s
sparc317
Voice
Posts: 11
Joined: Wed Jan 23, 2008 9:34 am

Post by sparc317 »

Heh Metroid,

Its not when the bot disconnects which I'm looking to handle, its when the TCP connection my script monitors disconnects.

Seems to be working how I want though, thank god these forums exist so many helpful people on here :)
Post Reply