-
Notifications
You must be signed in to change notification settings - Fork 0
Hacking on basil
First and foremost, please take a look through the docs:
$ rake rdoc
$ $BROWSER docs/index.html
Main.run is called. Plugin.load loads all files (alphabetically) found in Config.plugins_directory.
Email.check spins off a separate thread which checks the configured email on the configured interval (if your server is defined to handle broadcasts). When a message is received, it's dispatched through Plugin.email_checkers much like a normal chat. If any checkers decide to construct a Message, that message is handed off to your server's broadcast_message method.
Config.server.start will start your configured server instance which is in charge of handling incoming messages and passing them through Server#dispatch_message. If a reply is returned, your server instance is also in charge of sending that back to chat.
Server#dispatch_message will ask all registered plugins if they'd like to handle the message. If the message was deemed to basil, responders will be asked first. Watchers are always asked. If any one plugin triggers on the message, dispatching stops and that reply is returned.
Storage allows plugins to persist arbitrary data on disk. It's just a thin wrapper over PStore.
ChatHistory allows plugins to access a limited number of recent messages spoken in their chat. Plugins can also purge that chat history (for example, if someone accidentally says a password). The history is stored using Storage.
Utils provides various utility methods for plugins. Methods for building a reply or a statement to say in chat as well as making simple HTTP requests are provided here.
Logging is accomplished through a singleton class and/or a convenience module. The Logger class is a small wrapper over ruby's built-in ::Logger and forwards all messages to this underlying object. The Logging mixin simply adds a number of delegate methods so classes can use error "some message" where they would have used Logger.error "some message".
Currently, the level is set at INFO. You can increase that to DEBUG (which includes all Skype API requests/responses) by passing --debug when invoking basil.
Additionally, you can adjust the logging level of a running basil via the eval plugin:
eval Logger.level = ::Logger::WARN