NET::IRC::Server NET::IRCServer - a module to handle the IRC Protocol and implements a lightweight IRC Server (without server-to-server support) SYNOPSIS use NET::IRC::Server; $server = NET::IRC::Server->new (srv_prefix => "mein.irc.server.funtzt.net"); $s->set_send_cb (sub { ... }); $s->parse_irc_stream (...) METHODS new (srv_prefix => $server_prefix) srv_prefix - the prefix the server will use for irc commands from itself set_send_cb ($sub, [$command]) The code-ref in the C<$sub> will be called everythime the server wants to send data to a client. If the C<$command> argument is given, the callback will only be called for irc-commands that match C<$command>. If the callback returns a true value when it's matched to a C<$command> the alternative callback (given without the C<$command>) won't be called. The callback will be called with following arguments: $sub->($client, $data, $prefix, $command, $trailing, @params) $client - the client datastructure you give C $data - the raw data to send out, for example on a socket $prefix - irc message prefix (may be undefined) $command - irc command $trailing - the trailing irc parameter @params - the other params or the irc message set_cmd_cb ($cmd, $cb) Sets the command callback for the irc-command C<$cmd>. The callback is executed B the command is evaluated by the server. If you want to prevent evaluation by the server later, you have to return a true value. Otherwise the server will evaluate the command and sends responses. There is are following special events/commands you can register a callback for, set C<$cmd> to: '*' - to receive all commands '!' - client successfully registered (after he send PASS, NICK and USER and all commands were successful, NOTE: the returnvalue of this callback will be ignored) Arguments of the callback are like: $cb->($client, $ircmsg); $client - the client datastructure for this command $ircmsg - the irc-message hash containing: { prefix => , command => , params => , trailing => } send_srv_msg ($client, @msg) Sends a irc-message to C<$client> with the server-prefix. @msg should look like: (, , , ..., ) send_msg ($client, @msg) Sends a irc-message to C<$client>. @msg should look like: (, , , , ..., ) send_nameslist ($client, $channel) This sends the names-list of C<$channel> to the C<$client>. feed_irc_data ($client, $data) Feeds raw IRC C<$data> for processing. When enough data for a command was feeded the command is handled and the callbacks set with C and C will be called. When the server wants to send a response he calls the callback set with C. The C<$client> data structure has to contain the C-key, so the server can generate the irc message prefix for that client in his replys. In the callbacks the C<$client> data structure will be filled with followin keys: $client = { registered => , nickname => , username => , password => , hostname => , channels => { => 1, => 1, ..., } (a hash of channel names the client is currently joined ) }; quit ($client, $quitmsg) It will remove the C<$client> from all lists in the server, and broadcasts the C<$quitmsg> to all users on the channels the C<$client> was. part_channel ($client, $channel, $reason) It will remove the C<$client> from the C<$channel> and will broadcast a PART to all members of that channel. The part C<$reason> may be undefined. join_channel ($client, $channel, $key) It will add the C<$client> to the C<$channel> and will broadcast a JOIN to all members of that channel. get_user_list ($channel) Get's the userlist of the $channel in the form: { nickname => client-structure, ... } register_nick ($client, $nick) Registers the nickname C<$nick> in the server and sets it's client data structure to C<$client>. get_nick ($nick) Returns the client datastructure for nickname C<$nick> or undef if there is no such nick; unregister_nick ($nick) Unregisters the nickname C<$nick> in the server. channel_exists ($channel) Return true if there are clients who are joined to that channel.