I have an IRC bot working on twisted. I want him to reload itself (disconnect, reopen his main .py file with all changes made while he was running and start again) through external input
The if statement would be something like:
if user in admin:
msg = "Restarting"
SendMsg(self, channel, msg)
A script reloading itself would not make sense. Where would the execution resume? The only possibility is to restart from the beginning, which would be the same as killing and starting the process again.
What you can do is put as much code as you can in a different module (but not the main loop) and call that module from the main script.
And, when the main script sees the
.reload command, reload the module.