aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Plugin/Admin.pm16
1 files changed, 11 insertions, 5 deletions
diff --git a/Plugin/Admin.pm b/Plugin/Admin.pm
index 38d4993..0601a85 100644
--- a/Plugin/Admin.pm
+++ b/Plugin/Admin.pm
@@ -168,13 +168,19 @@ sub topic {
my ($self, $irc, $logger, $who, $where, $ided, $rest, $no_reenter, @arguments) = @_;
return unless is_admin($logger, $who, $ided);
- return "Syntax: set topic <new topic>" unless @arguments >= 2;
- # Strip nick/channel from message
- $rest =~ s/^(.*?\s)//;
+ $where = $where->[0] if ref($where) eq "ARRAY";
+ my $channel;
+ if (@arguments && $arguments[0] =~ m/^#/) {
+ $channel = $arguments[0];
+ $rest =~ s/^.*?(\s|$)//;
+ } elsif ($where =~ m/^#/) {
+ $channel = $where;
+ }
+
+ return "Syntax: set topic <new topic>" unless $channel;
- # FIXME use $where if it's a channel
- $irc->yield(topic => $arguments[0] => $rest);
+ $irc->yield(topic => $channel => $rest);
}
sub reconnect {