Bot::Backbone::Service::Role::SendPolicy - Provides send policy framework to a service
version 0.141180
package Bot::Backbone::Service::RandomGibberish; use v5.14; use Bot::Backbone::Service; with qw( Bot::Backbone::Service::Role::Service Bot::Backbone::Service::Role::SendPolicy ); use List::Util qw( shuffle ); # Post to a random chat sub send_message { my ($self, $params) = @_; my @chats = grep { $_->does('Bot::Backbone::Service::Role::Chat') } $self->bot->list_services; my ($chat) = shuffle @chats; $chat->send_message($params); } # ... whatever else this insane service does ...
This role is used to apply send policies to Bot::Backbone::Service::Role::Chat, Bot::Backbone::Service::Role::ChatConsumer, and Bot::Backbone::Service::Role::Dispatch services. If you have a service that is none of those, but would like to have a send policy applied to anything it may send to a chat, you may define a send_message method and then apply this role.
send_message
This is the name of the send policy to apply to this service. It is set using the send_policy setting in the service configuration. It will be used to set "send_policy", if any policy is set.
send_policy
This is the Bot::Backbone::SendPolicy that has been selected for this service.
This role requires a send_mesage method be present that works just the same as the one required in Bot::Backbone::Service::Role::Chat. This role will modify that method to apply the "send_policy" to calls to that method.
send_mesage
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.