mirror of
https://github.com/perlbot/perlbuut
synced 2025-06-07 16:55:42 -04:00
fix handler
This commit is contained in:
parent
8adb75e6f2
commit
9cb460736b
1 changed files with 22 additions and 5 deletions
|
@ -41,6 +41,7 @@ my %commandhash = (
|
||||||
|
|
||||||
# "" => \&get_fact, #don't ever add the default like this, it'll cause issues! i plan on changing that!
|
# "" => \&get_fact, #don't ever add the default like this, it'll cause issues! i plan on changing that!
|
||||||
"forget" => \&get_fact_forget,
|
"forget" => \&get_fact_forget,
|
||||||
|
"delete" => \&get_fact_delete,
|
||||||
"learn" => \&get_fact_learn,
|
"learn" => \&get_fact_learn,
|
||||||
"relearn" => \&get_fact_learn,
|
"relearn" => \&get_fact_learn,
|
||||||
"literal" => \&get_fact_literal,
|
"literal" => \&get_fact_literal,
|
||||||
|
@ -221,7 +222,7 @@ sub handle ($self, $said, $pm) {
|
||||||
|
|
||||||
$said->{body} =~ s/^\s*(what|who|where|how|when|why)\s+($COPULA_RE)\s+(?<fact>.*?)\??\s*$/$+{fact}/i;
|
$said->{body} =~ s/^\s*(what|who|where|how|when|why)\s+($COPULA_RE)\s+(?<fact>.*?)\??\s*$/$+{fact}/i;
|
||||||
|
|
||||||
my $prefix = $conf->{prefix_command};
|
my $prefix = $conf->{command_prefix};
|
||||||
return unless $prefix;
|
return unless $prefix;
|
||||||
|
|
||||||
# TODO make this channel configurable and make it work properly to learn shit with colors later.
|
# TODO make this channel configurable and make it work properly to learn shit with colors later.
|
||||||
|
@ -316,7 +317,7 @@ sub store_factoid ($self, $said) {
|
||||||
return ($subject, $copula, $predicate);
|
return ($subject, $copula, $predicate);
|
||||||
}
|
}
|
||||||
|
|
||||||
sub _insert_factoid ($self, $author, $subject, $copula, $predicate, $compose_macro, $protected, $server, $namespace) {
|
sub _insert_factoid ($self, $author, $subject, $copula, $predicate, $compose_macro, $protected, $server, $namespace, $deleted=0) {
|
||||||
my $dbh = $self->dbh;
|
my $dbh = $self->dbh;
|
||||||
|
|
||||||
warn "Attempting to insert factoid: type $compose_macro";
|
warn "Attempting to insert factoid: type $compose_macro";
|
||||||
|
@ -335,8 +336,8 @@ sub _insert_factoid ($self, $author, $subject, $copula, $predicate, $compose_mac
|
||||||
|
|
||||||
$dbh->do(
|
$dbh->do(
|
||||||
"INSERT INTO factoid
|
"INSERT INTO factoid
|
||||||
(original_subject,subject,copula,predicate,author,modified_time,metaphone,compose_macro,protected, namespace, server)
|
(original_subject,subject,copula,predicate,author,modified_time,metaphone,compose_macro,protected, namespace, server, deleted)
|
||||||
VALUES (?,?,?,?,?,?,?,?,?,?,?)",
|
VALUES (?,?,?,?,?,?,?,?,?,?,?,?)",
|
||||||
undef,
|
undef,
|
||||||
$key,
|
$key,
|
||||||
$subject,
|
$subject,
|
||||||
|
@ -348,7 +349,8 @@ sub _insert_factoid ($self, $author, $subject, $copula, $predicate, $compose_mac
|
||||||
$compose_macro || 0,
|
$compose_macro || 0,
|
||||||
$protected || 0,
|
$protected || 0,
|
||||||
$namespace,
|
$namespace,
|
||||||
$server
|
$server,
|
||||||
|
$deleted
|
||||||
);
|
);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -411,6 +413,21 @@ sub get_fact_forget ($self, $subject, $name, $said) {
|
||||||
return "Forgot $subject";
|
return "Forgot $subject";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub get_fact_delete ($self, $subject, $name, $said) {
|
||||||
|
my ($aliasserver, $aliasnamespace) = $self->get_alias_namespace($said);
|
||||||
|
my ($server, $namespace) = $self->get_namespace($said);
|
||||||
|
|
||||||
|
warn "===TRYING TO DELETE [$subject] [$name]\n";
|
||||||
|
|
||||||
|
#XXX check permissions here
|
||||||
|
return "Insufficient permissions for deleting protected factoid [$subject]"
|
||||||
|
if (!$self->_db_check_perm($subject, $said));
|
||||||
|
|
||||||
|
$self->_insert_factoid($name, $subject, "is", " ", 0, $self->_db_get_protect($subject, $server, $namespace), $aliasserver, $aliasnamespace, 1);
|
||||||
|
|
||||||
|
return "Deleted $subject from $server:$namespace";
|
||||||
|
}
|
||||||
|
|
||||||
sub _fact_literal_format($r, $aliasserver, $aliasnamespace) {
|
sub _fact_literal_format($r, $aliasserver, $aliasnamespace) {
|
||||||
$aliasserver ||= "*";
|
$aliasserver ||= "*";
|
||||||
$aliasnamespace ||= "##NULL";
|
$aliasnamespace ||= "##NULL";
|
||||||
|
|
Loading…
Add table
Reference in a new issue