aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Phillips <david@sighup.nz>2019-07-12 21:38:14 +1200
committerDavid Phillips <david@sighup.nz>2019-07-12 23:19:18 +1200
commit7e7609d60fe1c2dab6a5c2f968573888b9ceab07 (patch)
tree965b1418bdc99abbc414e9acd5f8d8b67c243385
parenta22d539075597a686f04a79d960c2047c83ab389 (diff)
downloadidalius-7e7609d60fe1c2dab6a5c2f968573888b9ceab07.tar.xz
Admin: Make topic setting more flexible
-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 {