From f618b2928214fd9934e0ece10a816d9387f25b01 Mon Sep 17 00:00:00 2001 From: Pragmatic Software Date: Thu, 14 Nov 2013 06:35:40 +0000 Subject: [PATCH] Do not lowercase hostmask/nicks in message history (quotegrab now preserves nick case) --- PBot/AntiFlood.pm | 6 +----- PBot/Quotegrabs.pm | 8 +++++++- PBot/VERSION.pm | 2 +- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/PBot/AntiFlood.pm b/PBot/AntiFlood.pm index 4e17144a..3827ad06 100644 --- a/PBot/AntiFlood.pm +++ b/PBot/AntiFlood.pm @@ -213,14 +213,10 @@ sub check_flood { my ($self, $channel, $nick, $user, $host, $text, $max_messages, $max_time, $mode) = @_; $channel = lc $channel; - my $mask = lc "$nick!$user\@$host"; + my $mask = "$nick!$user\@$host"; $self->{pbot}->logger->log(sprintf("%-14s | %-65s | %s\n", $channel eq $mask ? "QUIT" : $channel, $mask, $text)); - $nick = lc $nick; - $user = lc $user; - $host = lc $host; - my $account = $self->get_flood_account($nick, $user, $host); if(not defined $account) { diff --git a/PBot/Quotegrabs.pm b/PBot/Quotegrabs.pm index 2dd205cc..da0a3766 100644 --- a/PBot/Quotegrabs.pm +++ b/PBot/Quotegrabs.pm @@ -137,7 +137,7 @@ sub export_quotegrabs() { } $last_channel = ""; - foreach my $quotegrab (sort { $$a{channel} cmp $$b{channel} or $$a{nick} cmp $$b{nick} } @{ $self->{quotegrabs} }) { + foreach my $quotegrab (sort { $$a{channel} cmp $$b{channel} or lc $$a{nick} cmp lc $$b{nick} } @{ $self->{quotegrabs} }) { if(not $quotegrab->{channel} =~ /^$last_channel$/i) { print FILE "\n\n" if $had_table; print FILE "\n"; @@ -236,6 +236,10 @@ sub grab_quotegrab { return "/msg $nick Please choose a history between 1 and $self->{pbot}->{MAX_NICK_MESSAGES}"; } + if(not $channel =~ m/^#/) { + return "'$channel' is not a valid channel; usage: grab [[history] channel] (you must specify a history parameter before the channel parameter)"; + } + my $found_mask = undef; my $last_spoken = 0; foreach my $mask (keys %{ $self->{pbot}->antiflood->message_history }) { @@ -252,6 +256,8 @@ sub grab_quotegrab { return "No message history for $grab_nick in channel $channel. Usage: grab [history [channel]]; to specify channel, you must also specify history"; } + ($grab_nick) = $found_mask =~ m/^([^!]+)!/; # convert $grab_nick to match casing of nick + if(not exists $self->{pbot}->antiflood->message_history->{$found_mask}->{channels}->{$channel}) { return "No message history for $grab_nick in channel $channel. Usage: grab [history [channel]]; to specify channel, you must also specify history"; } diff --git a/PBot/VERSION.pm b/PBot/VERSION.pm index e95be7be..9413bf91 100644 --- a/PBot/VERSION.pm +++ b/PBot/VERSION.pm @@ -13,7 +13,7 @@ use warnings; # These are set automatically by the build/commit script use constant { BUILD_NAME => "PBot", - BUILD_REVISION => 464, + BUILD_REVISION => 466, BUILD_DATE => "2013-11-13", };