Bot::Backbone::Service - Useful features for services
version 0.161950
package MyBot::Service::Echo; use v5.14; # because newer Perl is cooler than older Perl use Bot::Backbone::Service; with qw( Bot::Backbone::Service::Role::Service Bot::Backbone::Service::Role::Responder ); # Instead of Bot::Backbone::Service::Role::Responder, you may prefer to # apply the Bot::Backbone::Service::Role::ChatConsumer role instead. It # really depends on if this module will be used across multiple chats or # needs to be tied to a specific chat. service_dispatcher as { command '!echo' => given_parameters { parameter thing => ( match => qr/.+/ ); } respond_by_method 'echo_back'; }; sub echo_back { my ($self, $message) = @_; return $message->parameters->{thing}; } __PACKAGE__->meta->make_immutable; # very good idea
This is a Moose-replacement for bot backbone services. It provides a similar set of features to a service class as are provided to bot classes by Bot::Backbone.
Setup the bot package by applying the Bot::Backbone::Service::Role::Service role to the class.
with_bot_roles ...;
Similar to with provided by Moose, this defines a list of roles that should be applied to the bot that uses this service.
with
service_dispatcher ...;
Setup the default dispatcher for this service. Use of this method will cause the Bot::Backbone::Service::Role::Dispatch role to be applied to the class.
This exports all the same dispatcher predicates as Bot::Backbone.
redispatch_to
command
not_command
given_parameters (and parameter)
given_parameters
parameter
to_me
not_to_me
shouted
spoken
whispered
also
This exports all the same run mode operations as Bot::Backbone.
as
respond. This run mode operation will be passed the service object as the first argument, rather than that bot object.
respond
respond_with_method. As stated for respond, the first argument is the service object. The method is also a method defined within the current service package rather than the bot.
respond_with_method
respond_with_bot_method. This is similar to respond_with_method, but instead of calling a method within the service, it will call a method directly on the bot to which the service has been added.
respond_with_bot_method
run_this. This run mode operation will be passed the service object as the first argument, rather than that bot object.
run_this
run_this_method. As stated for respond, the first argument is the service object. The method is also a method defined within the current service package rather than the bot.
run_this_method
run_this_bot_method. This is similar to run_this_method, but results in a call to a method on the bot object rather than on the service.
run_this_bot_method
Andrew Sterling Hanenkamp <hanenkamp@cpan.org>
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.
To install Bot::Backbone, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Bot::Backbone
CPAN shell
perl -MCPAN -e shell install Bot::Backbone
For more information on module installation, please visit the detailed CPAN module installation guide.