Skip to content

Commit

Permalink
Allow blocking "say" feature with a new plugin
Browse files Browse the repository at this point in the history
Let's say this resolves zigdon#90, and if "say" is eventually removed from core
and put into a plugin then that can replace this one.
  • Loading branch information
dgw committed Apr 27, 2017
1 parent 071e792 commit 3492a8d
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions plugins/plugin.nosay.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# BUCKET PLUGIN

use BucketBase qw/cached_reply Log/;

sub signals {
return (qw/on_public/)
}

sub route {
my ( $package, $sig, $data ) = @_;

if ( $sig eq 'on_public' ) {
# first check if the line looks like teaching a factoid
if ( $data->{msg} =~ /(.*?) (?:is ?|are ?)(<\w+>)\s*(.*)()/i
or $data->{msg} =~ /(.*?)\s+(<\w+(?:'t)?>)\s*(.*)()/i
or $data->{msg} =~ /(.*?)(<'s>)\s+(.*)()/i
or $data->{msg} =~ /(.*?)\s+(is(?: also)?|are)\s+(.*)/i ) {
return 0; # if it looks like teaching, let processing continue
# then if not, check if it would trigger the 'say' function
} elsif ( $data->{msg} =~ /^say (.*)/i ) {
if ( $data->{addressed} ) {
&cached_reply( $data->{chl}, $data->{who}, "", "don't know" );
}
Log "$data->{who} tried to trigger 'say' in $data->{chl}; ignoring.";
return 1; # Halting core prevents default behavior, but plugins should (probably?) be allowed to continue
}
}

return 0;
}

0 comments on commit 3492a8d

Please sign in to comment.