Added !fact command to allow calling factoids belonging to another channel

This commit is contained in:
Pragmatic Software 2010-06-21 13:54:27 +00:00
parent 562d265261
commit 65470a139b
2 changed files with 20 additions and 1 deletions

View File

@ -57,6 +57,25 @@ sub initialize {
$pbot->commands->register(sub { return $self->disable_command(@_) }, "disable", 10);
$pbot->commands->register(sub { return $self->factset(@_) }, "factset", 10);
$pbot->commands->register(sub { return $self->factunset(@_) }, "factunset", 10);
$pbot->commands->register(sub { return $self->call_factoid(@_) }, "fact", 0);
}
sub call_factoid {
my $self = shift;
my ($from, $nick, $user, $host, $arguments) = @_;
my ($chan, $keyword, $args) = split / /, $arguments, 3;
if(not defined $chan or not defined $keyword) {
return "Usage: !fact <channel> <keyword> [arguments]";
}
my ($channel, $trigger) = $self->{pbot}->factoids->find_factoid($chan, $keyword, $args, 1);
if(not defined $trigger) {
return "No such factoid '$keyword' exists for channel '$chan'";
}
return $self->{pbot}->factoids->interpreter($channel, $nick, $user, $host, 1, $trigger, $args);
}
sub factset {

View File

@ -13,7 +13,7 @@ use warnings;
# These are set automatically by the build/commit script
use constant {
BUILD_NAME => "PBot",
BUILD_REVISION => 191,
BUILD_REVISION => 192,
BUILD_DATE => "2010-06-21",
};