]> jfr.im git - irc/quakenet/newserv.git/blob - chanserv/chancmds/channelcomment.c
Add remaining help.
[irc/quakenet/newserv.git] / chanserv / chancmds / channelcomment.c
1 /* Automatically generated by refactor.pl.
2 *
3 *
4 * CMDNAME: channelcomment
5 * CMDLEVEL: QCMD_OPER
6 * CMDARGS: 2
7 * CMDDESC: Shows or changes the staff comment for a channel.
8 * CMDFUNC: csc_dochannelcomment
9 * CMDPROTO: int csc_dochannelcomment(void *source, int cargc, char **cargv);
10 * CMDHELP: Usage: channelcomment <channel> [<comment>]
11 * CMDHELP: Sets or views a comment for a channel.
12 */
13
14 #include "../chanserv.h"
15 #include "../../nick/nick.h"
16 #include "../../lib/flags.h"
17 #include "../../lib/irc_string.h"
18 #include "../../channel/channel.h"
19 #include "../../parser/parser.h"
20 #include "../../irc/irc.h"
21 #include "../../localuser/localuserchannel.h"
22 #include <string.h>
23 #include <stdio.h>
24
25 int csc_dochannelcomment(void *source, int cargc, char **cargv) {
26 nick *sender=source;
27 reguser *rup=getreguserfromnick(sender);
28 regchan *rcp;
29 chanindex *cip;
30 char buf[300];
31 int bufpos;
32
33 if (!rup)
34 return CMD_ERROR;
35
36 if (cargc<1) {
37 chanservstdmessage(sender, QM_NOTENOUGHPARAMS, "channelcomment");
38 return CMD_ERROR;
39 }
40
41 if (!(cip=findchanindex(cargv[0])) || !(rcp=cip->exts[chanservext])) {
42 chanservstdmessage(sender, QM_UNKNOWNCHAN, cargv[0]);
43 return CMD_ERROR;
44 }
45
46 if (cargc>1) {
47 if (!ircd_strcmp(cargv[1],"none")) {
48 freesstring(rcp->comment);
49 rcp->comment=NULL;
50 } else {
51 if (*cargv[1]=='+') {
52 if (rcp->comment) {
53 strcpy(buf,rcp->comment->content);
54 bufpos=rcp->comment->length;
55 buf[bufpos++]=' ';
56 } else {
57 bufpos=0;
58 }
59 strncpy(buf+bufpos, cargv[1]+1, 250-bufpos);
60 } else {
61 strncpy(buf, cargv[1], 250);
62 }
63
64 freesstring(rcp->comment);
65 rcp->comment=getsstring(buf,250);
66 }
67 csdb_updatechannel(rcp);
68 }
69
70 if (rcp->comment)
71 chanservstdmessage(sender, QM_COMMENT, cip->name->content, rcp->comment->content);
72 else
73 chanservstdmessage(sender, QM_NOCOMMENT, cip->name->content);
74
75 return CMD_OK;
76 }