From 7e7609d60fe1c2dab6a5c2f968573888b9ceab07 Mon Sep 17 00:00:00 2001 From: David Phillips Date: Fri, 12 Jul 2019 21:38:14 +1200 Subject: Admin: Make topic setting more flexible --- Plugin/Admin.pm | 16 +++++++++++----- 1 file 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 " 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 " unless $channel; - # FIXME use $where if it's a channel - $irc->yield(topic => $arguments[0] => $rest); + $irc->yield(topic => $channel => $rest); } sub reconnect { -- cgit v1.1