зеркало из https://github.com/mozilla/gecko-dev.git
Change the // forms to m// forms. Comment some of the regexps. Allow multiple bugs to be caught on one line. b=76910, r=kerz.
This commit is contained in:
Родитель
672a8db99a
Коммит
90b08ac487
|
@ -1,3 +1,4 @@
|
||||||
|
# -*- Mode: perl; tab-width: 4; indent-tabs-mode: nil; -*-
|
||||||
################################
|
################################
|
||||||
# Bugzilla Module #
|
# Bugzilla Module #
|
||||||
################################
|
################################
|
||||||
|
@ -48,19 +49,31 @@ sub Help {
|
||||||
sub Told {
|
sub Told {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
my ($event, $message) = @_;
|
my ($event, $message) = @_;
|
||||||
if ($message =~ /^\s*(?:please\s+)?(?:(?:could\s+you\s+)?(?:please\s+)?show\s+me\s+|what\s+is\s+|what's\s+)?bug(?:\s*id)?s?[#\s]+([0-9].*?|&.+?)(?:\s+please)?[?!.]*\s*$/osi) {
|
if ($message =~ m/^ \s* # some optional whitespace
|
||||||
|
(?:please\s+)? # an optional "please", followed optionally by either:
|
||||||
|
(?: (?:could\s+you\s+)? # 1. an optional "could you",
|
||||||
|
(?:please\s+)? # another optional "please",
|
||||||
|
show\s+me\s+ | # and the text "show me"
|
||||||
|
what\s+is\s+ | # 2. the text "what is"
|
||||||
|
what\'s\s+ )? # 3. or the text "what's"
|
||||||
|
bug (?:\s*id)?s? [\#\s]+ # a variant on "bug", "bug id", "bugids", etc
|
||||||
|
([0-9].*?| # a query string, either a number followed by some optional text, or
|
||||||
|
&.+?) # a query string, starting with a &.
|
||||||
|
(?:\s+please)? # followed by yet another optional "please"
|
||||||
|
[?!.\s]* # ending with some optional punctuation
|
||||||
|
$/osix) {
|
||||||
my $target = $event->{'target'};
|
my $target = $event->{'target'};
|
||||||
my $bug = $1;
|
my $bug = $1;
|
||||||
$self->FetchBug($event, $bug, 'bugs', 0, 0);
|
$self->FetchBug($event, $bug, 'bugs', 0, 0);
|
||||||
$self->{'bugsHistory'}->{$target}->{$bug} = time() if $bug =~ /^[0-9]+$/os;
|
$self->{'bugsHistory'}->{$target}->{$bug} = time() if $bug =~ m/^[0-9]+$/os;
|
||||||
} elsif ($message =~ /^\s*bug-?total\s+(.+?)\s*$/osi) {
|
} elsif ($message =~ m/^\s*bug-?total\s+(.+?)\s*$/osi) {
|
||||||
$self->FetchBug($event, $1, 'total', 0, 0);
|
$self->FetchBug($event, $1, 'total', 0, 0);
|
||||||
} elsif ($self->isAdmin($event)) {
|
} elsif ($self->isAdmin($event)) {
|
||||||
if ($message =~ /^\s*mute\s+bugzilla\s+in\s+(\S+?)\s*$/osi) {
|
if ($message =~ m/^\s*mute\s+bugzilla\s+in\s+(\S+?)\s*$/osi) {
|
||||||
$self->{'mutes'} .= " $1";
|
$self->{'mutes'} .= " $1";
|
||||||
$self->saveConfig();
|
$self->saveConfig();
|
||||||
$self->say($event, "$event->{'from'}: Watching for bug numbers disabled in channel $1.");
|
$self->say($event, "$event->{'from'}: Watching for bug numbers disabled in channel $1.");
|
||||||
} elsif ($message =~ /^\s*unmute\s+bugzilla\s+in\s+(\S+)\s*$/osi) {
|
} elsif ($message =~ m/^\s*unmute\s+bugzilla\s+in\s+(\S+)\s*$/osi) {
|
||||||
my %mutedChannels = map { $_ => 1 } split(/ /o, $self->{'mutes'});
|
my %mutedChannels = map { $_ => 1 } split(/ /o, $self->{'mutes'});
|
||||||
delete($mutedChannels{$1}); # get rid of any mentions of that channel
|
delete($mutedChannels{$1}); # get rid of any mentions of that channel
|
||||||
$self->{'mutes'} = join(' ', keys(%mutedChannels));
|
$self->{'mutes'} = join(' ', keys(%mutedChannels));
|
||||||
|
@ -78,28 +91,48 @@ sub Told {
|
||||||
sub CheckForBugs {
|
sub CheckForBugs {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
my ($event, $message) = @_;
|
my ($event, $message) = @_;
|
||||||
my $bug;
|
if ((($event->{'channel'} eq '') or # either it was /msg'ed, or
|
||||||
my $skipURI;
|
($self->{'mutes'} !~ m/^(?:.*\s|)\Q$event->{'channel'}\E(?:|\s.*)$/si)) and # it was sent on a channel in which we aren't muted
|
||||||
if ($message =~ /^(?:.*[]\s,.;:\\\/=?!()<>{}[-])?bug[\s#]*([0-9]+)(?:[]\s,.;:\\\/=?!()<>{}[-].*)?$/osi) {
|
(not $self->ignoringCommentsFrom($event->{'from'})) and # we aren't ignoring them
|
||||||
$bug = $1;
|
(not $self->ignoringCommentsTo($message))) { # and they aren't talking to someone we need to ignore
|
||||||
$skipURI = 0;
|
my $rest = $message;
|
||||||
} elsif ($message =~ /\Q$self->{'bugsURI'}\Eshow_bug.cgi\?id=([0-9]+)(?:[^0-9&].*)?$/si) {
|
my $bugsFound = 0;
|
||||||
$bug = $1;
|
my $bugsToFetch = '';
|
||||||
$skipURI = 1;
|
my $bug;
|
||||||
}
|
my $skipURI;
|
||||||
if (($bug) and ((not $event->{'channel'}) or ($self->{'mutes'} !~ /^(.*\s|)\Q$event->{'channel'}\E(|\s.*)$/si)) and
|
do {
|
||||||
(not $self->ignoringCommentsFrom($event->{'from'})) and (not $self->ignoringCommentsTo($message))) {
|
if ($rest =~ m/ (?:^| # either the start of the string
|
||||||
$self->debug("Noticed someone mention bug $bug -- investigating...");
|
[]\s,.;:\\\/=?!()<>{}[-]) # or some punctuation
|
||||||
my $last = 0;
|
bug [\s\#]* ([0-9]+) # followed a string similar to "bug # 123" (put the number in $1)
|
||||||
$last = $self->{'bugsHistory'}->{$event->{'target'}}->{$bug} if defined($self->{'bugsHistory'}->{$event->{'target'}}->{$bug});
|
(?:[]\s,.;:\\\/=?!()<>{}[-]+ # followed optionally by some punctuation,
|
||||||
if ((time()-$last) > $self->{'backoffTime'}) {
|
(.*))?$/osix) { # and everything else (which we put in $2)
|
||||||
$self->FetchBug($event, $bug, 'bugs', $skipURI, 1);
|
$bug = $1;
|
||||||
|
$skipURI = 0;
|
||||||
|
$rest = $2;
|
||||||
|
} elsif ($rest =~ m/\Q$self->{'bugsURI'}\Eshow_bug.cgi\?id=([0-9]+)(?:[^0-9&](.*))?$/si) {
|
||||||
|
$bug = $1;
|
||||||
|
$skipURI = 1;
|
||||||
|
$rest = $2;
|
||||||
|
} else {
|
||||||
|
$bug = undef;
|
||||||
|
}
|
||||||
|
if (defined($bug)) {
|
||||||
|
$self->debug("Noticed someone mention bug $bug -- investigating...");
|
||||||
|
my $last = 0;
|
||||||
|
$last = $self->{'bugsHistory'}->{$event->{'target'}}->{$bug} if defined($self->{'bugsHistory'}->{$event->{'target'}}->{$bug});
|
||||||
|
if ((time()-$last) > $self->{'backoffTime'}) {
|
||||||
|
$bugsToFetch .= "$bug ";
|
||||||
|
}
|
||||||
|
$self->{'bugsHistory'}->{$event->{'target'}}->{$bug} = time();
|
||||||
|
$bugsFound++;
|
||||||
|
}
|
||||||
|
} while (defined($bug));
|
||||||
|
if ($bugsToFetch ne '') {
|
||||||
|
$self->FetchBug($event, $bugsToFetch, 'bugs', $skipURI, 1);
|
||||||
}
|
}
|
||||||
$self->{'bugsHistory'}->{$event->{'target'}}->{$bug} = time();
|
return $bugsFound;
|
||||||
return 1;
|
|
||||||
} else {
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub Heard {
|
sub Heard {
|
||||||
|
@ -114,7 +147,7 @@ sub Heard {
|
||||||
sub Baffled {
|
sub Baffled {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
my ($event, $message) = @_;
|
my ($event, $message) = @_;
|
||||||
if ($message =~ /^\s*(...+?)\s+bugs\s*$/osi) {
|
if ($message =~ m/^\s*(...+?)\s+bugs\s*$/osi) {
|
||||||
my $target = $event->{'target'};
|
my $target = $event->{'target'};
|
||||||
$self->FetchBug($event, $1, 'dwim', 0, 0);
|
$self->FetchBug($event, $1, 'dwim', 0, 0);
|
||||||
} else {
|
} else {
|
||||||
|
@ -166,7 +199,7 @@ sub GotURI {
|
||||||
# magicness
|
# magicness
|
||||||
{ no warnings; # this can go _very_ wrong easily
|
{ no warnings; # this can go _very_ wrong easily
|
||||||
|
|
||||||
$lots = ($output !~ /<FORM\s+METHOD=POST\s+ACTION="long_list.cgi">/osi); # if we got truncated, then this will be missing
|
$lots = ($output !~ m/<FORM\s+METHOD=POST\s+ACTION="long_list.cgi">/osi); # if we got truncated, then this will be missing
|
||||||
$output =~ s/<\/TABLE><TABLE .+?<\/A><\/TH>//gosi;
|
$output =~ s/<\/TABLE><TABLE .+?<\/A><\/TH>//gosi;
|
||||||
(undef, $output) = split(/Summary<\/A><\/TH>/osi, $output);
|
(undef, $output) = split(/Summary<\/A><\/TH>/osi, $output);
|
||||||
($output, undef) = split(/<\/TABLE>/osi, $output);
|
($output, undef) = split(/<\/TABLE>/osi, $output);
|
||||||
|
@ -235,7 +268,7 @@ sub ignoringCommentsTo {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
my ($who) = @_;
|
my ($who) = @_;
|
||||||
foreach (@{$self->{'ignoreCommentsTo'}}) {
|
foreach (@{$self->{'ignoreCommentsTo'}}) {
|
||||||
return 1 if $who =~ /^(?:.*[]\s,.;:\\\/=?!()<>{}[-])?\Q$_\E(?:[]\s,.;:\\\/=?!()<>{}[-].*)?$/is;
|
return 1 if $who =~ m/^(?:.*[]\s,.;:\\\/=?!()<>{}[-])?\Q$_\E(?:[]\s,.;:\\\/=?!()<>{}[-].*)?$/is;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче