Bot::Backbone::Bot - Provides backbone services to your bot
my $bot = My::Bot->new; $bot->run;
When you use Bot::Backbone in your code, you get a bot implementing this role. It provides tools for constructing, executing, and shutting down services.
Bots do all their work using an event loop. Usually, this is either POE or AnyEvent. Fortunately, these event loops tend to work well together in case you need both. Just in case you need specialized startup for your bot's event loop, though, this is attribute is provided to allow the event loop startup to be customized.
This is an object or class on which you may call a
run with no arguments. It will be called to start the event loop. By default, this is just "POE::Kernel". It is expected that this method will block until the bot is shutdown.
This is a set containing the names of all the services that have been constructed and initialized.
This method iterates through the service configurations of the meta class and constructs each service from that configuration.
If more services are added to the bot later, this method may be called to initialize services after the new services have been constructed.
This starts your bot running. It constructs the services if they have not yet been constructed. Then, it initializes each service. Finally, it starts the POE event loop. This last part really isn't it's business and might go away in the future.
This method will not return until the event loop terminates. The usual way to do this is to call "shutdown".
You may call this at any time while your bot is running to shutdown all the services. This notifies each service that it should shutdown (i.e., finish or terminate any pending jobs in the event loop). It then clears the "services" hash, which should cause all services to be destroyed.
This thing sort of kind of needs POE to be any kind of useful. However, POE seems to have weird drawbacks. I have some planned work-arounds for this being an explicit and required dependency, but it's there for now.
Andrew Sterling Hanenkamp <email@example.com>
This software is copyright (c) 2016 by Qubling Software LLC.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.