]> jfr.im git - irc/SurrealServices/srsv.git/commitdiff
merge cs_topicappend and friends, including cleanups
authortabris <redacted>
Fri, 2 Sep 2011 18:33:08 +0000 (18:33 +0000)
committertabris <redacted>
Fri, 2 Sep 2011 18:33:08 +0000 (18:33 +0000)
git-svn-id: http://svn.tabris.net/repos/srsv@3563 70d4eda1-72e9-0310-a436-91e5bd24443c

branches/0.5.0/help/chanserv.txt
branches/0.5.0/help/chanserv/topicappend.txt [new file with mode: 0644]
branches/0.5.0/help/chanserv/topicprepend.txt [new file with mode: 0644]
branches/0.5.0/modules/serviceslibs/chanserv.pm

index f2bc8a920315859feca185c96c28228c42a8c4e8..d1738b5cd60917f93afe7ca9725f35fb72141238 100644 (file)
@@ -24,7 +24,8 @@ Other available commands:
    DICE   INVITE   GETKEY   CLOSE
    CLEAR  WELCOME  DRONE    KICKMASK
    KICK   KICKBAN  MLOCK    KICKBANMASK
-   JOIN   COPY     BANLIST  TOPIC
+   JOIN   COPY     BANLIST
+   TOPIC  TOPICAPPEND TOPICPREPEND
 
 Note that channels will be dropped after 21 days of inactivity.
  
diff --git a/branches/0.5.0/help/chanserv/topicappend.txt b/branches/0.5.0/help/chanserv/topicappend.txt
new file mode 100644 (file)
index 0000000..5d4c203
--- /dev/null
@@ -0,0 +1,5 @@
+%BChanServ TOPICAPPEND%B appends a phrase to the current topic, or sets the topic if no topic is set yet.
+
+Syntax: %BTOPICAPPEND%B %U#channel%U <message>
+Examples: /cs TOPICAPPEND #erry COOKIES!
+-!- Eustace has changed the topic of #erry to: SLINKIES | COOKIES!
diff --git a/branches/0.5.0/help/chanserv/topicprepend.txt b/branches/0.5.0/help/chanserv/topicprepend.txt
new file mode 100644 (file)
index 0000000..a8bb0c1
--- /dev/null
@@ -0,0 +1,5 @@
+%BChanServ TOPICAPPEND%B prepends a phrase to the current topic, or sets the topic if no topic is set yet.
+
+Syntax: %BTOPICPREPEND%B %U#channel%U <message>
+Examples: /cs TOPICPREPEND #erry COLORSS!!!
+-!- Eustace has changed the topic of #erry to: COLORSS!!! | SLINKIES | COOKIES!
index 546701cc5e18b76381ec26a13a20a3686d4b096f..9be96d01ef03a30f4b616f98d6d1f4630cd00911 100644 (file)
@@ -568,6 +568,7 @@ sub dispatch($$$) {
                        notice($user, 'Syntax: REGISTER <#channel> [password] [description]');
                }
        }
+       
        elsif($cmd =~ /^(?:[uvhas]op|co?f(ounder)?)$/i) {
                my ($cn, $cmd2) = splice(@args, 0, 2);
                my $chan = { CHAN => $cn };
@@ -996,13 +997,30 @@ sub dispatch($$$) {
                        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 =~ /^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 {
@@ -3330,7 +3348,24 @@ sub cs_topic($$@) {
        my ($chan, $msg) = ($cn->{CHAN}, join(" ", @args));
        can_do($cn, 'SETTOPIC', $user) or return undef;
        ircd::settopic(agent($cn), $chan, get_user_nick($user), time, ($msg =~ /^none/i ? "" : $msg));
-}   
+}
+
+sub cs_topicappend {
+       my ($user, $chan, $front, $topicappend) = @_;
+       my $cn = $chan->{CHAN};
+       $get_topic->execute($cn);
+       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;
+               }
+       }
+       cs_topic ($user, $chan, $new_topic);
+}
 
 ### MISCELLANEA ###
 
@@ -4886,7 +4921,7 @@ sub chan_topic {
        $suser -> {AGENT} = agent($chan);
        my $setter = $suser -> {NICK};
        return if cr_chk_flag($chan, CRF_CLOSE, 1);
-       
+
        if(current_message->{SYNC}) {  # We don't need to undo our own topic changes.
                print "Line @{[__LINE__]}\n";
                $set_topic1->execute($setter, $time, $cn);