]> jfr.im git - irc/quakenet/newserv.git/commitdiff
CHANSERV: Clarified behaviour of chanflag +f and empty topics.
authorsplidge <redacted>
Thu, 16 Jul 2009 12:50:18 +0000 (13:50 +0100)
committersplidge <redacted>
Thu, 16 Jul 2009 12:50:18 +0000 (13:50 +0100)
+f will now enforce an empty topic on a channel.

Added CLEARTOPIC command to clear out the saved topic if that's what you
want to do.

chanserv/chancmds/cleartopic.c [new file with mode: 0644]
chanserv/chanservnetevents.c

diff --git a/chanserv/chancmds/cleartopic.c b/chanserv/chancmds/cleartopic.c
new file mode 100644 (file)
index 0000000..3cc8035
--- /dev/null
@@ -0,0 +1,53 @@
+/*
+ * CMDNAME: cleartopic
+ * CMDLEVEL: QCMD_AUTHED
+ * CMDARGS: 2
+ * CMDDESC: Clears the topic on a channel.
+ * CMDFUNC: csc_docleartopic
+ * CMDPROTO: int csc_docleartopic(void *source, int cargc, char **cargv);
+ * CMDHELP: Usage: CLEARTOPIC <channel>
+ * CMDHELP: Clears the topic on a channel, where:
+ * CMDHELP: channel - channel to use
+ * CMDHELP: CLEARTOPIC requires topic (+t) or master (+m) access on the named channel.
+ */
+
+#include "../chanserv.h"
+#include "../../nick/nick.h"
+#include "../../lib/flags.h"
+#include "../../lib/irc_string.h"
+#include "../../channel/channel.h"
+#include "../../parser/parser.h"
+#include "../../irc/irc.h"
+#include "../../localuser/localuserchannel.h"
+#include <string.h>
+#include <stdio.h>
+
+int csc_docleartopic(void *source, int cargc, char **cargv) {
+  nick *sender=source;
+  chanindex *cip;
+  regchan *rcp;
+
+  if (cargc<1) {
+    chanservstdmessage(sender, QM_NOTENOUGHPARAMS, "cleartopic");
+    return CMD_ERROR;
+  }
+
+  if (!(cip=cs_checkaccess(sender, cargv[0], CA_TOPICPRIV, 
+                          NULL, "cleartopic", 0, 0)))
+    return CMD_ERROR;
+
+  rcp=cip->exts[chanservext];
+
+  if (rcp->topic)
+    freesstring(rcp->topic);
+
+  rcp->topic=NULL;
+  
+  if (cip->channel) {
+    localsettopic(chanservnick, cip->channel, "");
+  }
+
+  chanservstdmessage(sender, QM_DONE);
+  csdb_updatechannel(rcp);
+  return CMD_OK;
+}
index 0320b00b86011732cdbcdcc9702115343602d677..d802c78b4ce600282261e1dc9bfbca737d4df5b8 100644 (file)
@@ -430,10 +430,8 @@ void cs_handletopicchange(int hooknum, void *arg) {
     return;
  
   if (CIsForceTopic(rcp)) {
-    if (rcp->topic) {
-      /* Forced topic: change it back */
-      localsettopic(chanservnick, cp, rcp->topic->content);
-    }
+    /* Forced topic: change it back even if blank */
+    localsettopic(chanservnick, cp, (rcp->topic)?rcp->topic->content:"");
   } else if (CIsTopicSave(rcp)) {
     if (rcp->topic) {
       freesstring(rcp->topic);