mirror of
https://github.com/pragma-/pbot.git
synced 2024-11-26 22:09:26 +01:00
Require "is" as separator to allow add factoids with spaces in trigger
This commit is contained in:
parent
7b4d15191a
commit
c699ae26a8
@ -220,20 +220,18 @@ sub add_text {
|
|||||||
my $self = shift;
|
my $self = shift;
|
||||||
my ($from, $nick, $user, $host, $arguments) = @_;
|
my ($from, $nick, $user, $host, $arguments) = @_;
|
||||||
my $factoids = $self->{pbot}->factoids->factoids;
|
my $factoids = $self->{pbot}->factoids->factoids;
|
||||||
my ($keyword, $text) = $arguments =~ /^(.*?)\s+(.*)$/ if defined $arguments;
|
my ($keyword, $text) = $arguments =~ /^(.*?)\s+is\s+(.*)$/i if defined $arguments;
|
||||||
|
|
||||||
if(not defined $text) {
|
if(not defined $text) {
|
||||||
$self->{pbot}->logger->log("add_text: invalid usage\n");
|
$self->{pbot}->logger->log("add_text: invalid usage\n");
|
||||||
return "/msg $nick Usage: add <keyword> <factoid>";
|
return "/msg $nick Usage: add <keyword> is <factoid>";
|
||||||
}
|
}
|
||||||
|
|
||||||
if(not defined $keyword) {
|
if(not defined $keyword) {
|
||||||
$self->{pbot}->logger->log("add_text: invalid usage\n");
|
$self->{pbot}->logger->log("add_text: invalid usage\n");
|
||||||
return "/msg $nick Usage: add <keyword> <factoid>";
|
return "/msg $nick Usage: add <keyword> is <factoid>";
|
||||||
}
|
}
|
||||||
|
|
||||||
$text =~ s/^is\s+//;
|
|
||||||
|
|
||||||
if(exists $factoids->{$keyword}) {
|
if(exists $factoids->{$keyword}) {
|
||||||
$self->{pbot}->logger->log("$nick!$user\@$host attempt to overwrite $keyword\n");
|
$self->{pbot}->logger->log("$nick!$user\@$host attempt to overwrite $keyword\n");
|
||||||
return undef;
|
return undef;
|
||||||
@ -251,7 +249,7 @@ sub add_text {
|
|||||||
|
|
||||||
$self->{pbot}->factoids->save_factoids();
|
$self->{pbot}->factoids->save_factoids();
|
||||||
|
|
||||||
return "/msg $nick $keyword added.";
|
return "/msg $nick '$keyword' added.";
|
||||||
}
|
}
|
||||||
|
|
||||||
sub histogram {
|
sub histogram {
|
||||||
|
@ -175,10 +175,10 @@ sub interpret {
|
|||||||
($keyword, $arguments, $tonick) = ($2, $3, $1);
|
($keyword, $arguments, $tonick) = ($2, $3, $1);
|
||||||
} elsif($command =~ /^tell\s+(.{1,20})\s+about\s+(.*)$/) {
|
} elsif($command =~ /^tell\s+(.{1,20})\s+about\s+(.*)$/) {
|
||||||
($keyword, $tonick) = ($2, $1);
|
($keyword, $tonick) = ($2, $1);
|
||||||
} elsif($command =~ /^([^ ]+)\s+is\s+also\s+(.*)$/) {
|
} elsif($command =~ /^(.*?)\s+is\s+also\s+(.*)$/) {
|
||||||
($keyword, $arguments) = ("change", "$1 s,\$, ; $2,");
|
($keyword, $arguments) = ("change", "$1 s|\$| - $2|");
|
||||||
} elsif($command =~ /^([^ ]+)\s+is\s+(.*)$/) {
|
} elsif($command =~ /^(.*?)\s+is\s+(.*)$/) {
|
||||||
($keyword, $arguments) = ("add", join(' ', $1, $2)) unless exists ${ $pbot->factoids }{factoids}{$1};
|
($keyword, $arguments) = ("add", join(' is ', $1, $2)) unless exists ${ $pbot->factoids }{factoids}{$1};
|
||||||
($keyword, $arguments) = ($1, "is $2") if exists ${ $pbot->factoids }{factoids}{$1};
|
($keyword, $arguments) = ($1, "is $2") if exists ${ $pbot->factoids }{factoids}{$1};
|
||||||
} elsif($command =~ /^(.*?)\s+(.*)$/) {
|
} elsif($command =~ /^(.*?)\s+(.*)$/) {
|
||||||
($keyword, $arguments) = ($1, $2);
|
($keyword, $arguments) = ($1, $2);
|
||||||
|
Loading…
Reference in New Issue
Block a user