diff options
author | lookshe <mail@lookshe.org> | 2011-09-20 23:16:53 +0200 |
---|---|---|
committer | lookshe <mail@lookshe.org> | 2011-09-20 23:16:53 +0200 |
commit | 7d3e3c509d20addb32ab6701155b35a7023d3b4d (patch) | |
tree | a5de439b21c973766af5aed1ac812cb560ec4b35 | |
parent | c4b1a82f6b3ece544da0b6f42825b549aa6ac6f2 (diff) |
changed to get date if it is required (last speaking time was not today)
-rw-r--r-- | lastseen.tcl | 6 | ||||
-rw-r--r-- | lastspoke.pl | 8 |
2 files changed, 6 insertions, 8 deletions
diff --git a/lastseen.tcl b/lastseen.tcl index 8733c61..d82a135 100644 --- a/lastseen.tcl +++ b/lastseen.tcl @@ -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"; } diff --git a/lastspoke.pl b/lastspoke.pl index 9ccf5d9..0661744 100644 --- a/lastspoke.pl +++ b/lastspoke.pl @@ -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 { |