]>
Commit | Line | Data |
---|---|---|
1dd6d55d | 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); | |
baafd54b | 10 | * CMDHELP: Usage: channelcomment <channel> [[+]<comment>] |
94e4d2f4 | 11 | * CMDHELP: Sets or views a comment for a channel. |
baafd54b CP |
12 | * CMDHELP: Comments can be appended to by prefixing <comment> with +. |
13 | * CMDHELP: Use 'none' for <comment> to unset. | |
1dd6d55d | 14 | */ |
15 | ||
16 | #include "../chanserv.h" | |
17 | #include "../../nick/nick.h" | |
18 | #include "../../lib/flags.h" | |
19 | #include "../../lib/irc_string.h" | |
20 | #include "../../channel/channel.h" | |
21 | #include "../../parser/parser.h" | |
22 | #include "../../irc/irc.h" | |
23 | #include "../../localuser/localuserchannel.h" | |
24 | #include <string.h> | |
25 | #include <stdio.h> | |
26 | ||
27 | int csc_dochannelcomment(void *source, int cargc, char **cargv) { | |
28 | nick *sender=source; | |
29 | reguser *rup=getreguserfromnick(sender); | |
30 | regchan *rcp; | |
31 | chanindex *cip; | |
32 | char buf[300]; | |
33 | int bufpos; | |
34 | ||
35 | if (!rup) | |
36 | return CMD_ERROR; | |
37 | ||
38 | if (cargc<1) { | |
39 | chanservstdmessage(sender, QM_NOTENOUGHPARAMS, "channelcomment"); | |
40 | return CMD_ERROR; | |
41 | } | |
42 | ||
43 | if (!(cip=findchanindex(cargv[0])) || !(rcp=cip->exts[chanservext])) { | |
44 | chanservstdmessage(sender, QM_UNKNOWNCHAN, cargv[0]); | |
45 | return CMD_ERROR; | |
46 | } | |
47 | ||
48 | if (cargc>1) { | |
49 | if (!ircd_strcmp(cargv[1],"none")) { | |
50 | freesstring(rcp->comment); | |
51 | rcp->comment=NULL; | |
52 | } else { | |
53 | if (*cargv[1]=='+') { | |
54 | if (rcp->comment) { | |
55 | strcpy(buf,rcp->comment->content); | |
56 | bufpos=rcp->comment->length; | |
57 | buf[bufpos++]=' '; | |
58 | } else { | |
59 | bufpos=0; | |
60 | } | |
15cf23c4 | 61 | strncpy(buf+bufpos, cargv[1]+1, 280-bufpos); |
1dd6d55d | 62 | } else { |
63 | strncpy(buf, cargv[1], 250); | |
64 | } | |
65 | ||
66 | freesstring(rcp->comment); | |
67 | rcp->comment=getsstring(buf,250); | |
68 | } | |
69 | csdb_updatechannel(rcp); | |
70 | } | |
71 | ||
72 | if (rcp->comment) | |
73 | chanservstdmessage(sender, QM_COMMENT, cip->name->content, rcp->comment->content); | |
74 | else | |
75 | chanservstdmessage(sender, QM_NOCOMMENT, cip->name->content); | |
76 | ||
77 | return CMD_OK; | |
78 | } |