The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Bot::Backbone::Service::Role::SendPolicy - Provides send policy framework to a service

VERSION

version 0.142820

SYNOPSIS

  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 ...

DESCRIPTION

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.

ATTRIBUTES

send_policy_name

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.

REQUIRED METHODS

send_message

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.

AUTHOR

Andrew Sterling Hanenkamp <hanenkamp@cpan.org>

COPYRIGHT AND LICENSE

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.