NAME

Bot::Backbone::Service::IRChat - Connect and chat with an IRC server

VERSION

version 0.160630

SYNOPSIS

    service irc_chat => (
        service => 'IRChat',
        nick    => 'fancybot',
        server  => 'irc.perl.org',
    );

DESCRIPTION

Can be used to connect to and chat on Internet Relay Chat servers. Will join channels on the server and communicate with groups that way sa well. It can also speak via private messages.

ATTRIBUTES

nick

This is the nickname the bot will take.

server

This is the hostname of the IRC server to connect.

irc

This is the internal POE::Component::IRC::State object used to communicate with the server. It is automatically built using the other settings given to this service.

session_ready

This is a boolean flag that is set to true once the IRC connection is established and the server has started sending messages.

group_options

This is used to keep track of the channels that the service has been asked to join. These channels will be joined once "session_ready" is set to true.

METHODS

initialize

This starts up the POE session required to connect this service to the event loop.

_start

When the POE session is setup, this initiates the connection to the IRC server.

irc_001

This handler is called once the server has started sending messages over the connection and is ready to receive. At this point, "session_ready" will return true and any channels that need to be joined will be joined.

irc_msg

This handler is called whenever a privmsg is sent directly to the bot. It passes the message on to the dispatcher and such.

irc_public

This handler is called whenever a privmsg is sent to a channel that bot has joined. It passes the message on to the dispatcher and such.

join_group

    $chat->join_group({ group => 'example' });

Joins the group pass to the group option. On IRC, the nickname option is ignored.

is_to_me

  my $bool = $self->is_to_me($user, \$text);

Given the user that identifies the bot in a group chat and text that was just sent to the chat, this detects if the message was directed at the bot. Normally, this includes messages that start with the following:

  nick: ...
  nick, ...
  nick- ...

It also includes suffix references like this:

  ..., nick.
  ..., nick

and infix references like this:

  ..., nick, ...

If you want something different, you may subclass service and override this method.

Note that the text is sent as a reference and can be modified, usually to remove the nick from the message so the bot does not have to worry about that.

send_message

    $chat->send_message( to => 'bob', text => 'hi' );
    $chat->send_message( group => 'example, text => 'hi' );

Call to send a message to the nick, via to, or channel, via group, named.

AUTHOR

Andrew Sterling Hanenkamp <hanenkamp@cpan.org>

COPYRIGHT AND LICENSE

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.