]>
jfr.im git - irc/quakenet/newserv.git/blob - chanserv/chancmds/addchan.c
1 /* Automatically generated by refactor.pl.
7 * CMDDESC: Adds a new channel to the bot.
8 * CMDFUNC: csc_doaddchan
9 * CMDPROTO: int csc_doaddchan(void *source, int cargc, char **cargv);
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"
23 int csc_doaddchan(void *source
, int cargc
, char **cargv
) {
25 reguser
*rup
=getreguserfromnick(sender
);
37 chanservstdmessage(sender
, QM_NOTENOUGHPARAMS
, "addchan");
41 if (*cargv
[0] != '#') {
42 chanservstdmessage(sender
, QM_INVALIDCHANNAME
, cargv
[0]);
47 if (!(founder
=findreguser(sender
, cargv
[1])))
55 setflags(&flags
, QCFLAG_ALL
, cargv
[2], rcflags
, REJECT_NONE
);
57 flags
= (QCFLAG_JOINED
| QCFLAG_BITCH
| QCFLAG_PROTECT
| QCFLAG_ENFORCE
);
60 /* Pick up the chantype */
62 for (type
=CHANTYPES
-1;type
;type
--) {
63 if (!ircd_strcmp(chantypes
[type
]->content
, cargv
[3]))
67 chanservstdmessage(sender
, QM_UNKNOWNCHANTYPE
, cargv
[3]);
72 if (!(cip
=findorcreatechanindex(cargv
[0]))) {
73 chanservstdmessage(sender
, QM_INVALIDCHANNAME
, cargv
[0]);
77 if (cip
->exts
[chanservext
]) {
78 chanservstdmessage(sender
, QM_ALREADYREGISTERED
, cip
->name
->content
);
82 /* Initialise the channel */
86 rcp
->ID
=++lastchannelID
;
88 cip
->exts
[chanservext
]=rcp
;
94 rcp
->lastcountersync
=0;
97 rcp
->forcemodes
=CHANMODE_NOEXTMSG
| CHANMODE_TOPICLIMIT
;
100 if (CIsAutoLimit(rcp
)) {
101 rcp
->forcemodes
|= CHANMODE_LIMIT
;
107 rcp
->created
=rcp
->lastactive
=rcp
->statsreset
=rcp
->ostatsreset
=time(NULL
);
108 rcp
->banduration
=1800;
113 rcp
->addedby
=rup
->ID
;
116 rcp
->founder
=founder
->ID
;
121 rcp
->totaljoins
=rcp
->tripjoins
=rcp
->otripjoins
=rcp
->maxusers
=rcp
->tripusers
=rcp
->otripusers
=0;
122 rcp
->welcome
=rcp
->topic
=rcp
->key
=rcp
->suspendreason
=rcp
->comment
=NULL
;
125 memset(rcp
->regusers
,0,REGCHANUSERHASHSIZE
*sizeof(reguser
*));
127 rcp
->checksched
=NULL
;
130 /* Add new channel to db.. */
131 csdb_createchannel(rcp
);
133 /* Add the founder as +ano */
134 rcup
=getregchanuser();
137 rcup
->flags
=(QCUFLAG_OWNER
| QCUFLAG_OP
| QCUFLAG_AUTOOP
);
140 rcup
->changetime
=time(NULL
);
142 addregusertochannel(rcup
);
143 csdb_createchanuser(rcup
);
145 /* If the channel exists, get the ball rolling */
147 chanservjoinchan(cip
->channel
);
148 rcp
->status
|= QCSTAT_MODECHECK
| QCSTAT_OPCHECK
| QCSTAT_BANCHECK
;
152 cs_log(sender
, "ADDCHAN %s #%s %s %s",cip
->name
->content
,founder
->username
,printflags(rcp
->flags
,rcflags
), chantypes
[type
]->content
);
153 chanservstdmessage(sender
, QM_DONE
);