From: splidge Date: Thu, 16 Jul 2009 12:50:18 +0000 (+0100) Subject: CHANSERV: Clarified behaviour of chanflag +f and empty topics. X-Git-Url: https://jfr.im/git/irc/quakenet/newserv.git/commitdiff_plain/5bc296cea412ea68e1b5c7b8abac87eae85d15ac CHANSERV: Clarified behaviour of chanflag +f and empty topics. +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. --- diff --git a/chanserv/chancmds/cleartopic.c b/chanserv/chancmds/cleartopic.c new file mode 100644 index 00000000..3cc8035c --- /dev/null +++ b/chanserv/chancmds/cleartopic.c @@ -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 + * 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 +#include + +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; +} diff --git a/chanserv/chanservnetevents.c b/chanserv/chanservnetevents.c index 0320b00b..d802c78b 100644 --- a/chanserv/chanservnetevents.c +++ b/chanserv/chanservnetevents.c @@ -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);