#
use strict;
-use vars qw(%topiccmp %topic %channels %orig);
-use vars qw($who $chan $conn $uh $ident $topicUpdate);
-# use cache{topicUpdate}?
+use vars qw(%topiccmp %topic %channels %cache %orig);
+use vars qw($who $chan $conn $uh $ident);
###############################
##### INTERNAL FUNCTIONS
}
if (grep /^\Q$subtopic\E\|\|\Q$owner\E$/, @results) {
- &status("Topic: we have found a dupe in the topic, not adding.");
+ &status("Topic: we have found a dupe ($subtopic) in the topic, not adding.");
next;
}
foreach (@_) {
my ($subtopic, $setby) = split /\|\|/;
- if ($setby =~ /(unknown|)$/i) {
+ if ($setby =~ /^(unknown|)$/i) {
push(@topic, $subtopic);
} else {
push(@topic, "$subtopic ($setby)");
}
###
-# Usage: &topicNew($chan, $topic, $updateMsg, $topicUpdate);
+# Usage: &topicNew($chan, $topic, $updateMsg);
sub topicNew {
- my ($chan, $topic, $updateMsg, $topicUpdate) = @_;
+ my ($chan, $topic, $updateMsg) = @_;
my $maxlen = 470;
if ($channels{$chan}{t} and !$channels{$chan}{o}{$ident}) {
$topic{$chan}{'Current'} = $topic;
- # notification that the topic was altered.
- if (!$topicUpdate) { # for cached changes with '-'.
- &msg($who, "okay");
+ if ($cache{topicNotUpdate}{$chan}) {
+ &msg($who, "done. 'flush' to finalize changes.");
+ delete $cache{topicNotUpdate}{$chan};
return 1;
}
$topic{$chan}{'Time'} = time();
$conn->topic($chan, $topic);
- &topicAddHistory($chan,$topic);
+ &topicAddHistory($chan, $topic);
return 1;
}
return;
}
- if (!&hasFlag("T")) {
- &msg($who, "you do not have enough flags to add topics");
- return;
- }
+ return unless (&hasFlag("T"));
my @prev = &topicDecipher($chan);
my $new = "$args ($orig{who})";
$new = &topicCipher(@prev, $str);
}
- &topicNew($chan, $new, "", $topicUpdate);
+ &topicNew($chan, $new, "");
}
# cmd: delete.
push(@newtopics, $_);
}
- &topicNew($chan, &topicCipher(@newtopics), "", $topicUpdate);
+ &topicNew($chan, &topicCipher(@newtopics), "");
}
# cmd: list
) {
$_ = "Modifying topic with sar s/$op/$np/.";
- &topicNew($chan, $topic, $_, $topicUpdate);
+ &topicNew($chan, $topic, $_);
} else {
&msg($who, "warning: regex not found in topic.");
}
$subtopics[$from - 1] = $tmp;
$_ = "Swapped #\002$from\002 with #\002$to\002.";
- &topicNew($chan, &topicCipher(@subtopics), $_, $topicUpdate);
+ &topicNew($chan, &topicCipher(@subtopics), $_);
return;
}
}
$_ = "Moved #\002$from\002 $action #\002$to\002.";
- &topicNew($chan, &topicCipher(@subtopics), $_, $topicUpdate);
+ &topicNew($chan, &topicCipher(@subtopics), $_);
}
# cmd: shuffle.
}
$_ = "Shuffling the bag of lollies.";
- &topicNew($chan, &topicCipher(@newtopics), $_, $topicUpdate);
+ &topicNew($chan, &topicCipher(@newtopics), $_);
}
# cmd: history.
}
$_ = "Changing topic according to request.";
- &topicNew($chan, ${ $topic{$chan}{'History'} }[$args-1], $_, $topicUpdate);
+ &topicNew($chan, ${ $topic{$chan}{'History'} }[$args-1], $_);
}
# cmd: rehash.
# Usage: &Topic($cmd, $args);
sub Topic {
my ($chan, $cmd, $args) = @_;
- my $topicUpdate = 1;
if ($cmd =~ /^-(\S+)/) {
- $topicUpdate = 0;
+ $cache{topicNotUpdate}{$chan} = 1;
$cmd = $1;
}
} elsif ($cmd =~ /^restore$/i) {
&do_restore($chan, $args);
- } elsif ($cmd =~ /^rehash$/i) {
+ } elsif ($cmd =~ /^(flush|rehash)$/i) {
&do_rehash($chan);
} elsif ($cmd =~ /^info$/i) {