I prepared a small proof of concept for how code swapping could be handled in the next release of botzilla. When I say “swapping”, I really mean making changes to a module class file and reloading it, or simply loading a brand new file, without restarting the bot. load() and reload() methods would probably be added to the operator class.
The foundation is that your class name is essentially meaningless. So your class file is fetched and its constructor given a unique generated name, written to a temporary place, and included. Once instatiated, it takes the place of the current class in botzilla’s internal plugins array. The old class is still hanging around, but without instances. This would reset any internal data the instance had collected for itself.
This would not work particularly well for modules that contain more than one class file, so I recommend that you keep one class per file, and require_once them as needed (using explicit paths instead of relative ones).
I think I’ll get started for real after a smoke and another pot of coffee.
— UPDATE —
It was fairly easy to apply! Add this method to your operator class, and you’re all set!
Reload ( or load a few file) by calling it by its original class name.
.reload test
.reload alarm
ziggi - No Comments »