use strict;
use warnings;
use String::CRC32;
use Xchat qw( :all );
register('CRC Check Script', '1.0', 'Check CRC');
hook_print('DCC RECV Complete', \&check_crc);
sub check_crc {
my $filename = $_[0][0];
my $filepath = $_[0][1];
if ($_[0][0] =~ /([a-fA-F0-9]{8})/){
open(SOMEFILE, $filepath);
binmode SOMEFILE;
my $crc = crc32(*SOMEFILE);
close(SOMEFILE);
my $hexval = uc(sprintf("%x", $crc));
if ($filename =~ $hexval) {
delaycommand("CRC is \00303OK!");
} else {
delaycommand("CRC is \00306NOT OK! - " .$hexval);
}
return EAT_NONE;
}
};
sub delaycommand {
my $command = $_[0];
hook_timer( 0,
sub {
prnt($command);
return REMOVE;
}
);
return EAT_NONE;
}