]> jfr.im git - irc/quakenet/newserv.git/blame - chanserv/chancmds/settopic.c
Merge pull request #1 from meeb/meeb
[irc/quakenet/newserv.git] / chanserv / chancmds / settopic.c
CommitLineData
1dd6d55d 1/* Automatically generated by refactor.pl.
2 *
3 *
4 * CMDNAME: settopic
5 * CMDLEVEL: QCMD_AUTHED
6 * CMDARGS: 2
7 * CMDDESC: Changes the topic on a channel.
8 * CMDFUNC: csc_dosettopic
9 * CMDPROTO: int csc_dosettopic(void *source, int cargc, char **cargv);
1e32d528 10 * CMDHELP: Usage: SETTOPIC <channel> [<topic>]
11 * CMDHELP: Changes the topic on the channel, where:
12 * CMDHELP: channel - channel to use
13 * CMDHELP: topic - new topic. If no topic is set, the stored topic will be reset (this
14 * CMDHELP: feature is useful if some users can no longer see the topic due to a
15 * CMDHELP: netsplit).
16 * CMDHELP: SETTOPIC requires topic (+t) or master (+m) access on the named channel.
1dd6d55d 17 */
18
19#include "../chanserv.h"
20#include "../../nick/nick.h"
21#include "../../lib/flags.h"
22#include "../../lib/irc_string.h"
23#include "../../channel/channel.h"
24#include "../../parser/parser.h"
25#include "../../irc/irc.h"
26#include "../../localuser/localuserchannel.h"
27#include <string.h>
28#include <stdio.h>
29
30int csc_dosettopic(void *source, int cargc, char **cargv) {
31 nick *sender=source;
32 chanindex *cip;
33 regchan *rcp;
34
35 if (cargc<1) {
36 chanservstdmessage(sender, QM_NOTENOUGHPARAMS, "settopic");
37 return CMD_ERROR;
38 }
39
40 if (!(cip=cs_checkaccess(sender, cargv[0], CA_TOPICPRIV,
41 NULL, "settopic", 0, 0)))
42 return CMD_ERROR;
43
44 rcp=cip->exts[chanservext];
45
46 if (cargc>1) {
47 if (rcp->topic)
48 freesstring(rcp->topic);
49 rcp->topic=getsstring(cargv[1],TOPICLEN);
50 }
51
52 if (rcp->topic && cip->channel) {
53 localsettopic(chanservnick, cip->channel, rcp->topic->content);
54 }
55
56 chanservstdmessage(sender, QM_DONE);
57 csdb_updatechannel(rcp);
58 return CMD_OK;
59}