package Bot::Backbone::Service::GroupChat;
$Bot::Backbone::Service::GroupChat::VERSION = '0.161950';
use v5.10;
use Bot::Backbone::Service;

with qw(

with 'Bot::Backbone::Service::Role::ChatConsumer' => {
    -excludes => [ 'send_message' ],

with_bot_roles qw(

# ABSTRACT: A helper chat for performing group chats

has group => (
    is          => 'ro',
    isa         => 'Str',
    required    => 1,

has nickname => (
    is          => 'ro',
    isa         => 'Str',
    predicate   => 'has_nickname',

sub initialize {
    my $self = shift;

    my %options = (
        group => $self->group,

    $options{nickname} = $self->nickname if $self->has_nickname;


sub send_message {
    my ($self, $params) = @_;
    my $text = $params->{text};
        group => $self->group,
        text  => $text,

sub receive_message {
    my ($self, $message) = @_;

    return unless $message->is_group
              and $message->group eq $self->group;





=encoding UTF-8

=head1 NAME

Bot::Backbone::Service::GroupChat - A helper chat for performing group chats

=head1 VERSION

version 0.161950


  service group_foo => (
      service => 'GroupChat',
      chat    => 'jabber_chat',
      group   => 'foo',


This is a chat consumer that provides chat services to a specific group on the
consumed chat service.


=head2 group

This is the name of the group this chat will communicate with. It will not
perform chats in any other group or directly.

=head2 nickname

This is the nickname to pass to the chat when joining the group. If not set, no
special nickname will be requested.

=head1 METHODS

=head2 initialize

Joins the L</group>.

=head2 send_message

Sends a message to the L</group>.

=head2 receive_message

If the message belongs to the L</group> this chat service works with, the
consumers will be notified and the dispatcher run. Otherwise, the message will
be ignored.

=head1 AUTHOR

Andrew Sterling Hanenkamp <>


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