]>
jfr.im git - irc/quakenet/newserv.git/blob - chanserv/chancmds/adduser.c
1 /* Automatically generated by refactor.pl.
5 * CMDLEVEL: QCMD_AUTHED
7 * CMDDESC: Adds one or more users to a channel.
8 * CMDFUNC: csc_doadduser
9 * CMDPROTO: int csc_doadduser(void *source, int cargc, char **cargv);
10 * CMDHELP: Usage: ADDUSER <channel> [<flags>] <user1> [<user2> [<user3> [...]]]
11 * CMDHELP: Adds the named user(s) to the channel, where:
12 * CMDHELP: channel - the channel to use
13 * CMDHELP: flags - the list of flags to add for each user, introduced by + (for example
14 * CMDHELP: +gv). See CHANLEV for valid flags. If no flags are specified,
15 * CMDHELP: +aot is used. This command cannot be used to add masters (+m) or
16 * CMDHELP: owners (+n).
17 * CMDHELP: user<n> - either a user's current nickname on the network or #accountname. Up to
18 * CMDHELP: 18 users can be specified.
19 * CMDHELP: ADDUSER requires master (+m) access on the named channel.
22 #include "../chanserv.h"
23 #include "../../nick/nick.h"
24 #include "../../lib/flags.h"
25 #include "../../lib/irc_string.h"
26 #include "../../channel/channel.h"
27 #include "../../parser/parser.h"
28 #include "../../irc/irc.h"
29 #include "../../localuser/localuserchannel.h"
33 int csc_doadduser(void *source
, int cargc
, char **cargv
) {
36 regchanuser
*rcup
, *rcuplist
;
46 chanservstdmessage(sender
, QM_NOTENOUGHPARAMS
, "adduser");
50 if (!(cip
=cs_checkaccess(sender
, cargv
[0], CA_MASTERPRIV
, NULL
, "adduser", QPRIV_CHANGECHANLEV
, 0)))
53 rcp
=cip
->exts
[chanservext
];
55 /* See if there are flags defined */
56 if (*cargv
[1] == '+') {
59 /* If there are we now need at least 3 parameters */
61 chanservstdmessage(sender
, QM_NOTENOUGHPARAMS
, "adduser");
66 /* Set the flags. We allow everything except personal flags and +mn. */
67 setflags(&addflags
, QCUFLAG_ALL
& ~(QCUFLAGS_PERSONAL
| QCUFLAG_MASTER
| QCUFLAG_OWNER
), cargv
[1], rcuflags
, 0);
69 /* Remove impossible combinations */
70 addflags
=cs_sanitisechanlev(addflags
);
72 /* It helps a lot if they have actually set something */
74 chanservstdmessage(sender
, QM_NOFLAGSPECIFIED
);
78 addflags
=QCUFLAG_OP
| QCUFLAG_AUTOOP
| QCUFLAG_TOPIC
;
81 flagbuf
=printflags(addflags
, rcuflags
);
84 for (count
=i
=0;i
<REGCHANUSERHASHSIZE
;i
++)
85 for (rcuplist
=rcp
->regusers
[i
];rcuplist
;rcuplist
=rcuplist
->nextbychan
)
88 /* If we found flags don't try to add them as a user as well.. */
89 for (i
=1+foundflags
;i
<cargc
;i
++) {
90 if (!(rup
=findreguser(sender
, cargv
[i
])))
93 if ((rcup
=findreguseronchannel(rcp
, rup
))) {
94 chanservstdmessage(sender
, QM_ALREADYKNOWNONCHAN
, cargv
[i
], cip
->name
->content
);
98 if(count
++ >= MAXCHANLEVS
) {
99 chanservstdmessage(sender
, QM_TOOMANYCHANLEVS
);
100 chanservstdmessage(sender
, QM_DONE
);
104 rcup
=getregchanuser();
107 rcup
->flags
= addflags
;
108 rcup
->changetime
=time(NULL
);
112 cs_log(sender
,"CHANLEV %s #%s %s (+ -> %s)",cip
->name
->content
,rup
->username
, flagbuf
, flagbuf
);
113 addregusertochannel(rcup
);
114 csdb_createchanuser(rcup
);
115 csdb_chanlevhistory_insert(rcp
, sender
, rcup
->user
, 0, rcup
->flags
);
119 rcp
->status
|= QCSTAT_OPCHECK
;
123 chanservstdmessage(sender
, QM_DONE
);