]>
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);
10 * CMDHELP: Usage: addchan <channel> [<owner> [<flags> [<type> [<msguser>]]]]
11 * CMDHELP: Adds the given channel to the bot, where:
12 * CMDHELP: owner - can be either nickname on the network or #authname. If not supplied,
13 * CMDHELP: the channel will belong to the user issuing the ADDCHAN command.
14 * CMDHELP: flags - can be any valid chanflags (see CHANFLAGS). If not specified this
15 * CMDHELP: defaults to +j.
16 * CMDHELP: type - is a channel type as per old Q and is now obsolete.
17 * CMDHELP: msguser - send a notification to this user (for service use)
20 #include "../chanserv.h"
21 #include "../../nick/nick.h"
22 #include "../../lib/flags.h"
23 #include "../../lib/irc_string.h"
24 #include "../../channel/channel.h"
25 #include "../../parser/parser.h"
26 #include "../../irc/irc.h"
27 #include "../../localuser/localuserchannel.h"
31 int csc_doaddchan(void *source
, int cargc
, char **cargv
) {
32 nick
*sender
=source
, *notify
=NULL
;
33 reguser
*rup
=getreguserfromnick(sender
);
46 chanservstdmessage(sender
, QM_NOTENOUGHPARAMS
, "addchan");
50 if (*cargv
[0] != '#' || strlen(cargv
[0]) > CHANNELLEN
) {
51 chanservstdmessage(sender
, QM_INVALIDCHANNAME
, cargv
[0]);
55 /* If a 5th argument is supplied, it's a nick to send the reply messages to. */
57 notify
=getnickbynick(cargv
[4]);
61 if (!(founder
=findreguser(sender
, cargv
[1])))
69 setflags(&flags
, QCFLAG_ALL
, cargv
[2], rcflags
, REJECT_NONE
);
70 /* Apply relevant policy */
72 flags
&= QCFLAG_USERCONTROL
;
73 flags
|= QCFLAG_JOINED
;
76 flags
= (QCFLAG_JOINED
);
79 /* Pick up the chantype */
81 for (type
=CHANTYPES
-1;type
;type
--) {
82 if (!ircd_strcmp(chantypes
[type
]->content
, cargv
[3]))
86 chanservstdmessage(sender
, QM_UNKNOWNCHANTYPE
, cargv
[3]);
91 if (!(cip
=findorcreatechanindex(cargv
[0]))) {
92 chanservstdmessage(sender
, QM_INVALIDCHANNAME
, cargv
[0]);
94 chanservstdmessage(notify
, QM_INVALIDCHANNAME
, cargv
[0]);
100 for (rcup
=founder
->knownon
;rcup
;rcup
=rcup
->nextbyuser
)
103 if (count
> MAXCHANNELS
) {
104 chanservstdmessage(sender
, QM_TOOMANYCHANNELS
, cip
->name
->content
);
106 chanservstdmessage(sender
, QM_TOOMANYCHANNELS
, cip
->name
->content
);
110 rcp
=cs_addchan(cip
, sender
, rup
, founder
, flags
, type
);
112 chanservstdmessage(sender
, QM_ALREADYREGISTERED
, cip
->name
->content
);
114 chanservstdmessage(notify
, QM_ALREADYREGISTERED
, cip
->name
->content
);
118 cs_log(sender
, "ADDCHAN %s #%s %s %s",cip
->name
->content
,founder
->username
,printflags(rcp
->flags
,rcflags
), chantypes
[type
]->content
);
119 chanservstdmessage(sender
, QM_DONE
);
121 chanservstdmessage(notify
, QM_DONE
);