2007-05-20 22:44:44 +02:00
|
|
|
#!/usr/bin/perl -w
|
|
|
|
|
2017-03-05 22:33:31 +01:00
|
|
|
# This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
|
2007-05-20 22:44:44 +02:00
|
|
|
use strict;
|
|
|
|
|
2019-05-28 18:19:42 +02:00
|
|
|
if ($#ARGV != 0)
|
2007-05-20 22:44:44 +02:00
|
|
|
{
|
|
|
|
print "Usage: !seen nick\n";
|
|
|
|
exit 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
my $nick = $ARGV[0];
|
|
|
|
|
|
|
|
my $file = "/home/msmud/irclogs/freenode/##c.log";
|
|
|
|
|
|
|
|
open(FILE, "< $file")
|
|
|
|
or die "Can't open $file for reading: $!\n";
|
|
|
|
|
|
|
|
seek(FILE, 0, 2); # seek to end of file
|
|
|
|
|
|
|
|
my $pos = tell(FILE) - 2;
|
|
|
|
my $char;
|
|
|
|
my $result;
|
|
|
|
|
2019-05-28 18:19:42 +02:00
|
|
|
while (seek(FILE, $pos--, 0))
|
2007-05-20 22:44:44 +02:00
|
|
|
{
|
|
|
|
read(FILE, $char, 1);
|
2019-05-28 18:19:42 +02:00
|
|
|
if ($char eq "\n")
|
2007-05-20 22:44:44 +02:00
|
|
|
{
|
|
|
|
my $line = <FILE>;
|
|
|
|
chomp $line;
|
|
|
|
|
|
|
|
next if not defined $line;
|
|
|
|
|
2019-05-28 18:19:42 +02:00
|
|
|
if ($line =~ m/^(\d\d:\d\d) -!- $nick (.*?)$/i)
|
2007-05-20 22:44:44 +02:00
|
|
|
{
|
2019-06-26 18:34:19 +02:00
|
|
|
$result = "date at $1: $nick $2\n";
|
2007-05-20 22:44:44 +02:00
|
|
|
}
|
2019-05-28 18:19:42 +02:00
|
|
|
elsif ($line =~ m/^(\d\d:\d\d) <\s*$nick> (.*?)$/i)
|
2007-05-20 22:44:44 +02:00
|
|
|
{
|
|
|
|
$result = "date at $1: <$nick> $2\n";
|
|
|
|
}
|
2019-05-28 18:19:42 +02:00
|
|
|
elsif ($line =~ m/^(\d\d:\d\d) * $nick (.*?)$/i)
|
2007-05-20 22:44:44 +02:00
|
|
|
{
|
|
|
|
$result = "date at $1: $nick $2\n";
|
|
|
|
}
|
|
|
|
last if defined $result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-05-28 18:19:42 +02:00
|
|
|
if (defined $result)
|
2007-05-20 22:44:44 +02:00
|
|
|
{
|
|
|
|
my $date;
|
|
|
|
|
2019-05-28 18:19:42 +02:00
|
|
|
while (seek(FILE, $pos--, 0))
|
2007-05-20 22:44:44 +02:00
|
|
|
{
|
|
|
|
read(FILE, $char, 1);
|
2019-05-28 18:19:42 +02:00
|
|
|
if ($char eq "\n")
|
2007-05-20 22:44:44 +02:00
|
|
|
{
|
|
|
|
my $line = <FILE>;
|
|
|
|
chomp($line);
|
|
|
|
|
2019-05-28 18:19:42 +02:00
|
|
|
if ($line =~ m/^--- Log opened (.*?) \d\d:\d\d:\d\d(.*?)$/)
|
2007-05-20 22:44:44 +02:00
|
|
|
{
|
|
|
|
$date = $1 . $2;
|
|
|
|
last;
|
|
|
|
}
|
2019-05-28 18:19:42 +02:00
|
|
|
elsif ($line =~ m/^--- Day changed (.*?)$/)
|
2007-05-20 22:44:44 +02:00
|
|
|
{
|
|
|
|
$date = $1;
|
|
|
|
last;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$result =~ s/^date/$date/;
|
|
|
|
print $result;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
print "I haven't seen $nick.\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
close(FILE);
|