Skip Menu |
 

This queue is for tickets about the POE-Component-IRC CPAN distribution.

Report information
The Basics
Id: 46065
Status: resolved
Priority: 0/
Queue: POE-Component-IRC

People
Owner: Nobody in particular
Requestors: damien.bezborodow [...] valex.com.au
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: POE::Component::IRC::Plugin::BotCommand does not respond as documented
Date: Thu, 14 May 2009 16:36:29 +0930
To: bug-POE-Component-IRC [...] rt.cpan.org
From: Damien Bezborodov <damien.bezborodow [...] valex.com.au>
Download (untitled) / with headers
text/plain 2.6k
*Steps:* 1. Use the example script provided on CPAN documentation, any OS, version 6.06. *Expect:* (4:17:44 PM) dbezborodov: vxTEST: test (4:17:45 PM) vxTEST: (notice) Unknown command: test (4:17:45 PM) vxTEST: (notice) To get a list of commands, do: /msg vxTEST help (4:23:17 PM) dbezborodov: vxTEST: help (4:23:18 PM) vxTEST: (notice) Commands: slap, lookup (4:23:19 PM) vxTEST: (notice) You can do: /msg vxTEST help <command> (4:18:11 PM) dbezborodov: vxTEST: help lookup (4:18:12 PM) vxTEST: (notice) Takes two arguments: a record type (optional), and a host. (4:19:16 PM) dbezborodov: vxTEST: help test (4:19:17 PM) vxTEST: (notice) Unknown command: test *Actual:* (3:45:52 PM) dbezborodov: vxTEST: help (3:45:52 PM) vxTEST: (notice) Unknown command: help (3:45:53 PM) vxTEST: (notice) To get a list of commands, do: /msg vxTEST help (3:48:14 PM) dbezborodov: vxTEST: slap dbezborodov (3:48:15 PM) ***vxTEST slaps dbezborodov (3:53:30 PM) dbezborodov: vxTEST: help slap (3:53:32 PM) vxTEST: (notice) Unknown command: help (3:53:33 PM) vxTEST: (notice) To get a list of commands, do: /msg vxTEST help (4:00:55 PM) dbezborodov: vxTEST: test (doesn't respond at all here) *My fix (implemented by overriding methods) is below (although it _will need review_):* package VXBot::BotCommand; use strict; use warnings; use Carp; use POE::Component::IRC::Plugin::BotCommand; use POE::Component::IRC::Common qw( parse_user ); use POE::Component::IRC::Plugin qw( :ALL ); our $VERSION = '6.06'; our @ISA = qw(POE::Component::IRC::Plugin::BotCommand); sub _handle_cmd { my ($self, $who, $where, $cmd, $args) = @_; my $irc = $self->{irc}; $cmd = lc $cmd; if (defined $self->{Commands}->{$cmd}) { $irc->send_event("irc_botcmd_$cmd" => $who, $where, $args); } else { my @help = $self->_get_help($cmd, $args); $irc->yield(notice => $where => $_) for @help; } return 1; } sub _get_help { my ($self, $cmd, $args) = @_; my $irc = $self->{irc}; my @help; if ($cmd eq "help") { if (defined $args) { if (exists $self->{Commands}->{$args}) { @help = split /\015?\012/, $self->{Commands}->{$args}; } else { push @help, "Unknown command: $args"; } } else { push @help, 'Commands: ' . join ', ', keys %{ $self->{Commands} }; push @help, 'You can do: /msg ' . $irc->nick_name() . ' help <command>'; } } else { push @help, "Unknown command: $cmd"; push @help, 'To get a list of commands, do: /msg '. $irc->nick_name() . ' help'; } return @help; } 1; __END__
Download (untitled) / with headers
text/plain 342b
You are right about the help command not working. I've fixed it. The fact that it doesn't respond to unknown commands was intentional, but I changed it to print a help message by default now (can be changed with "Handle_unkown => 0" to constructor). http://github.com/bingos/poe-component-irc/commit/b3fa36465da5bcf60540d3020a85f6bf055e6beb


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.