diff options
-rw-r--r-- | bot.conf.example | 3 | ||||
-rwxr-xr-x | saxrobot | 17 | ||||
-rw-r--r-- | sb_config.pm | 2 |
3 files changed, 13 insertions, 9 deletions
diff --git a/bot.conf.example b/bot.conf.example index ab0de2e..86204f8 100644 --- a/bot.conf.example +++ b/bot.conf.example @@ -7,5 +7,4 @@ ignore = trumpetbot,abusiveuser password = pleffquiffle admins = snargle!~kleg@glarg.example.com must_id = 1 -re = sa+x, tr+u, l+e+n+y -rep = 🎷, 🎺, ( ͡° ͜ʖ ͡°) +triggers = 'sa+x' => '🎷 ', 'trumpet' => '🎺 ', 'lenny' => '( ͡° ͜ ʖ ͡° ) ' @@ -83,15 +83,20 @@ sub irc_public { my $me = $irc->nick_name; - # FIXME tidy this loop: do we need $idx? - my $idx = 0; - for (@{$config{re}}) { - my $repcount = () = $what =~ /@{$config{re}}[$idx]/gi; + my $collected_response = ""; + for (@{$config{triggers}}) { + my ($match, $response) = split /=>/; + # strip quotes + $match =~ s/^[^']*'|'[^']*$//g; + $response =~ s/^[^']*'|'[^']*$//g; + + # do the count + my $repcount = () = $what =~ /$match/gi; if ($repcount > 0) { - $irc->yield(privmsg => $channel => @{$config{rep}}[$idx] x $repcount); + $collected_response .= $response x $repcount; } - $idx++; } + $irc->yield(privmsg => $channel => $collected_response) if $collected_response; return; } diff --git a/sb_config.pm b/sb_config.pm index 618b616..5440f0c 100644 --- a/sb_config.pm +++ b/sb_config.pm @@ -9,7 +9,7 @@ use Config::Tiny; sub parse_config { my @scalar_configs = ('nick', 'username', 'ircname', 'server', 'port', 'password', 'must_id'); - my @list_configs = ('channels', 'ignore', 'admins', 're', 'rep' ); + my @list_configs = ('channels', 'ignore', 'admins', 'triggers'); my $file = $_[0]; my %built_config; my $config = Config::Tiny->read($file); |