From 50fa9ff7060e65e1684041771cbc2877979d156f Mon Sep 17 00:00:00 2001 From: Pragmatic Software Date: Sat, 12 Sep 2015 01:52:45 -0700 Subject: [PATCH] Improve `recall` error message when no history is found `recall` now shows all channels a nick was seen in if they weren't seen in the requested channel. --- PBot/MessageHistory.pm | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/PBot/MessageHistory.pm b/PBot/MessageHistory.pm index f7d850d2..38715fcc 100644 --- a/PBot/MessageHistory.pm +++ b/PBot/MessageHistory.pm @@ -308,6 +308,24 @@ sub recall_message { if(defined $account) { my $max_messages = $self->{database}->get_max_messages($account, $recall_channel); if($recall_history < 1 || $recall_history > $max_messages) { + if ($max_messages == 0) { + my @channels = $self->{database}->get_channels($account); + my $result = "No messages for $recall_nick in $recall_channel; I have messages for them in "; + my $comma = ''; + my $count = 0; + foreach my $channel (sort @channels) { + next if $channel !~ /^#/; + $result .= "$comma$channel"; + $comma = ', '; + $count++; + } + if ($count == 0) { + return "I have no messages for $recall_nick."; + } else { + return "$result."; + } + } + } else { return "Please choose a history between 1 and $max_messages"; } }