зеркало из https://github.com/mozilla/pjs.git
Upgrade the insult protection overrides to be more customisable. Add more of them by default. Note that this is not a backwards compatible change but since we haven't released a version with this module yet, that's ok.
This commit is contained in:
Родитель
724de21dff
Коммит
4d10cefada
|
@ -64,9 +64,12 @@ sub RegisterConfig {
|
||||||
$self->registerVariables(
|
$self->registerVariables(
|
||||||
# [ name, save?, settable? ]
|
# [ name, save?, settable? ]
|
||||||
['insultOverrides', 1, 1, { # overrides for the insults (keys must be lowercase)
|
['insultOverrides', 1, 1, { # overrides for the insults (keys must be lowercase)
|
||||||
'mozilla' => 'You are nothing but the best browser on the planet.',
|
'' => '%source: exactly how stupid do you think i am?',
|
||||||
'mozilla.org' => 'You are nothing but the best caretaker Mozilla ever had.',
|
'yourself' => '%source: nice try, fool',
|
||||||
'c++' => 'you are evil',
|
'urself' => '%source: at least learn to spell, you moronic noodle',
|
||||||
|
'mozilla' => '%target: You are nothing but the best browser on the planet.',
|
||||||
|
'mozilla.org' => '%target: You are nothing but the best caretaker Mozilla ever had.',
|
||||||
|
'c++' => '%target: you are evil',
|
||||||
}],
|
}],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -77,15 +80,23 @@ sub Told {
|
||||||
if ($message =~ /^\s*(?:will\s+you\s+)?(?:insult|harass)\s+(\S+?)(?:[\s,.]+please)?[\s.?!]*$/osi) {
|
if ($message =~ /^\s*(?:will\s+you\s+)?(?:insult|harass)\s+(\S+?)(?:[\s,.]+please)?[\s.?!]*$/osi) {
|
||||||
my $who = $1;
|
my $who = $1;
|
||||||
my $line;
|
my $line;
|
||||||
if (defined($self->{'insultOverrides'}->{lc $who})) {
|
|
||||||
|
if (lc $who eq 'me') {
|
||||||
|
$who = $event->{'from'};
|
||||||
|
}
|
||||||
|
|
||||||
|
my $me = quotemeta($event->{'nick'});
|
||||||
|
if ($who =~ m/^$me$/si and
|
||||||
|
defined $self->{'insultOverrides'}->{''}) {
|
||||||
|
$line = $self->{'insultOverrides'}->{''};
|
||||||
|
} elsif (defined $self->{'insultOverrides'}->{lc $who}) {
|
||||||
$line = $self->{'insultOverrides'}->{lc $who};
|
$line = $self->{'insultOverrides'}->{lc $who};
|
||||||
} else {
|
} else {
|
||||||
if (lc $who eq 'me') {
|
$line = $who . ': ' . $self->generateInsult();
|
||||||
$who = $event->{'from'};
|
|
||||||
}
|
|
||||||
$line = $self->generateInsult();
|
|
||||||
}
|
}
|
||||||
$self->say($event, "$who: $line");
|
$line =~ s/%source/$event->{'from'}/gos;
|
||||||
|
$line =~ s/%target/$who/gos;
|
||||||
|
$self->sayOrEmote($event, $line);
|
||||||
} else {
|
} else {
|
||||||
return $self->SUPER::Told(@_);
|
return $self->SUPER::Told(@_);
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче