3
0
mirror of https://github.com/pragma-/pbot.git synced 2024-12-24 11:42:35 +01:00

Fix possible case-sensitivity issues

This commit is contained in:
Pragmatic Software 2016-10-29 10:47:08 -07:00
parent 72faa9169f
commit 3bd424aacc

View File

@ -58,12 +58,14 @@ sub initialize {
sub can_gain_ops { sub can_gain_ops {
my ($self, $channel) = @_; my ($self, $channel) = @_;
$channel = lc $channel;
return exists $self->{pbot}->{channels}->{channels}->hash->{$channel} && $self->{pbot}->{channels}->{channels}->hash->{$channel}{chanop}; return exists $self->{pbot}->{channels}->{channels}->hash->{$channel} && $self->{pbot}->{channels}->{channels}->hash->{$channel}{chanop};
} }
sub gain_ops { sub gain_ops {
my $self = shift; my $self = shift;
my $channel = shift; my $channel = shift;
$channel = lc $channel;
return if exists $self->{op_requested}->{$channel}; return if exists $self->{op_requested}->{$channel};
return if not $self->can_gain_ops($channel); return if not $self->can_gain_ops($channel);
@ -79,11 +81,13 @@ sub gain_ops {
sub lose_ops { sub lose_ops {
my $self = shift; my $self = shift;
my $channel = shift; my $channel = shift;
$channel = lc $channel;
$self->{pbot}->{conn}->privmsg("chanserv", "op $channel -" . $self->{pbot}->{registry}->get_value('irc', 'botnick')); $self->{pbot}->{conn}->privmsg("chanserv", "op $channel -" . $self->{pbot}->{registry}->get_value('irc', 'botnick'));
} }
sub add_op_command { sub add_op_command {
my ($self, $channel, $command) = @_; my ($self, $channel, $command) = @_;
$channel = lc $channel;
return if not $self->can_gain_ops($channel); return if not $self->can_gain_ops($channel);
push @{ $self->{op_commands}->{$channel} }, $command; push @{ $self->{op_commands}->{$channel} }, $command;
} }
@ -91,6 +95,7 @@ sub add_op_command {
sub perform_op_commands { sub perform_op_commands {
my $self = shift; my $self = shift;
my $channel = shift; my $channel = shift;
$channel = lc $channel;
my $botnick = $self->{pbot}->{registry}->get_value('irc', 'botnick'); my $botnick = $self->{pbot}->{registry}->get_value('irc', 'botnick');
$self->{pbot}->{logger}->log("Performing op commands...\n"); $self->{pbot}->{logger}->log("Performing op commands...\n");
@ -150,6 +155,9 @@ sub ban_user_timed {
my $self = shift; my $self = shift;
my ($mask, $channel, $length) = @_; my ($mask, $channel, $length) = @_;
$channel = lc $channel;
$mask = lc $mask;
if ($mask !~ m/[!@\$]/) { if ($mask !~ m/[!@\$]/) {
my ($message_account, $hostmask) = $self->{pbot}->{messagehistory}->{database}->find_message_account_by_nick($mask); my ($message_account, $hostmask) = $self->{pbot}->{messagehistory}->{database}->find_message_account_by_nick($mask);
if (defined $hostmask) { if (defined $hostmask) {
@ -187,6 +195,8 @@ sub mute_user {
sub unmute_user { sub unmute_user {
my $self = shift; my $self = shift;
my ($mask, $channel) = @_; my ($mask, $channel) = @_;
$mask = lc $mask;
$channel = lc $channel;
$self->{pbot}->{logger}->log("Unmuting $channel $mask\n"); $self->{pbot}->{logger}->log("Unmuting $channel $mask\n");
if($self->{unmute_timeout}->find_index($channel, $mask)) { if($self->{unmute_timeout}->find_index($channel, $mask)) {
$self->{unmute_timeout}->hash->{$channel}->{$mask}{timeout} = gettimeofday + 7200; # try again in 2 hours if unmute doesn't immediately succeed $self->{unmute_timeout}->hash->{$channel}->{$mask}{timeout} = gettimeofday + 7200; # try again in 2 hours if unmute doesn't immediately succeed
@ -200,6 +210,9 @@ sub mute_user_timed {
my $self = shift; my $self = shift;
my ($mask, $channel, $length) = @_; my ($mask, $channel, $length) = @_;
$channel = lc $channel;
$mask = lc $mask;
$mask .= '!*@*' if $mask !~ m/[\$!@]/; $mask .= '!*@*' if $mask !~ m/[\$!@]/;
$self->mute_user($mask, $channel); $self->mute_user($mask, $channel);
if ($length > 0) { if ($length > 0) {
@ -218,6 +231,7 @@ sub join_channel {
$self->{pbot}->{conn}->join($channels); $self->{pbot}->{conn}->join($channels);
foreach my $channel (split /,/, $channels) { foreach my $channel (split /,/, $channels) {
$channel = lc $channel;
$self->{pbot}->{event_dispatcher}->dispatch_event('pbot.join', { channel => $channel }); $self->{pbot}->{event_dispatcher}->dispatch_event('pbot.join', { channel => $channel });
delete $self->{is_opped}->{$channel}; delete $self->{is_opped}->{$channel};
@ -234,6 +248,8 @@ sub join_channel {
sub part_channel { sub part_channel {
my ($self, $channel) = @_; my ($self, $channel) = @_;
$channel = lc $channel;
$self->{pbot}->{event_dispatcher}->dispatch_event('pbot.part', { channel => $channel }); $self->{pbot}->{event_dispatcher}->dispatch_event('pbot.part', { channel => $channel });
$self->{pbot}->{conn}->part($channel); $self->{pbot}->{conn}->part($channel);
@ -243,12 +259,12 @@ sub part_channel {
sub has_ban_timeout { sub has_ban_timeout {
my ($self, $channel, $mask) = @_; my ($self, $channel, $mask) = @_;
return exists $self->{unban_timeout}->hash->{$channel}->{$mask}; return exists $self->{unban_timeout}->hash->{lc $channel}->{lc $mask};
} }
sub has_mute_timeout { sub has_mute_timeout {
my ($self, $channel, $mask) = @_; my ($self, $channel, $mask) = @_;
return exists $self->{unmute_timeout}->hash->{$channel}->{$mask}; return exists $self->{unmute_timeout}->hash->{lc $channel}->{lc $mask};
} }