]> jfr.im git - irc/quakenet/newserv.git/blame - chanserv/chancmds/welcome.c
docs: Change section title.
[irc/quakenet/newserv.git] / chanserv / chancmds / welcome.c
CommitLineData
1dd6d55d 1/* Automatically generated by refactor.pl.
2 *
3 *
4 * CMDNAME: welcome
5 * CMDLEVEL: QCMD_AUTHED
6 * CMDARGS: 2
7 * CMDDESC: Shows or changes the welcome message on a channel.
8 * CMDFUNC: csc_dowelcome
9 * CMDPROTO: int csc_dowelcome(void *source, int cargc, char **cargv);
1e32d528 10 * CMDHELP: Usage: WELCOME <channel> [<message>]
11 * CMDHELP: This shows the current welcome message set on a channel and allows it to be
12 * CMDHELP: changed. In order to be displayed to users, the feature must be enabled
13 * CMDHELP: by the +w chanflag (see CHANFLAGS). Where:
14 * CMDHELP: channel - channel to use
15 * CMDHELP: message - welcome message to set. If this is not provided the existing welcome
16 * CMDHELP: message is displayed.
17 * CMDHELP: Displaying the message requires operator (+o) access on the named channel.
18 * CMDHELP: Changing the message requires master (+m) access on the named channel.
1dd6d55d 19 */
20
21#include "../chanserv.h"
22#include "../../nick/nick.h"
23#include "../../lib/flags.h"
24#include "../../lib/irc_string.h"
25#include "../../channel/channel.h"
26#include "../../parser/parser.h"
27#include "../../irc/irc.h"
28#include "../../localuser/localuserchannel.h"
29#include <string.h>
30#include <stdio.h>
31
32int csc_dowelcome(void *source, int cargc, char **cargv) {
33 nick *sender=source;
34 chanindex *cip;
35 regchan *rcp;
36 sstring *oldwelcome;
37
38 if (cargc<1) {
39 chanservstdmessage(sender, QM_NOTENOUGHPARAMS, "welcome");
40 return CMD_ERROR;
41 }
42
43 if (!(cip=cs_checkaccess(sender, cargv[0], CA_OPPRIV, NULL, "welcome",
44 QPRIV_VIEWWELCOME, 0)))
45 return CMD_ERROR;
46
47 rcp=cip->exts[chanservext];
48
49 if (cargc>1) {
50 if (!cs_checkaccess(sender, NULL, CA_MASTERPRIV, cip, "welcome",
51 QPRIV_CHANGEWELCOME, 0))
52 return CMD_ERROR;
53
54 oldwelcome=rcp->welcome;
55
56 rcp->welcome=getsstring(cargv[1], 500);
57 csdb_updatechannel(rcp);
58
59 cs_log(sender,"WELCOME %s %s (was %s)",cip->name->content,rcp->welcome->content,oldwelcome?oldwelcome->content:"unset");
60 freesstring(oldwelcome);
61 chanservstdmessage(sender, QM_DONE);
62 }
63
64 chanservstdmessage(sender, QM_WELCOMEMESSAGEIS, rcp->index->name->content,
65 rcp->welcome?rcp->welcome->content:"(none)");
66
67 return CMD_OK;
68}