IRC is an odd protocol, and the plethora of server implementations all seem to behave differently in certain ways. It's real hard to debug an IRC bot when one server works and the other doesn't---often because of server-side issues.

This little _default handler traces the IRC server responses your POE::Component::IRC bot or client doesn't handle. It's extremely useful for finding out why your mode command isn't generating a response, or something.

sub _default {
  my ($event, $args) = @_[ARG0 .. $#_];
  print "unhandled $event\n";
  my $arg_number = 0;
  foreach (@$args) {
    print "  ARG$arg_number = ";
    if (ref($_) eq 'ARRAY') {
      print "$_ = [", join(", ", @$_), "]\n";
    }
    else {
      print "'$_'\n";
    }
    $arg_number++;
  }
  return 0;    # Don't handle signals.
}

Some notes:

Be sure your _default handler returns zero. Otherwise it will handle all unhandled signals, including SIGINT, making your program very difficult to stop.

Don't forget to add _default to the inline_states or package_states of your POE::Session->create(...) call. Otherwise POE doesn't know which function will handle the _default event.

POE::Session->create(
  inline_states => {
    ...;
      _default => \&handle_default,
    ...;
  }
);