From cd1fc57841deab0e9b8bcfad49d527c6b263534c Mon Sep 17 00:00:00 2001 From: David Phillips Date: Tue, 10 Apr 2018 15:20:24 +1200 Subject: Correct capitalisation on module names --- Plugin/Tittilate.pm | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 Plugin/Tittilate.pm (limited to 'Plugin/Tittilate.pm') diff --git a/Plugin/Tittilate.pm b/Plugin/Tittilate.pm new file mode 100644 index 0000000..b2c2286 --- /dev/null +++ b/Plugin/Tittilate.pm @@ -0,0 +1,37 @@ +#!/usr/bin/env perl + +package Plugin::Tittilate; + +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; -- cgit v1.1