Bot::Backbone::Service::Role::Responder - A role for services that respond to messages
version 0.142820
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 role will provide implementations of send_message and send_reply methods appropriate if you build a service that just replies to input passed to it.
send_message
send_reply
$service->send_reply($message, \%options);
This will send a reply back to the given message.
$service->send_message({ chat => $chat, %options, });
This works just like your typical send_message method, but it requires a chat argument to tell it where to send the message. This is mostly useful if all you need to do is reply to whatever message was received from whichever source it was received from.
chat
Andrew Sterling Hanenkamp <hanenkamp@cpan.org>
This software is copyright (c) 2014 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.