aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Plugin/Natural.pm25
1 files changed, 19 insertions, 6 deletions
diff --git a/Plugin/Natural.pm b/Plugin/Natural.pm
index fabdf0c..64cc755 100644
--- a/Plugin/Natural.pm
+++ b/Plugin/Natural.pm
@@ -32,12 +32,8 @@ sub some {
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();
+sub choose_response {
+ my ($what, $nick) = @_;
if ($what =~ /\b(hi|hey|sup|morning|hello|hiya)\b/i) {
return some("hi $nick", "hey $nick", "sup $nick") . some("", ", how goes it?");
@@ -51,6 +47,23 @@ sub on_message {
return;
}
+sub on_message {
+ my ($self, $logger, $me, $who, $where, $raw_what, $what, $irc) = @_;
+ my $nick = (split /!/, $who)[0];
+
+ if (ref($where) eq "ARRAY") {
+ $where = $where->[0];
+ }
+
+ return unless $what =~ /\b$root_config->{current_nick}\b/;
+ return unless mention_odds();
+
+ my $response = choose_response($what, $nick);
+ $irc->delay([privmsg => $where => $response], rand(10)) if $response;
+
+ return;
+}
+
sub on_action {
on_message @_;
}