}
my $subtopic = $_;
- my $owner = "Unknown";
+ my $owner = 'Unknown';
if (/(.*)\s+\((.*?)\)$/) {
$subtopic = $1;
foreach (@_) {
my ($subtopic, $setby) = split /\|\|/;
- if ($setby =~ /^(unknown|)$/i) {
- push(@topic, $subtopic);
- } else {
+ if ($param{'topicAuthor'} eq '1' and (!$setby =~ /^(unknown|)$/i)) {
push(@topic, "$subtopic ($setby)");
+ } else {
+ push(@topic, "$subtopic");
}
}
return 1;
}
- if (defined $updateMsg && $updateMsg ne "") {
+ if (defined $updateMsg && $updateMsg ne '') {
&msg($who, $updateMsg);
}
$conn->topic($chan, $topic);
&topicAddHistory($chan, $topic);
} else {
- $conn->topic($chan, " ");
+ $conn->topic($chan, ' ');
}
return 1;
my ($chan, $topic) = @_;
my $dupe = 0;
- return 1 if ($topic eq ""); # required fix.
+ return 1 if ($topic eq ''); # required fix.
foreach (@{ $topic{$chan}{'History'} }) {
- next if ($_ ne "" and $_ ne $topic);
+ next if ($_ ne '' and $_ ne $topic);
# checking length is required.
# slightly weird to put a return statement in a loop.
sub do_add {
my ($chan, $args) = @_;
- if ($args eq "") {
- &help("topic add");
+ if ($args eq '') {
+ &help('topic add');
return;
}
# heh, joeyh. 19990819. -xk
if ($who =~ /\|\|/) {
- &msg($who, "error: you have an invalid nick, loser!");
+ &msg($who, 'error: you have an invalid nick, loser!');
return;
}
- return if ($channels{$chan}{t} and !&hasFlag("T"));
+ return if ($channels{$chan}{t} and !&hasFlag('T'));
my @prev = &topicDecipher($chan);
- my $new = "$args ($orig{who})";
+ my $new;
+ # If bot new to chan and topic is blank, it still got a (owner). This is fix
+ if ($param{'topicAuthor'} eq '1') {
+ $new = "$args ($orig{who})";
+ } else {
+ $new = "$args";
+ }
$topic{$chan}{'What'} = "Added '$args'.";
if (scalar @prev) {
$new = &topicCipher(@prev, $str);
}
- &topicNew($chan, $new, "");
+ &topicNew($chan, $new, '');
}
# cmd: delete.
my $topiccount = scalar @subtopics;
if ($topiccount == 0) {
- &msg($who, "No topic set.");
+ &msg($who, 'No topic set.');
return;
}
- if ($args eq "") {
- &help("topic del");
+ if ($args eq '') {
+ &help('topic del');
return;
}
}
my @delete;
- foreach (split ",", $args) {
- next if ($_ eq "");
+ foreach (split ',', $args) {
+ next if ($_ eq '');
# change to hash list instead of array?
if (/^(\d+)-(\d+)$/) {
return;
}
- $topic{$chan}{'What'} = "Deleted ".join("/",@delete);
+ $topic{$chan}{'What'} = 'Deleted '.join("/",@delete);
}
foreach (@delete) {
my ($subtopic,$whoby) = split('\|\|', $subtopics[$_-1]);
- $whoby = "unknown" if ($whoby eq "");
+ $whoby = 'unknown' if ($whoby eq '');
&msg($who, "Deleting topic: $subtopic ($whoby)");
undef $subtopics[$_-1];
push(@newtopics, $_);
}
- &topicNew($chan, &topicCipher(@newtopics), "");
+ &topicNew($chan, &topicCipher(@newtopics), '');
}
# cmd: list
sub do_modify {
my ($chan, $args) = @_;
- if ($args eq "") {
- &help("topic mod");
+ if ($args eq '') {
+ &help('topic mod');
return;
}
my $topic = $topic{$chan}{'Current'};
### TODO: use m### to make code safe!
- if (($flags eq "g" and $topic =~ s/\Q$op\E/$np/g) ||
- ($flags eq "" and $topic =~ s/\Q$op\E/$np/)
+ if (($flags eq 'g' and $topic =~ s/\Q$op\E/$np/g) ||
+ ($flags eq '' and $topic =~ s/\Q$op\E/$np/)
) {
$_ = "Modifying topic with sar s/$op/$np/.";
sub do_move {
my ($chan, $args) = @_;
- if ($args eq "") {
- &help("topic mv");
+ if ($args eq '') {
+ &help('topic mv');
return;
}
undef @subtopics; # lets reuse this array.
foreach (@newtopics) {
- next if (!defined $_ or $_ eq "");
+ next if (!defined $_ or $_ eq '');
push(@subtopics, $_);
}
my @subtopics = &topicDecipher($chan);
my @newtopics;
- $topic{$chan}{'What'} = "shuffled";
+ $topic{$chan}{'What'} = 'shuffled';
foreach (&makeRandom(scalar @subtopics)) {
push(@newtopics, $subtopics[$_]);
sub do_restore {
my ($chan, $args) = @_;
- if ($args eq "") {
- &help("topic restore");
+ if ($args eq '') {
+ &help('topic restore');
return;
}
my ($chan) = @_;
$_ = "Rehashing topic...";
- $topic{$chan}{'What'} = "Rehash";
+ $topic{$chan}{'What'} = 'Rehash';
&topicNew($chan, $topic{$chan}{'Current'}, $_, 1);
}
if (exists $topic{$chan}{'Who'} and exists $topic{$chan}{'Time'}) {
$reply = "topic on \002$chan\002 was last set by ".
$topic{$chan}{'Who'}. ". This was done ".
- &Time2String(time() - $topic{$chan}{'Time'}) ." ago".
+ &Time2String(time() - $topic{$chan}{'Time'}) .' ago'.
". Length: ".length($topic{$chan}{'Current'});
my $change = $topic{$chan}{'What'};
$reply .= ". Change => $change" if (defined $change);
&do_info($chan);
} else {
- ### CMD: HELP:
- if ($cmd ne "" and $cmd !~ /^help/i) {
+ ### HELP:
+ if ($cmd ne '' and $cmd !~ /^help/i) {
&msg($who, "Invalid command [$cmd].");
&msg($who, "Try 'help topic'.");
return;
}
- &help("topic");
+ &help('topic');
}
return;
}
1;
+
+# vim:ts=4:sw=4:expandtab:tw=80