|
AutumnLeafMethods
Making sense of the many methods in Autumn::Stem and Autumn::Leaf.
The Autumn::Leaf and Autumn::Stem classes have a lot of methods; however, that's no need to get intimidated! Here's the full list of methods you should care about: Stem ActionsThese methods allow your leaf to perform IRC tasks, such as joining and leaving a channel or promoting a user to operator. Due to the nature of IRC, all of these actions fail silently on error. The only way to tell if your action was successful is to override a hook method (see below). You can call these methods on any Autumn::Stem instance. Generally, the stem instance is provided to you, as a parameter for a hook method, for instance. You can also access all of a leaf's stems with the stems attribute. Performing actions
Getting information
Other methods
Invoked (Hook) MethodsThese Autumn::Leaf methods are for you to override. They are called when certain IRC events occur. If you need your leaf to respond to an IRC event, you override this method and specify your leaf's response. Unless otherwise indicated in the API, the default behavior for each of these methods is to do nothing. Therefore, it isn't necessary to call super when you override these methods. Leaf events
IRC events
IRC errorsIRC errors are handled by the stem. You should see the Autumn::Stem#add_listener documentation for full details, but there are a number of IRC responses and errors, as well as server messages and errors, that you can trap if you need to. As an example, if you wanted to trap NAMES responses, you would implement a method in your leaf like so: irc_rpl_namreply_response(stem, sender, recipient, arguments, msg) The phrase "rpl_namreply" is defined in the resources/daemons/RFC1459.yml file. You can implement a method named after any such IRC reply. Errors are handled similarly; to be alerted in the event that your nickname is in use: irc_err_nicknameinuse_response(stem, sender, recipient, arguments, msg) Note that Stem already has a system for claiming stolen nicks, so there's no need to handle this situation. You could implement this method if there were something else you wanted to do in addition, however. This is just the tip of the iceberg; please see the add_listener method docs for complete details. CTCP requests and responsesThe Autumn::CTCP class is a listener plugin that gives other listeners the ability to send CTCP requests, listen for CTCP requests, and send CTCP replies. It is included by default to all stems, so its features are available to your leaf. To receive a CTCP request, implement a method like so: ctcp_version_request(handler, stem, sender, arguments) You can then send a response with a call like: stem.ctcp_reply_version sender, 'My Awesome Bot v2.0' To send your own CTCP request, you simply call a stem method like so: stem.ctcp_time 'Sancho' And listen for his response by implementing: ctcp_time_response(handler, stem, sender, arguments) For full details, see the Autumn::CTCP class docs. Helper and Utility MethodsThese methods are included for your convenience. They will help make writing your leaf easier. Persistent storeFor more information, see StoringPersistentData.
FiltersFor more information, see the README.
Leaf configuration
IRC CommandsThese methods are IRC commands that are included in all leaves by default. If there are commands you wish to remove from your leaf, you can use the remove_method method. If you want alternate behavior from your leaf, simply override these methods with your own.
New leaves, by default, are configured to restrict the !quit and !reload commands to channel ops and higher. See the README for more information. |