blob: 91e91e57a62cfadb244c69d6b25e5fbf47b80946 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
package Plugin::Titillate;
use strict;
use warnings;
use IdaliusConfig qw/assert_dict/;
my $config;
sub configure {
my $self = shift;
my $cmdref = shift;
shift; # run_command
$config = shift;
IdaliusConfig::assert_dict($config, $self, "triggers");
return $self;
}
sub on_message {
my ($self, $logger, $me, $who, $where, $raw_what, $what, $irc) = @_;
my $gathered = "";
my @expressions = (keys %{$config->{triggers}});
my %responses;
# FIXME still doesn't support overlap like 'foo' with 'fooo'
foreach (@expressions) {
my $e = $_;
while ($what =~ /($e)/gi) {
$responses{$-[0]} .= $config->{triggers}->{$e};
}
}
$gathered .= $responses{$_} foreach (sort { $a <=> $b } (keys %responses));
return $gathered;
}
sub on_action {
on_message(@_);
}
1;
|