NAME

POE::Component::IRC::Plugin::DCC - a PoCo-IRC plugin providing DCC support

SYNOPSIS

# send a file
my $file = '/home/user/secret.pdf';
my $recipient = 'that_guy';
$irc->dcc($recipient => SEND => $file);

# receive a file
sub irc_dcc_request {
    my ($nick, $type, $port, $cookie, $file, $size) = @_[ARG0..$#_];
    return if $type ne 'SEND';

    my $irc = $_[SENDER]->get_heap();
    print "Someone's sending me '$file' (size: $size) on port $port\n");
    $irc->yield(dcc_accept => $cookie);
}

DESCRIPTION

This plugin provides the IRC commands needed to make use of DCC. It is used internally by POE::Component::IRC so there's no need to add it manually.

METHODS

new

Takes no arguments.

Returns a plugin object suitable for feeding to POE::Component::IRC's plugin_add() method.

dccports

Sets the TCP ports that can be used for DCC sends. Takes one argument, an arrayref containing the port numbers.

nataddr

Sets the public NAT address to be used for DCC sends.

COMMANDS

The plugin responds to the following POE::Component::IRC commands.

dcc

Send a DCC SEND or CHAT request to another person. Takes at least two arguments: the nickname of the person to send the request to and the type of DCC request (SEND or CHAT). For SEND requests, be sure to add a third argument for the filename you want to send. Optionally, you can add a fourth argument for the DCC transfer blocksize, but the default of 1024 should usually be fine.

Incidentally, you can send other weird nonstandard kinds of DCCs too; just put something besides 'SEND' or 'CHAT' (say, 'FOO') in the type field, and you'll get back irc_dcc_* events when activity happens on its DCC connection.

If you are behind a firewall or Network Address Translation, you may want to consult POE::Component::IRC's connect for some parameters that are useful with this command.

dcc_accept

Accepts an incoming DCC connection from another host. First argument: the magic cookie from an irc_dcc_request event. In the case of a DCC GET, the second argument can optionally specify a new name for the destination file of the DCC transfer, instead of using the sender's name for it. (See the irc_dcc_request section below for more details.)

dcc_resume

Resumes a DCC SEND file transfer. First argument: the magic cookie from an irc_dcc_request event. The second argument is the name of the file to which you want to write. The third argument is the size from which will be resumed.

dcc_chat

Sends lines of data to the person on the other side of a DCC CHAT connection. Takes any number of arguments: the magic cookie from an irc_dcc_start event, followed by the data you wish to send. (It'll be separated by newlines for you.)

dcc_close

Terminates a DCC SEND or GET connection prematurely, and causes DCC CHAT connections to close gracefully. Takes one argument: the magic cookie from an irc_dcc_start or irc_dcc_request event.

OUTPUT

irc_dcc_request

You receive this event when another IRC client sends you a DCC SEND or CHAT request out of the blue. You can examine the request and decide whether or not to accept it here. ARG0 is the nick of the client on the other end. ARG1 is the type of DCC request (CHAT, SEND, etc.). ARG2 is the port number. ARG3 is a "magic cookie" argument, suitable for sending with dcc_accept events to signify that you want to accept the connection (see the 'dcc_accept' docs). For DCC SEND and GET connections, ARG4 will be the filename, and ARG5 will be the file size.

irc_dcc_chat

Notifies you that one line of text has been received from the client on the other end of a DCC CHAT connection. ARG0 is the connection's magic cookie, ARG1 is the nick of the person on the other end, ARG2 is the port number, and ARG3 is the text they sent.

irc_dcc_done

You receive this event when a DCC connection terminates normally. Abnormal terminations are reported by irc_dcc_error, below. ARG0 is the connection's magic cookie, ARG1 is the nick of the person on the other end, ARG2 is the DCC type (CHAT, SEND, GET, etc.), and ARG3 is the port number. For DCC SEND and GET connections, ARG4 will be the filename, ARG5 will be the file size, and ARG6 will be the number of bytes transferred. (ARG5 and ARG6 should always be the same.)

irc_dcc_failed

You get this event when a DCC connection fails for some reason. ARG0 will be the operation that failed, ARG1 is the error number, ARG2 is the description of the error and ARG3 the connection's magic cookie.

irc_dcc_error

You get this event whenever a DCC connection or connection attempt terminates unexpectedly or suffers some fatal error. ARG0 will be the connection's magic cookie, ARG1 will be a string describing the error. ARG2 will be the nick of the person on the other end of the connection. ARG3 is the DCC type (SEND, GET, CHAT, etc.). ARG4 is the port number of the DCC connection, if any. For SEND and GET connections, ARG5 is the filename, ARG6 is the expected file size, and ARG7 is the transferred size.

irc_dcc_get

Notifies you that another block of data has been successfully transferred from the client on the other end of your DCC GET connection. ARG0 is the connection's magic cookie, ARG1 is the nick of the person on the other end, ARG2 is the port number, ARG3 is the filename, ARG4 is the total file size, and ARG5 is the number of bytes successfully transferred so far.

irc_dcc_send

Notifies you that another block of data has been successfully transferred from you to the client on the other end of a DCC SEND connection. ARG0 is the connection's magic cookie, ARG1 is the nick of the person on the other end, ARG2 is the port number, ARG3 is the filename, ARG4 is the total file size, and ARG5 is the number of bytes successfully transferred so far.

irc_dcc_start

This event notifies you that a DCC connection has been successfully established. ARG0 is a unique "magic cookie" argument which you can pass to dcc_chat or dcc_close. ARG1 is the nick of the person on the other end, ARG2 is the DCC type (CHAT, SEND, GET, etc.), and ARG3 is the port number. For DCC SEND and GET connections, ARG4 will be the filename and ARG5 will be the file size.

AUTHOR

Dennis 'fimmtiu' Taylor, et al.