]>
Commit | Line | Data |
---|---|---|
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); | |
10 | */ | |
11 | ||
12 | #include "../chanserv.h" | |
13 | #include "../../nick/nick.h" | |
14 | #include "../../lib/flags.h" | |
15 | #include "../../lib/irc_string.h" | |
16 | #include "../../channel/channel.h" | |
17 | #include "../../parser/parser.h" | |
18 | #include "../../irc/irc.h" | |
19 | #include "../../localuser/localuserchannel.h" | |
20 | #include <string.h> | |
21 | #include <stdio.h> | |
22 | ||
23 | int csc_dowelcome(void *source, int cargc, char **cargv) { | |
24 | nick *sender=source; | |
25 | chanindex *cip; | |
26 | regchan *rcp; | |
27 | sstring *oldwelcome; | |
28 | ||
29 | if (cargc<1) { | |
30 | chanservstdmessage(sender, QM_NOTENOUGHPARAMS, "welcome"); | |
31 | return CMD_ERROR; | |
32 | } | |
33 | ||
34 | if (!(cip=cs_checkaccess(sender, cargv[0], CA_OPPRIV, NULL, "welcome", | |
35 | QPRIV_VIEWWELCOME, 0))) | |
36 | return CMD_ERROR; | |
37 | ||
38 | rcp=cip->exts[chanservext]; | |
39 | ||
40 | if (cargc>1) { | |
41 | if (!cs_checkaccess(sender, NULL, CA_MASTERPRIV, cip, "welcome", | |
42 | QPRIV_CHANGEWELCOME, 0)) | |
43 | return CMD_ERROR; | |
44 | ||
45 | oldwelcome=rcp->welcome; | |
46 | ||
47 | rcp->welcome=getsstring(cargv[1], 500); | |
48 | csdb_updatechannel(rcp); | |
49 | ||
50 | cs_log(sender,"WELCOME %s %s (was %s)",cip->name->content,rcp->welcome->content,oldwelcome?oldwelcome->content:"unset"); | |
51 | freesstring(oldwelcome); | |
52 | chanservstdmessage(sender, QM_DONE); | |
53 | } | |
54 | ||
55 | chanservstdmessage(sender, QM_WELCOMEMESSAGEIS, rcp->index->name->content, | |
56 | rcp->welcome?rcp->welcome->content:"(none)"); | |
57 | ||
58 | return CMD_OK; | |
59 | } |