diff options
author | David Phillips <david@yeah.nah.nz> | 2018-10-02 19:00:50 +1300 |
---|---|---|
committer | David Phillips <david@yeah.nah.nz> | 2018-10-02 19:03:27 +1300 |
commit | 8c1c7bd5e29f0b4574e65f67091f9ed9d5b53940 (patch) | |
tree | c71a9cf200bddb0355404756313d507dc796f2d6 /Plugin | |
parent | cb5b3397cb7d9f13a0b871314f337cf1631d782c (diff) | |
download | idalius-8c1c7bd5e29f0b4574e65f67091f9ed9d5b53940.tar.xz |
Add Natural.pm for responses to nick mentions
Diffstat (limited to 'Plugin')
-rw-r--r-- | Plugin/Natural.pm | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/Plugin/Natural.pm b/Plugin/Natural.pm new file mode 100644 index 0000000..fabdf0c --- /dev/null +++ b/Plugin/Natural.pm @@ -0,0 +1,57 @@ +package Plugin::Natural; + +use strict; +use warnings; +use threads; + +my $root_config; + +sub configure { + my $self = shift; + shift; # cmdref + shift; # run_command + shift; # module config + $root_config = shift; + + return $self; +} + +#my %language { +# qr/(hi|hello|hey|hiya|morning|sup)/ => ("hey", "how goes it?", "hi") +# qr/(thx|thanks|thank you)/ => ("no problem", "you're welcome"), +# qr/help/ => ("oh no") +#}; + +sub mention_odds { + return 1; +# return int(rand(3)) == 1; +} + +sub some { + my @choices = @_; + return $choices[rand(@choices)]; +} + +sub on_message { + my ($self, $logger, $me, $who, $where, $raw_what, $what, $irc) = @_; + my $nick = (split /!/, $who)[0]; + + return unless $what =~ /\b$root_config->{current_nick}\b/; + return unless mention_odds(); + + if ($what =~ /\b(hi|hey|sup|morning|hello|hiya)\b/i) { + return some("hi $nick", "hey $nick", "sup $nick") . some("", ", how goes it?"); + } elsif ($what =~ /\b(thanks|thx|ta)\b/i) { + return some("don't mention it", "that's ok", ":)", "not a problem"); + } elsif ($what =~ /\b(shush|(shit|shut)(\s+the\s+fuck|)\s+up|stfu)\b/i) { + return some("$nick: shush yourself", "shut up, $nick", "nou $nick", "sorry $nick", ":("); + } elsif ($what =~ /\b(fuck\s+(off?|you|u)|fucking)\b/i) { + return some("$nick: take your meds", "stop harassing me", "ease up on the drink, mate", "ooh big boy angry $nick has come out to play"); + } + return; +} + +sub on_action { + on_message @_; +} +1; |