3
0
mirror of https://github.com/pragma-/pbot.git synced 2024-10-03 01:48:38 +02:00

Added cc diff command

This commit is contained in:
Pragmatic Software 2013-08-22 20:41:54 +00:00
parent 0e783365d1
commit 36e48cb703
2 changed files with 17 additions and 2 deletions

View File

@ -13,8 +13,8 @@ use warnings;
# These are set automatically by the build/commit script
use constant {
BUILD_NAME => "PBot",
BUILD_REVISION => 421,
BUILD_DATE => "2013-08-16",
BUILD_REVISION => 422,
BUILD_DATE => "2013-08-22",
};
1;

View File

@ -180,6 +180,21 @@ if($code =~ m/^\s*show\s*$/i) {
exit 0;
}
if($code =~ m/^\s*diff\s*$/i) {
if($#last_code < 1) {
print "$nick: Not enough recent code to diff.\n"
} else {
use Text::WordDiff;
my $diff = word_diff \$last_code[1], \$last_code[0], { STYLE => 'MARKUP' };
$diff =~ s/<del>(.*?)<\/del><ins>(.*?)<\/ins>/<replaced `$1` with `$2`>/g;
$diff =~ s/<del>(.*?)<\/del>/<removed `$1`>/g;
$diff =~ s/<ins>(.*?)<\/ins>/<inserted `$1`>/g;
print "$nick: $diff\n";
}
exit 0;
}
my $got_run = undef;
if($code =~ m/^\s*(run|paste)\s*$/i) {