Jon Portnoy


IRC::Toolkit::CTCP - CTCP parsing utilities


  ## Extract first CTCP request/reply from a message:
  if (my $ctcp_ev = ctcp_extract( $orig_msg ) ) {
    ## CTCP was found; $ctcp_ev is an IRC::Message::Object

  ## Properly CTCP-quote a string:
  my $quoted_ctcp = ctcp_quote("PING 1234");

  ## Deparse CTCP messages (including multipart):
  if (my $ref = ctcp_unquote($raw_line)) {
    my @ctcp = @{ $ref->{ctcp} };
    my @txt  = @{ $ref->{text} };


Utility functions useful for quoting/unquoting/extracting CTCP.


Takes input (in the form of an IRC::Message::Object instance, a hash such as that produced by POE::Filter::IRCv3, or a raw line) and attempts to extract a valid CTCP request or reply.

Returns an IRC::Message::Object whose command carries an appropriate prefix (one of ctcp, ctcpreply, or dcc_request) prepended to the CTCP command:

  ## '$ev' is your incoming or outgoing IRC::Message::Object
  ## CTCP VERSION request:
  $ev->command eq 'ctcp_version' 

  ## Reply to CTCP VERSION:
  $ev->command eq 'ctcpreply_version'

  ## DCC SEND:
  $ev->command eq 'dcc_request_send' 

Returns undef if no valid CTCP was found; this is a breaking change in v0.91.2, as previous versions returned the empty list.


CTCP quote a raw line.


Deparses a raw line possibly containing CTCP.

Returns a hash with two keys, ctcp and text, whose values are ARRAYs containing the CTCP and text portions of a CTCP-quoted message.

Returns an empty list if no valid CTCP was found.


Jon Portnoy <>

Code derived from Net::IRC and POE::Filter::IRC::Compat, copyright BinGOs, HINRIK, fimm, Abigail et al

Licensed under the same terms as Perl.