3
0
mirror of https://github.com/pragma-/pbot.git synced 2024-12-23 19:22:40 +01:00

ActionTrigger: Properly handle QUITs

This commit is contained in:
Pragmatic Software 2018-02-03 16:06:42 -08:00
parent 49866fd0d2
commit c5e5b9768f

View File

@ -129,7 +129,14 @@ sub list_triggers {
my ($self, $channel) = @_;
my $triggers = eval {
my $sth = $self->{dbh}->prepare('SELECT * FROM Triggers WHERE channel = ?');
my $sth;
if ($channel eq '*') {
$sth = $self->{dbh}->prepare('SELECT * FROM Triggers WHERE channel != ?');
$channel = 'global';
} else {
$sth = $self->{dbh}->prepare('SELECT * FROM Triggers WHERE channel = ?');
}
$sth->bind_param(1, lc $channel);
$sth->execute();
return $sth->fetchall_arrayref({});
@ -333,7 +340,7 @@ sub check_trigger {
return 0;
}
my @triggers = $self->list_triggers($channel);
my @triggers = $text =~ m/^QUIT/ ? $self->list_triggers('*') : $self->list_triggers($channel);
my @globals = $self->list_triggers('global');
push @triggers, @globals;