changed to get date if it is required (last speaking time was not today)

This commit is contained in:
lookshe 2011-09-20 23:16:53 +02:00
parent c4b1a82f6b
commit 7d3e3c509d
2 changed files with 6 additions and 8 deletions

View file

@ -10,11 +10,7 @@ proc lastspoke {nick host hand chan arg} {
if {$arg == ""} {
return 0
}
if {[onchan $arg $chan] != 1} {
set output [split "[exec perl /home/eggdrop/eggdrop/scripts/lastspoke.pl /home/eggdrop/eggdrop/logs [string trimleft $chan #] $arg 1]" "\n"]
} else {
set output [split "[exec perl /home/eggdrop/eggdrop/scripts/lastspoke.pl /home/eggdrop/eggdrop/logs [string trimleft $chan #] $arg 0]" "\n"]
}
set output [split "[exec perl /home/eggdrop/eggdrop/scripts/lastspoke.pl /home/eggdrop/eggdrop/logs [string trimleft $chan #] $arg]" "\n"]
foreach out $output {
putserv "PRIVMSG $chan :$out";
}

View file

@ -2,7 +2,7 @@
use File::ReadBackwards;
if ($#ARGV ne 3){
if ($#ARGV ne 2){
print "not enough arguments\n";
exit 1;
}
@ -10,7 +10,6 @@ if ($#ARGV ne 3){
my $folder=$ARGV[0];
my $chan=$ARGV[1];
my $nick=$ARGV[2];
my $printdate=$ARGV[3];
my @files;
@ -22,6 +21,7 @@ foreach $file (@files) {
my $date=0;
my $lastaction;
my $line;
my $datecount=0;
$file=~s/\n$//;
my $log = File::ReadBackwards->new($file) || die $!;
@ -32,9 +32,11 @@ while ($line=$log->readline()){
if ($line =~ m/^\[[0-9]{2}:[0-9]{2}(:[0-9]{2})?\] <$nick> /i && $line !~ m/joined #/ ) {
$date=1;
($lastaction=$line)=~s/\n//;
} elsif ($line =~ m/^\[00:00(:00)?\] --- /) {
++$datecount
}
} else {
if ($printdate eq 0){
if ($datecount eq 0){
print "$nick\'s last action: $lastaction\n";
exit 0;
} else {