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

NAME

Bot::Backbone::Service::Role::Chat - Chat services must implement this role

VERSION

version 0.112500

DESCRIPTION

A chat service is one that sends and receives messages to other entities.

See Bot::Backbone::Service::ConsoleChat and Bot::Backbone::Service::JabberChat.

ATTRIBUTES

chat_consumers

This is a list of Bot::Backbone::Service::Role::ChatConsumers that hvae registered to receive messages from this chat service. A chat consumer is registered using the register_chat_cnosumer method. A list_chat_consumers method is provided to list the registered consumers.

REQUIRED METHODS

send_message

  # Send a direct message
  $chat->send_message({
      to          => $to_username,
      text        => 'blah blah blah',
  });

  # Send a group message
  $chat->send_message({
      group       => $to_group,
      text        => 'blah blah blah',
  });

Sends a message to a group or individual using this chat service. This is used when the message is not being made as a direct reply to a message received from the chat service.

If both group and to are passed, the preference should be to send to the group.

This role also provides a wrapper around your chat's implementation of send_message, which will apply the current service's send policy to the message. The most restrictive send policy encountered at any point will win.

A send policy may be explicitly provided by setting the send_policy setting in the parameters to a Bot::Backbone::SendPolicy object. Missing this parameter will result in an error. The send_policy_result may also be set to reflect the most restrictive send policy result encountered so far.

METHODS

send_reply

  $chat->send_reply($message, \%options);

Given a message generated by this chat service, this should send a reply to the origin of the message, whether that be a group or individual or other entity.

The second argument is a hash reference of options, which is used to modify the reply further. See "send_message" for additional options and be aware that individual chat implementations may provide more options in addition to those shown here.

resend_message

  $chat->resend_message($message);

This should be called whenever a message is received from the chat service. This message willb e forwarded to all of the registered "chat_consumers".

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.