3
0
mirror of https://github.com/pragma-/pbot.git synced 2024-11-19 10:29:30 +01:00

!info and !show now require channel parameter

This commit is contained in:
Pragmatic Software 2010-06-21 14:41:39 +00:00
parent 65470a139b
commit eabb249d79
2 changed files with 16 additions and 13 deletions

View File

@ -347,15 +347,16 @@ sub show {
my ($from, $nick, $user, $host, $arguments) = @_; my ($from, $nick, $user, $host, $arguments) = @_;
my $factoids = $self->{pbot}->factoids->factoids->hash; my $factoids = $self->{pbot}->factoids->factoids->hash;
if(not defined $arguments) { my ($chan, $trig) = split / /, $arguments;
return "/msg $nick Usage: show <factoid>";
if(not defined $chan or not defined $trig) {
return "/msg $nick Usage: show <channel> <factoid>";
} }
$from = '.*' if not defined $from or $from !~ /^#/; my ($channel, $trigger) = $self->{pbot}->factoids->find_factoid($chan, $trig);
my ($channel, $trigger) = $self->{pbot}->factoids->find_factoid($from, $arguments);
if(not defined $trigger) { if(not defined $trigger) {
return "/msg $nick $arguments not found in channel $from"; return "/msg $nick '$trig' not found in channel '$chan' (did you mean channel '.*'?";
} }
if($factoids->{$channel}->{$trigger}->{type} eq 'module') { if($factoids->{$channel}->{$trigger}->{type} eq 'module') {
@ -370,22 +371,22 @@ sub info {
my ($from, $nick, $user, $host, $arguments) = @_; my ($from, $nick, $user, $host, $arguments) = @_;
my $factoids = $self->{pbot}->factoids->factoids->hash; my $factoids = $self->{pbot}->factoids->factoids->hash;
if(not defined $arguments) { my ($chan, $trig) = split / /, $arguments;
return "/msg $nick Usage: info <factoid|module>";
if(not defined $chan or not defined $trig) {
return "/msg $nick Usage: info <channel> <trigger>";
} }
$from = '.*' if not defined $from or $from !~ /^#/; my ($channel, $trigger) = $self->{pbot}->factoids->find_factoid($chan, $trig);
my ($channel, $trigger) = $self->{pbot}->factoids->find_factoid($from, $arguments);
if(not defined $trigger) { if(not defined $trigger) {
return "/msg $nick $arguments not found"; return "/msg $nick '$trig' not found in channel '$chan' (did you mean channel '.*'?";
} }
my $created_ago = ago(gettimeofday - $factoids->{$channel}->{$trigger}->{created_on}); my $created_ago = ago(gettimeofday - $factoids->{$channel}->{$trigger}->{created_on});
my $ref_ago = ago(gettimeofday - $factoids->{$channel}->{$trigger}->{last_referenced_on}) if defined $factoids->{$channel}->{$trigger}->{last_referenced_on}; my $ref_ago = ago(gettimeofday - $factoids->{$channel}->{$trigger}->{last_referenced_on}) if defined $factoids->{$channel}->{$trigger}->{last_referenced_on};
my $chan = ($channel eq '.*' ? 'all channels' : $channel); $chan = ($channel eq '.*' ? 'all channels' : $channel);
# factoid # factoid
if($factoids->{$channel}->{$trigger}->{type} eq 'text') { if($factoids->{$channel}->{$trigger}->{type} eq 'text') {
@ -496,6 +497,8 @@ sub find {
my $text; my $text;
my $type; my $type;
if(not defined $arguments) { if(not defined $arguments) {
return "/msg $nick Usage: !find [-owner nick] [-by nick] [text]"; return "/msg $nick Usage: !find [-owner nick] [-by nick] [text]";
} }

View File

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