- my ($chan, $topic, $updateMsg, $topicUpdate) = @_;
- my $maxlen = 470;
-
- &DEBUG("topic: chan{$chan} is +t.") if ($channels{$chan}{t});
- &DEBUG("topic: chan{$chan} is -t.") unless ($channels{$chan}{t});
- &DEBUG("topic: I have +o.") if ($channels{$chan}{o}{$ident});
- &DEBUG("topic: I don't have +o.") unless ($channels{$chan}{o}{$ident});
-
- if ($channels{$chan}{t} and !$channels{$chan}{o}{$ident}) {
- &msg($who, "error: cannot change topic without ops. (channel is +t) :(");
- return 0;
- }
-
- if (defined $topiccmp{$chan} and $topiccmp{$chan} eq $topic) {
- &msg($who, "warning: action had no effect on topic; no change required.");
- return 0;
- }
-
- # bail out if the new topic is too long.
- my $newlen = length($chan.$topic);
- if ($newlen > $maxlen) {
- &msg($who, "new topic will be too long. ($newlen > $maxlen)");
- return 0;
- }
-
- $topic{$chan}{'Current'} = $topic;
-
- # notification that the topic was altered.
- if (!$topicUpdate) { # for cached changes with '-'.
- &performReply("okay");
+ my ($chan, $topic, $updateMsg, $topicUpdate) = @_;
+ my $maxlen = 470;
+
+ if ($channels{$chan}{t} and !$channels{$chan}{o}{$ident}) {
+ &msg($who, "error: cannot change topic without ops. (channel is +t) :(");
+ return 0;
+ }
+
+ if (defined $topiccmp{$chan} and $topiccmp{$chan} eq $topic) {
+ &msg($who, "warning: action had no effect on topic; no change required.");
+ return 0;
+ }
+
+ # bail out if the new topic is too long.
+ my $newlen = length($chan.$topic);
+ if ($newlen > $maxlen) {
+ &msg($who, "new topic will be too long. ($newlen > $maxlen)");
+ return 0;
+ }
+
+ $topic{$chan}{'Current'} = $topic;
+
+ # notification that the topic was altered.
+ if (!$topicUpdate) { # for cached changes with '-'.
+ &msg($who, "okay");
+ return 1;
+ }
+
+ if ($updateMsg ne "") {
+ &msg($who, $updateMsg);
+ }
+
+ $topic{$chan}{'Last'} = $topic;
+ $topic{$chan}{'Who'} = $orig{who}."!".$uh;
+ $topic{$chan}{'Time'} = time();
+
+ $conn->topic($chan, $topic);
+ &topicAddHistory($chan,$topic);
+