]> jfr.im git - irc/quakenet/newserv.git/blob - chanserv/chancmds/chantype.c
Add remaining help.
[irc/quakenet/newserv.git] / chanserv / chancmds / chantype.c
1 /* Automatically generated by refactor.pl.
2 *
3 *
4 * CMDNAME: chantype
5 * CMDLEVEL: QCMD_OPER
6 * CMDARGS: 2
7 * CMDDESC: Shows or changes a channel's type.
8 * CMDFUNC: csc_dochantype
9 * CMDPROTO: int csc_dochantype(void *source, int cargc, char **cargv);
10 * CMDHELP: Usage: chantype <channel> [<channel type>]
11 * CMDHELP: Views or changes the channel type for the specified 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_dochantype(void *source, int cargc, char **cargv) {
26 nick *sender=source;
27 chanindex *cip;
28 regchan *rcp;
29 int type;
30
31 if (cargc<1) {
32 chanservstdmessage(sender, QM_NOTENOUGHPARAMS, "chantype");
33 return CMD_ERROR;
34 }
35
36 if (!(cip=findchanindex(cargv[0])) || !(rcp=cip->exts[chanservext])) {
37 chanservstdmessage(sender, QM_UNKNOWNCHAN, cargv[0]);
38 return CMD_ERROR;
39 }
40
41 if (cargc>1) {
42 /* Set type */
43 for (type=CHANTYPES-1;type;type--) {
44 if (!ircd_strcmp(chantypes[type]->content, cargv[1]))
45 break;
46 }
47 if (!type) {
48 chanservstdmessage(sender, QM_UNKNOWNCHANTYPE, cargv[1]);
49 return CMD_ERROR;
50 }
51 rcp->chantype=type;
52
53 csdb_updatechannel(rcp);
54 chanservstdmessage(sender, QM_DONE);
55 }
56
57 chanservstdmessage(sender, QM_CHANTYPEIS, cip->name->content, chantypes[rcp->chantype]->content);
58
59 return CMD_OK;
60 }