Created
October 13, 2012 19:51
-
-
Save protospork/3885916 to your computer and use it in GitHub Desktop.
cleaned up
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#source: http://www.binrand.com/post/469178-crc-use-strict-use-warnings-use-string-crc32-use-xchat-qw.html (13-Oct-2012) | |
# I don't know who posted this there, but all I did was change the file open syntax (protospork) | |
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; | |
} | |
}; | |
#I don't understand why we're using a timer instead of just standard print, but sure | |
sub delaycommand { | |
my $command = $_[0]; | |
hook_timer( 0, | |
sub { | |
prnt($command); | |
return REMOVE; | |
} | |
); | |
return EAT_NONE; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment