Andrew Sterling Hanenkamp > Bot-Backbone-0.112500 > Bot::Backbone::Service

Download:
Bot-Backbone-0.112500.tar.gz

Dependencies

Annotate this POD

CPAN RT

Open  0
View/Report Bugs
Module Version: 0.112500   Source   Latest Release: Bot-Backbone-0.142820

NAME ^

Bot::Backbone::Service - Useful features for services

VERSION ^

version 0.112500

SYNOPSIS ^

  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

DESCRIPTION ^

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.

SUBROUTINES ^

init_meta

Setup the bot package by applying the Bot::Backbone::Service::Role::Service role to the class.

SETUP ROUTINES ^

with_bot_roles

  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.

service_dispatcher

  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.

DISPATCHER PREDICATES ^

This exports all the same dispatcher predicates as Bot::Backbone.

RUN MODE OPERATIONS ^

This exports all the same run mode operations as Bot::Backbone.

AUTHOR ^

Andrew Sterling Hanenkamp <hanenkamp@cpan.org>

COPYRIGHT AND LICENSE ^

This software is copyright (c) 2011 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.

syntax highlighting: