my ($self, $irc, $rfullname, $rtargets, $rmessage) = @_;
my $nick = parse_user $$rfullname;
- seen $self, $irc, $$rmessage, $$rtargets->[0], $nick if $$rmessage =~ /^\s*!?seen\s+([^ ]+)/
+ seen $self, $irc, $1, $$rtargets->[0], $nick if $$rmessage =~ /^\s*!?seen\s+([^ ]+)/
}
1;
use strict;
use warnings;
-use Test::More tests => 8;
+use Test::More tests => 10;
use Test::MockObject;
BEGIN { *CORE::GLOBAL::localtime = sub { 'now' } }
# Sub setup
sub runtest{
- my ($message, $expect, $comment) = @_;
+ my ($message, $expect, $comment, $privmsg) = @_;
undef $last_msg;
- $self->S_public($mockirc, $rmgv, \$channels, \$message);
+ $self->S_public($mockirc, $rmgv, \$channels, \$message) unless $privmsg;
+ $self->S_msg($mockirc, $rmgv, \$channels, \$message) if $privmsg;
is($last_msg, $expect, $comment)
}
runtest 'bot: seen mgv', "I last saw mgv now parting #chan with message 'buh-bye'", 'part with message';
runtest 'bot: seen asd', "I haven't seen asd", "haven't seen";
+
+# Private messages
+runtest 'seen asd', "I haven't seen asd", "haven't seen", 1;
+runtest ' !seen asd', "I haven't seen asd", "haven't seen", 1;