diff --git a/lib/Bot/BasicBot/Pluggable/Module/DirkMod.pm b/lib/Bot/BasicBot/Pluggable/Module/DirkMod.pm index 908cebd..81d48a7 100644 --- a/lib/Bot/BasicBot/Pluggable/Module/DirkMod.pm +++ b/lib/Bot/BasicBot/Pluggable/Module/DirkMod.pm @@ -70,7 +70,7 @@ sub optipeep { my $l = length($input); - print "CHECKING $input $peep\n"; + #print "CHECKING $input $peep\n"; my $min = [length($peep)*10, $peep]; # set maxes for my $p (0..length($peep)-length($input)) { @@ -85,6 +85,15 @@ sub optipeep { return $min } +sub get_seen { + my ($self, $user) = @_; + my $seen = $self->bot->module("Seen"); + + my $out = $seen->told("seen ".$user); + + return $out; +} + sub get_player_pos { my ($user) = @_; @@ -109,7 +118,7 @@ sub get_player_pos { my @peeps = keys %{$playerstate->{players}}; my $peep = reduce {$a->[0] > $b->[0] ? $b : $a} map {optipeep($_, $user)} @peeps; - print Dumper($peep); + #print Dumper($peep); $user = $peep->[1] if ($peep->[0] < 5); # don't set it if it's too large if (exists($playerstate->{players}{lc $user})) { # we know where that user was @@ -137,7 +146,7 @@ sub get_player_pos { my $counter = 0; sub tick { # called every 5 seconds my $self = shift; # get ourself, duh - + unless ($counter++ % 48) {# every 4 minutes, 48 * 5 seconds, send the message my $mess = {body => "to_wanderer", who => "automatic", @@ -175,6 +184,7 @@ sub told { sub fallback { my ( $self, $mess ) = @_; + my $seen = $self->bot->module("Seen"); my $body = $mess->{body} || ""; my $is_priv = !defined $mess->{channel} || $mess->{channel} eq 'msg'; @@ -185,10 +195,27 @@ sub fallback { $user = $1; } + #23:05:18 < dirkocraft> [XmasPteradactyl disconnected] + #23:05:21 < dirkocraft> [CaveScavenger disconnected] + if ($mess->{who} =~ /^dirkocraft\d*$/ && $body =~ /\[(\S+) disconnected\]/) { + $seen->update_seen($1, "Minecraft", "losing the game"); + } + elsif ($mess->{who} =~ /^dirkocraft\d*$/ && $body =~ /\[(\S+) connected\]/) { + $seen->update_seen($1, "Minecraft", "winning the game") + } + else { + $seen->update_seen($user, "Minecraft", "saying '".$body."'"); # update people! + } + if ($body =~ /^!coords\s+(.*)/i) { # TODO ok this isn't robust, but it'll work for now $user = $1; $body = "!coords"; # rewrite the body }; + + if ($body =~ /^!seen\s+(.*)/i) { # TODO ok this isn't robust, but it'll work for now + $user = $1; + $body = "!seen"; # rewrite the body + }; # request starts with "my", so we'll look for # a valid factoid for "$mess->{who}'s $object". @@ -237,6 +264,7 @@ sub fallback { $factoid =~ s/\$who/$mess->{who}/ig; $factoid =~ s/\$coords/get_player_pos($user)/eig; + $factoid =~ s/\$seen/get_seen($self,$user)/eig; if ($factoid =~ /\$alert\$/i && $mess->{channel} =~ /dirkocraft$/i) { # if we see $ALERT$ and we're in the main channel $mess->{channel} = "#dirkocraft-alert"; diff --git a/main.pl b/main.pl index a5d0497..b14708c 100755 --- a/main.pl +++ b/main.pl @@ -21,6 +21,7 @@ my $bot = Bot::BasicBot::Pluggable->new( ); my $info = $bot->load("DirkMod"); +my $seen = $bot->load("Seen"); $info->set(user_require_question => 0); $info->set(user_passive_answer => 1); $info->set(user_allow_searching =>1);