]>
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
, *trcup
, *rcuplist
;
41 unsigned int chanlevcount
=0, channelcount
=0;
47 chanservstdmessage(sender
, QM_NOTENOUGHPARAMS
, "adduser");
51 if (!(cip
=cs_checkaccess(sender
, cargv
[0], CA_MASTERPRIV
, NULL
, "adduser", QPRIV_CHANGECHANLEV
, 0)))
54 rcp
=cip
->exts
[chanservext
];
56 /* See if there are flags defined */
57 if (*cargv
[1] == '+') {
60 /* If there are we now need at least 3 parameters */
62 chanservstdmessage(sender
, QM_NOTENOUGHPARAMS
, "adduser");
67 /* Set the flags. We allow everything except personal flags and +mn. */
68 setflags(&addflags
, QCUFLAG_ALL
& ~(QCUFLAGS_PERSONAL
| QCUFLAG_MASTER
| QCUFLAG_OWNER
), cargv
[1], rcuflags
, 0);
70 /* Remove impossible combinations */
71 addflags
=cs_sanitisechanlev(addflags
);
73 /* It helps a lot if they have actually set something */
75 chanservstdmessage(sender
, QM_NOFLAGSPECIFIED
);
79 addflags
=QCUFLAG_OP
| QCUFLAG_AUTOOP
| QCUFLAG_TOPIC
;
82 flagbuf
=printflags(addflags
, rcuflags
);
85 for (chanlevcount
=i
=0;i
<REGCHANUSERHASHSIZE
;i
++)
86 for (rcuplist
=rcp
->regusers
[i
];rcuplist
;rcuplist
=rcuplist
->nextbychan
)
89 /* If we found flags don't try to add them as a user as well.. */
90 for (i
=1+foundflags
;i
<cargc
;i
++) {
91 if (!(rup
=findreguser(sender
, cargv
[i
])))
94 if ((rcup
=findreguseronchannel(rcp
, rup
))) {
95 chanservstdmessage(sender
, QM_ALREADYKNOWNONCHAN
, cargv
[i
], cip
->name
->content
);
99 if(chanlevcount
++ >= MAXCHANLEVS
) {
100 chanservstdmessage(sender
, QM_TOOMANYCHANLEVS
);
101 chanservstdmessage(sender
, QM_DONE
);
106 for (trcup
=rup
->knownon
;trcup
;trcup
=trcup
->nextbyuser
)
109 if(channelcount
>= MAXCHANNELS
) {
110 chanservstdmessage(sender
, QM_TOOMANYCHANNELS
);
114 rcup
=getregchanuser();
117 rcup
->flags
= addflags
;
118 rcup
->changetime
=time(NULL
);
126 triggerhook(HOOK_CHANSERV_CHANLEVMOD
, args
);
128 cs_log(sender
,"CHANLEV %s #%s %s (+ -> %s)",cip
->name
->content
,rup
->username
, flagbuf
, flagbuf
);
129 addregusertochannel(rcup
);
130 csdb_createchanuser(rcup
);
131 csdb_chanlevhistory_insert(rcp
, sender
, rcup
->user
, 0, rcup
->flags
);
135 rcp
->status
|= QCSTAT_OPCHECK
;
139 chanservstdmessage(sender
, QM_DONE
);