From 059dc2648801cf53ea7959e15ca2c122a69b8377 Mon Sep 17 00:00:00 2001 From: Pragmatic Software Date: Sat, 1 Feb 2020 22:29:56 -0800 Subject: [PATCH] Plugin/ActionTrigger: improve examples; remove bind_param()s --- Plugins/ActionTrigger.pm | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Plugins/ActionTrigger.pm b/Plugins/ActionTrigger.pm index 17d62444..985ab549 100644 --- a/Plugins/ActionTrigger.pm +++ b/Plugins/ActionTrigger.pm @@ -9,9 +9,14 @@ package Plugins::ActionTrigger; # # Examples: # +# Greet a nick when they join the channel: # actiontrigger add #channel 0 0 ^(?i)([^!]+)![^\s]+.JOIN echo Hi $1, welcome to $channel! -# actiontrigger add global 0 0 ^(?i)([^!]+)![^\s]+.PRIVMSG.*bad_word kick $1 That's a naughty word! -# etc +# +# Kick a nick if they say a naughty thing. +# actiontrigger add global 10 0 "^(?i)([^!]+)![^\s]+.PRIVMSG.*bad phrase" kick $1 That's a naughty word! +# +# Say something when a keyword is seen, but only once every 5 minutes: +# actiontrigger add global 0 300 "some phrase" echo Something! # # These are basic examples; more complex examples can be crafted. @@ -124,9 +129,7 @@ sub delete_trigger { my ($self, $channel, $trigger) = @_; return 0 if not $self->get_trigger($channel, $trigger); my $sth = $self->{dbh}->prepare('DELETE FROM Triggers WHERE channel = ? AND trigger = ?'); - $sth->bind_param(1, lc $channel); - $sth->bind_param(2, $trigger); - $sth->execute(); + $sth->execute(lc $channel, $trigger); return 1; } @@ -142,8 +145,7 @@ sub list_triggers { } else { $sth = $self->{dbh}->prepare('SELECT * FROM Triggers WHERE channel = ?'); } - $sth->bind_param(1, lc $channel); - $sth->execute(); + $sth->execute(lc $channel); return $sth->fetchall_arrayref({}); }; @@ -187,9 +189,7 @@ sub get_trigger { my $row = eval { my $sth = $self->{dbh}->prepare('SELECT * FROM Triggers WHERE channel = ? AND trigger = ?'); - $sth->bind_param(1, lc $channel); - $sth->bind_param(2, $trigger); - $sth->execute(); + $sth->execute(lc $channel, $trigger); my $row = $sth->fetchrow_hashref(); return $row; };