psychoticwolf%carolina.rr.com ba5e59286e Bug 509863 - [MODULE] should linkify crash IDs to crash stats. Module by Cheng Wang <cwwmozilla@gmail.com>, r=Wolf
git-svn-id: svn://10.0.0.236/trunk@260126 18797224-902f-48f8-a5cc-f745e15eee43
2010-04-02 19:37:55 +00:00

40 lines
1.5 KiB
Plaintext
Executable File

#######################################
#
# Linkifies crash stats
# Not elegantly written but very functional
# -- Cww takes all the blame.
#
#######################################
package BotModules::Crashstats;
use vars qw(@ISA);
@ISA = qw(BotModules);
1;
sub Told {
my $self = shift;
my ($event, $message) = @_;
my @array = (); my $output = '';
push @array, $1 while ($message =~ /(?<!http:\/\/crash-stats.mozilla.com\/report\/index\/)(?|(?:bp-)?([a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{8}[01][0-9][0-3][0-9])|(?:bp-)?([a-f0-9]{8}-[a-f0-9]{4}-11dd-[a-f0-9]{4}-[a-f0-9]{12}))/osig);
if ($#array > -1) {
$output .= 'http://crash-stats.mozilla.com/report/index/'.$_.' ' foreach (@array);
$self->say($event, $event->{'from'}.': '.$output);
} else {
return $self->SUPER::Told(@_);
}
return 0; # we've dealt with it, no need to do anything else.
}
sub Heard {
my $self = shift;
my ($event, $message) = @_;
my @array = (); my $output = '';
push @array, $1 while ($message =~ /(?<!http:\/\/crash-stats.mozilla.com\/report\/index\/)(?|(?:bp-)?([a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{8}[01][0-9][0-3][0-9])|(?:bp-)?([a-f0-9]{8}-[a-f0-9]{4}-11dd-[a-f0-9]{4}-[a-f0-9]{12}))/osig);
if ($#array > -1) {
$output .= 'http://crash-stats.mozilla.com/report/index/'.$_.' ' foreach (@array);
$self->say($event, $event->{'from'}.': '.$output);
}
return $self->SUPER::Heard(@_);
}