From e3b351946a01b50fffbafd10351660fa365c3f29 Mon Sep 17 00:00:00 2001 From: Pragmatic Software Date: Fri, 18 Jun 2010 04:40:12 +0000 Subject: [PATCH] List keys and values when using set command without a key (but with an index) --- PBot/Channels.pm | 4 ++-- PBot/HashObject.pm | 11 +++++++++++ PBot/VERSION.pm | 2 +- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/PBot/Channels.pm b/PBot/Channels.pm index 8149bc64..ce3df6ed 100644 --- a/PBot/Channels.pm +++ b/PBot/Channels.pm @@ -49,8 +49,8 @@ sub set { my ($self, $from, $nick, $user, $host, $arguments) = @_; my ($channel, $key, $value) = split / /, $arguments, 3; - if(not defined $channel or not defined $key) { - return "/msg $nick Usage: chanset "; + if(not defined $channel) { + return "/msg $nick Usage: chanset [[key] ]"; } return "/msg $nick " . $self->channels->set($channel, $key, $value); diff --git a/PBot/HashObject.pm b/PBot/HashObject.pm index 7aeb1b78..6485b2bb 100644 --- a/PBot/HashObject.pm +++ b/PBot/HashObject.pm @@ -223,6 +223,17 @@ sub set { return $result; } + if(not defined $key) { + my $result = "[$self->{name}] $hash_index keys: "; + my $comma = ''; + foreach my $k (sort keys %{ $self->hash->{$hash_index} }) { + $result .= $comma . "$k => " . $self->hash->{$hash_index}{$k}; + $comma = ", "; + } + $result .= "none" if($comma eq ''); + return $result; + } + if(not defined $value) { $value = $self->hash->{$hash_index}{$key}; } else { diff --git a/PBot/VERSION.pm b/PBot/VERSION.pm index d2db7e25..830765a1 100644 --- a/PBot/VERSION.pm +++ b/PBot/VERSION.pm @@ -13,7 +13,7 @@ use warnings; # These are set automatically by the build/commit script use constant { BUILD_NAME => "PBot", - BUILD_REVISION => 173, + BUILD_REVISION => 174, BUILD_DATE => "2010-06-17", };