cs_join($user, @args);
}
}
- elsif($cmd =~ /^topic$/i) {
- my $chan = shift @args;
- if (@args == 0) {
- notice($user, 'Syntax: TOPIC <#channel> <message|NONE>');
- } else {
- $msg =~ s/^topic #(?:\S+)? //i;
- cs_topic($user, { CHAN => $chan }, $msg);
- }
- }
- elsif($cmd =~ /^topicappend$/i) {
- my $chan = shift @args;
- if (@args == 0) {
- notice($user, 'Syntax: TOPICAPPEND <#channel> <message>');
- } else {
- $msg =~ s/^topicappend #(?:\S+)? //i;
- cs_topicappend($user, $chan, $msg);
- }
- }
- elsif($cmd =~ /^topicprepend$/i) {
- my $chan = shift @args;
- if (@args == 0) {
- notice($user, 'Syntax: TOPICPREPEND <#channel> <message>');
- } else {
- $msg =~ s/^topicprepend #(?:\S+)? //i;
- cs_topicprepend($user, $chan, $msg);
+ elsif($cmd =~ /^topic/i) {
+ my $cn = shift @args;
+ my $chan = { CHAN => $cn };
+ if($cmd =~ /^topicprepend$/i) {
+ if (@args == 0) {
+ notice($user, 'Syntax: TOPICAPPEND <#channel> <message>');
+ } else {
+ $msg =~ s/^topicappend $cn //i;
+ cs_topicappend($user, $chan, 0, $msg);
+ }
+ } elsif($cmd =~ /^topicprepend$/i) {
+ if (@args == 0) {
+ notice($user, 'Syntax: TOPICPREPEND <#channel> <message>');
+ } else {
+ $msg =~ s/^topicprepend $cn //i;
+ cs_topicappend($user, $chan, 1, $msg);
+ }
+ } elsif($cmd =~ /^topic$/i) {
+ if (@args == 0) {
+ notice($user, 'Syntax: TOPIC <#channel> <message|NONE>');
+ } else {
+ $msg =~ s/^topic $cn //i;
+ cs_topic($user, $chan, $msg);
+ }
}
}
else {
$delete_ban->execute($cn, $arg, $type);
}
}
+
sub cs_topicappend {
- my ($user, $cn, $topicappend) = @_;
- $get_topic->execute($cn);
- my ($ntopic, $nsetter, $ntime) = $get_topic->fetchrow_array;
- my $newtopic;
- if ($ntopic) {
- $newtopic = $ntopic . " | " . $topicappend;
- }
- else { $newtopic = $topicappend; }
- cs_topic ($user, { CHAN => $cn }, $newtopic);
-}
-sub cs_topicprepend {
- my ($user, $cn, $topicprepend) = @_;
+ my ($user, $chan, $front, $topicappend) = @_;
+ my $cn = $chan->{CHAN};
$get_topic->execute($cn);
- my ($ntopic, $nsetter, $ntime) = $get_topic->fetchrow_array;
- my $newtopic;
- if ($ntopic) {
- $newtopic = $topicprepend . " | " . $ntopic;
+ my ($cur_topic, undef, undef) = $get_topic->fetchrow_array;
+ $get_topic->finish();
+ my $new_topic = $cur_topic;
+ if ($cur_topic) {
+ if($front) {
+ $new_topic = $topicappend . ' | ' . $cur_topic;
+ } else {
+ $new_topic .= ' | ' . $topicappend;
+ }
}
- else { $newtopic = $topicprepend; }
- cs_topic ($user, { CHAN => $cn }, $newtopic);
+ cs_topic ($user, $chan, $new_topic);
}
sub chan_topic {
my ($src, $cn, $setter, $time, $topic) = @_;
my $chan = { CHAN => $cn };
my $suser = { NICK => $setter, AGENT => agent($chan) };
-
return if cr_chk_flag($chan, CRF_CLOSE, 1);
-
+
if(current_message->{SYNC}) { # We don't need to undo our own topic changes.
$set_topic1->execute($setter, $time, $cn);
$set_topic2->execute($cn, $topic);