aboutsummaryrefslogtreecommitdiff
path: root/Plugin/Titillate.pm
diff options
context:
space:
mode:
authorDavid Phillips <david@sighup.nz>2018-07-29 21:24:53 +1200
committerDavid Phillips <david@sighup.nz>2018-07-29 21:24:53 +1200
commitd1087ccc86af420503d2da1c14cef3f92e794dc3 (patch)
treedb5ff4fbe53326fe55d30232cf0a6567351f268f /Plugin/Titillate.pm
parent90e84e1c774a5e36aaafa7da655c8193218f1f37 (diff)
parente56d58c07ccfe7d3e5ab9439d688259b70d60d95 (diff)
downloadidalius-d1087ccc86af420503d2da1c14cef3f92e794dc3.tar.xz
Merge branch 'master' into admin-command-module
Diffstat (limited to 'Plugin/Titillate.pm')
-rw-r--r--Plugin/Titillate.pm37
1 files changed, 37 insertions, 0 deletions
diff --git a/Plugin/Titillate.pm b/Plugin/Titillate.pm
new file mode 100644
index 0000000..f969df7
--- /dev/null
+++ b/Plugin/Titillate.pm
@@ -0,0 +1,37 @@
+#!/usr/bin/env perl
+
+package Plugin::Titillate;
+
+use strict;
+use warnings;
+
+my %config;
+
+sub configure {
+ my $self = $_[0];
+ my $cmdref = $_[1];
+ my $cref = $_[2];
+ %config = %$cref;
+ return $self;
+}
+
+sub message {
+ my ($self, $logger, $me, $who, $where, $raw_what, $what, $irc) = @_;
+ my $gathered = "";
+ my @expressions = (keys %{$config{triggers}});
+ my $expression = join '|', @expressions;
+ while ($what =~ /($expression)/gi) {
+ my $matched = $1;
+ my $key;
+ # figure out which key matched
+ foreach (@expressions) {
+ if ($matched =~ /$_/i) {
+ $key = $_;
+ last;
+ }
+ }
+ $gathered .= $config{triggers}->{$key};
+ }
+ return $gathered;
+}
+1;