3
0
mirror of https://github.com/pragma-/pbot.git synced 2024-11-27 06:19:25 +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 ($self, $channel) = @_;
my $triggers = eval { 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->bind_param(1, lc $channel);
$sth->execute(); $sth->execute();
return $sth->fetchall_arrayref({}); return $sth->fetchall_arrayref({});
@ -333,7 +340,7 @@ sub check_trigger {
return 0; 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'); my @globals = $self->list_triggers('global');
push @triggers, @globals; push @triggers, @globals;