Mojo-IRC

 view release on metacpan or  search on metacpan

README  view on Meta::CPAN

NAME
    Mojo::IRC - IRC Client for the Mojo IOLoop

VERSION
    0.44

SYNOPSIS
      my $irc = Mojo::IRC->new(
                  nick => 'test123',
                  user => 'my name',
                  server => 'irc.perl.org:6667',
                );

      $irc->on(irc_join => sub {
        my($self, $message) = @_;
        warn "yay! i joined $message->{params}[0]";
      });

      $irc->on(irc_privmsg => sub {
        my($self, $message) = @_;
        say $message->{prefix}, " said: ", $message->{params}[1];
      });

      $irc->connect(sub {
        my($irc, $err) = @_;
        return warn $err if $err;
        $irc->write(join => '#mojo');
      });

      Mojo::IOLoop->start;

DESCRIPTION
    Mojo::IRC is a non-blocking IRC client using Mojo::IOLoop from the
    wonderful Mojolicious framework.

    It features IPv6 and TLS, with additional optional modules:
    IO::Socket::IP and IO::Socket::SSL.

    By default this module will only emit standard IRC events, but by
    settings "parser" to a custom object it will also emit CTCP events.
    Example:

      my $irc = Mojo::IRC->new;
      $irc->parser(Parse::IRC->new(ctcp => 1);
      $irc->on(ctcp_action => sub {
        # ...
      });

    It will also set up some default events: "ctcp_ping", "ctcp_time", and
    "ctcp_version".

    This class inherits from Mojo::EventEmitter.

TESTING
    The module Test::Mojo::IRC is useful if you want to write tests without
    having a running IRC server.

    MOJO_IRC_OFFLINE (from v0.20) is now DEPRECATED in favor of
    Test::Mojo::IRC.

EVENTS
  close
      $self->on(close => sub { my ($self) = @_; });

    Emitted once the connection to the server closes.

  error
      $self->on(error => sub { my ($self, $err) = @_; });

    Emitted once the stream emits an error.

  message
      $self->on(message => sub { my ($self, $msg) = @_; });

    Emitted when a new IRC message arrives. Will dispatch to a default
    handler, which will again emit "err_event_name" "ctcp_event_name" and
    "irc_event_name" below.

    Here is an example $msg:

      {
        command  => "PRIVMSG",
        event    => "privmsg",
        params   => ["#convos", "hey!"],
        prefix   => "jan_henning",
        raw_line => ":jan_henning PRIVMSG #convos :hey",
      }

  err_event_name
    Events that start with "err_" are emitted when there is an IRC response
    that indicates an error. See Mojo::IRC::Events for sample events.

  ctcp_event_name
    Events that start with "ctcp_" are emitted if the "parser" can
    understand CTCP messages, and there is a CTCP response.

      $self->parser(Parse::IRC->new(ctcp => 1);



( run in 1.665 second using v1.01-cache-2.11-cpan-39bf76dae61 )