masked special characters only for searchstring and not for outputs

This commit is contained in:
lookshe 2012-01-11 09:15:06 +01:00
parent 38252cc554
commit d45663caaa
3 changed files with 24 additions and 21 deletions

View file

@ -9,9 +9,10 @@ if ($#ARGV ne 2){
my $chan=$ARGV[1]; my $chan=$ARGV[1];
my $folder=$ARGV[0]; my $folder=$ARGV[0];
my $nick=$ARGV[2]; my $nick=$ARGV[2];
$nick=~s/\\/\\\\/g; my $snick=$nick;
$nick=~s/\|/\\\|/g; $snick=~s/\\/\\\\/g;
$nick=~s/\^/\\\^/g; $snick=~s/\|/\\\|/g;
$snick=~s/\^/\\\^/g;
my @files; my @files;
@ -24,7 +25,7 @@ my $line;
open(file, $file) or die("Could not open file $file"); open(file, $file) or die("Could not open file $file");
foreach $line (<file>) { foreach $line (<file>) {
if ($line =~ m/^\[[0-9]{2}:[0-9]{2}(:[0-9]{2})?\] (Action: )?<?$nick>? /i) { if ($line =~ m/^\[[0-9]{2}:[0-9]{2}(:[0-9]{2})?\] (Action: )?<?$snick>? /i) {
if ($date =~ /^irgendwas$/) { if ($date =~ /^irgendwas$/) {
print "$nick belongs to inventory\n"; print "$nick belongs to inventory\n";
exit 0; exit 0;
@ -37,8 +38,8 @@ foreach $line (<file>) {
if ($line =~ m/^\[00:00(:00)?\] --- /){ if ($line =~ m/^\[00:00(:00)?\] --- /){
($date=$line)=~s/^\[00:00(:00)?\] --- (.*)\n/$2/; ($date=$line)=~s/^\[00:00(:00)?\] --- (.*)\n/$2/;
} }
if ($line =~ m/^\[[0-9]{2}:[0-9]{2}(:[0-]{2})?\] Nick change: .* -> $nick/i) { if ($line =~ m/^\[[0-9]{2}:[0-9]{2}(:[0-]{2})?\] Nick change: .* -> $snick/i) {
($newnick=$line)=~s/.* Nick change: (.*) -> $nick\n/$1/i; ($newnick=$line)=~s/.* Nick change: (.*) -> $snick\n/$1/i;
print "$nick was $newnick\n"; print "$nick was $newnick\n";
exec($^X, $0, $folder, $chan, $newnick); exec($^X, $0, $folder, $chan, $newnick);
exit 0 exit 0

View file

@ -10,9 +10,10 @@ if ($#ARGV ne 2){
my $chan=$ARGV[1]; my $chan=$ARGV[1];
my $folder=$ARGV[0]; my $folder=$ARGV[0];
my $nick=$ARGV[2]; my $nick=$ARGV[2];
$nick=~s/\\/\\\\/g; my $snick=$nick;
$nick=~s/\|/\\\|/g; $snick=~s/\\/\\\\/g;
$nick=~s/\^/\\\^/g; $snick=~s/\|/\\\|/g;
$snick=~s/\^/\\\^/g;
my @files; my @files;
@ -31,7 +32,7 @@ my $log = File::ReadBackwards->new($file) || die $!;
while ($line=$log->readline()){ while ($line=$log->readline()){
# $line=$log->readline(); # $line=$log->readline();
if ($date eq 0){ if ($date eq 0){
if ($line =~ m/^\[[0-9]{2}:[0-9]{2}(:[0-9]{2})?\]( Nick change:)? $nick /i && $line !~ m/joined #/ ) { if ($line =~ m/^\[[0-9]{2}:[0-9]{2}(:[0-9]{2})?\]( Nick change:)? $snick /i && $line !~ m/joined #/ ) {
$date=1; $date=1;
$lastaction=$line; $lastaction=$line;
} }
@ -39,23 +40,23 @@ while ($line=$log->readline()){
if ($line =~ m/^\[00:00(:00)?\] --- /){ if ($line =~ m/^\[00:00(:00)?\] --- /){
($date=$line)=~s/^\[00:00(:00)?\] --- (.*)\n/$2/; ($date=$line)=~s/^\[00:00(:00)?\] --- (.*)\n/$2/;
($time=$lastaction)=~s/(.*)\[([0-9]{2}:[0-9]{2}(:[0-9]{2})?)\](.*)\n/$2/; ($time=$lastaction)=~s/(.*)\[([0-9]{2}:[0-9]{2}(:[0-9]{2})?)\](.*)\n/$2/;
$l=9+length($nick); $l=9+length($snick);
$k=12+length($nick); $k=12+length($snick);
if ($lastaction=~m/^.{$l}kicked/ || $lastaction=~m/.{$k}kicked/){ if ($lastaction=~m/^.{$l}kicked/ || $lastaction=~m/.{$k}kicked/){
($by=$lastaction)=~s/^\[[0-9]{2}:[0-9]{2}(:[0-9]{2})?\] $nick kicked from #.* by //i; ($by=$lastaction)=~s/^\[[0-9]{2}:[0-9]{2}(:[0-9]{2})?\] $snick kicked from #.* by //i;
($reason=$by)=~s/.*: (.*)\n/$1/; ($reason=$by)=~s/.*: (.*)\n/$1/;
$by=~s/:.*\n//i; $by=~s/:.*\n//i;
print "$nick was kicked by $by on $date at $time reason: $reason\n"; print "$nick was kicked by $by on $date at $time reason: $reason\n";
} elsif ($lastaction=~m/$nick \(.*\) left irc: /i){ } elsif ($lastaction=~m/$snick \(.*\) left irc: /i){
($message=$lastaction)=~s/^.* $nick \(.*\) left irc: (.*)\n/$1/i; ($message=$lastaction)=~s/^.* $snick \(.*\) left irc: (.*)\n/$1/i;
print "$nick has quit on $date at $time saying: $message\n"; print "$nick has quit on $date at $time saying: $message\n";
} elsif ($lastaction=~m/Nick change: $nick /i) { } elsif ($lastaction=~m/Nick change: $nick /i) {
($newnick=$lastaction)=~s/^.*Nick change: $nick -> (.*)\n/$1/i; ($newnick=$lastaction)=~s/^.*Nick change: $snick -> (.*)\n/$1/i;
print "$nick changed his name to $newnick on $date at $time\n"; print "$nick changed his name to $newnick on $date at $time\n";
} else { } else {
if ($lastaction=~m/\)\.$/) { if ($lastaction=~m/\)\.$/) {
($message=$lastaction)=~s/^.* $nick \(.*\) left #[a-zA-Z0-9]* \((.*)\)\.\n/$1/i; ($message=$lastaction)=~s/^.* $snick \(.*\) left #[a-zA-Z0-9]* \((.*)\)\.\n/$1/i;
print "$nick has left on $date at $time saying: $message\n"; print "$nick has left on $date at $time saying: $message\n";
} else { } else {
print "$nick has left on $date at $time\n"; print "$nick has left on $date at $time\n";

View file

@ -10,9 +10,10 @@ if ($#ARGV ne 2){
my $folder=$ARGV[0]; my $folder=$ARGV[0];
my $chan=$ARGV[1]; my $chan=$ARGV[1];
my $nick=$ARGV[2]; my $nick=$ARGV[2];
$nick=~s/\\/\\\\/g; my $snick=$nick;
$nick=~s/\|/\\\|/g; $snick=~s/\\/\\\\/g;
$nick=~s/\^/\\\^/g; $snick=~s/\|/\\\|/g;
$snick=~s/\^/\\\^/g;
my @files; my @files;
@ -32,7 +33,7 @@ my $log = File::ReadBackwards->new($file) || die $!;
while ($line=$log->readline()){ while ($line=$log->readline()){
# $line=$log->readline(); # $line=$log->readline();
if ($date eq 0){ if ($date eq 0){
if ($line =~ m/^\[[0-9]{2}:[0-9]{2}(:[0-9]{2})?\] <$nick> /i && $line !~ m/joined #/ ) { if ($line =~ m/^\[[0-9]{2}:[0-9]{2}(:[0-9]{2})?\] <$snick> /i && $line !~ m/joined #/ ) {
$date=1; $date=1;
($lastaction=$line)=~s/\n//; ($lastaction=$line)=~s/\n//;
} elsif ($line =~ m/^\[00:00(:00)?\] --- /) { } elsif ($line =~ m/^\[00:00(:00)?\] --- /) {