skipping urls, parsing pm commands properly

This commit is contained in:
long.haired.steve 2009-12-07 15:45:27 +00:00
parent d251087e08
commit 5b3598ef16
2 changed files with 12 additions and 4 deletions

View File

@ -179,6 +179,10 @@ C<STDERR>.
my ($self, $word) = @_;
return exists $self->stopwords->{lc($word)};
}
sub is_url {
my ($self, $word) = @_;
return $word =~ /^https?:\/\//i;
}
sub is_meme {
my ($self, $word) = @_;
@ -278,8 +282,9 @@ C<$self-E<gt>meme>.
my $is_word = $word !~ /^[\d\W+]+$/;
my $is_stop = $self->is_stop_word($word);
my $is_meme = $self->is_meme($word);
my $is_url = $self->is_url($word);
$is_word and not $is_stop and not $is_meme;
$is_word and not $is_stop and not $is_meme and not $is_url;
} @word_idxs_len_sorted;
$self->_set_word_indices(\@word_idxs_len_sorted);

View File

@ -276,7 +276,7 @@ sub handle_pm_command {
$self->log("CMD: testing for PM command: [$who], [$msg]\n");
my ($cmd, $args) = $self->parse_command($msg);
my ($cmd, $args) = $self->parse_command($msg,0);
return 0 unless defined $cmd && length $cmd;
$self->log("CMD: [$msg] is a PM command\n");
@ -293,7 +293,10 @@ sub handle_pm_command {
} elsif ($cmd eq 'friend') {
# TODO: become friend/enemy
} elsif ($cmd eq $self->config('meme')) {
$self->buttify_message($who, 'msg', $args, 0);
my $ret = $self->buttify_message($who, 'msg', $args, 0);
if (!$ret) {
$self->pm_reply($who, "Sorry, can't ".$self->config('meme'));
}
return 1;
}
@ -428,7 +431,7 @@ sub buttify_message {
$self->say(channel => $where, who => $who,
body => $butt_msg, address => $prefix_addressee);
}
return;
return 1;
}
sub to_butt_or_not_to_butt {