summaryrefslogtreecommitdiffstats
path: root/firstseen.pl
blob: 859ffa2fb793886931640e0b00e441c943f00393 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/usr/bin/perl


if ($#ARGV ne 2){
   print "not enough arguments\n";
   exit 1;
}

my $chan=$ARGV[1];
my $folder=$ARGV[0];
my $nick=$ARGV[2];
$nick=~s/\\/\\\\/g;
$nick=~s/\|/\\\|/g;

my @files;

push @files, `ls $folder/$chan.* | sort`;

foreach $file (@files) {

my $date="irgendwas";
my $line;

open(file, $file) or die("Could not open file $file");
foreach $line (<file>) {
      if ($line =~ m/^\[[0-9]{2}:[0-9]{2}(:[0-9]{2})?\] (Action: )?<?$nick>? /i) {
         if ($date =~ /^irgendwas$/) {
            print "$nick belongs to inventory\n";
            exit 0;
         } else {
            ($time=$line)=~s/([^:]*)([0-9]{2}:[0-9]{2})(:[0-9]{2})?(.*)\n/$2/;
            print "$nick was first seen on $date at $time\n";
            exit 0;
         }
      }
      if ($line =~ m/^\[00:00(:00)?\] --- /){
         ($date=$line)=~s/^\[00:00(:00)?\] --- (.*)\n/$2/;
      }
      if ($line =~ m/^\[[0-9]{2}:[0-9]{2}(:[0-]{2})?\] Nick change: .* -> $nick/i) {
         ($newnick=$line)=~s/.* Nick change: (.*) -> $nick\n/$1/i;
         print "$nick was $newnick\n";
         exec($^X, $0, $folder, $chan, $newnick);
         exit 0
      }
}
}

print "I do not remember $nick\n";