]> jfr.im git - irc/quakenet/newserv.git/blob - chanserv/chancmds/removeuser.c
Merge.
[irc/quakenet/newserv.git] / chanserv / chancmds / removeuser.c
1 /* Automatically generated by refactor.pl.
2 *
3 *
4 * CMDNAME: removeuser
5 * CMDLEVEL: QCMD_AUTHED
6 * CMDARGS: 20
7 * CMDDESC: Removes one or more users from a channel.
8 * CMDFUNC: csc_doremoveuser
9 * CMDPROTO: int csc_doremoveuser(void *source, int cargc, char **cargv);
10 * CMDHELP: Usage: REMOVEUSER <channel> <user1> [<user2> [<user3> [...]]]
11 * CMDHELP: Removes any flags the named user(s) have on the channel. This command
12 * CMDHELP: cannot be used to remove owners (+n) from the channel, and cannot be used
13 * CMDHELP: to remove masters (+m) unless the user issuing the command is an owner.
14 * CMDHELP: Where:
15 * CMDHELP: channel - channel to use
16 * CMDHELP: user<n> - a user to remove. Can either be a nickname on the network
17 * CMDHELP: or #authname. Up to 18 users can be specified.
18 * CMDHELP: REMOVEUSER requires master (+m) access on the named channel.
19 */
20
21 #include "../chanserv.h"
22 #include "../../nick/nick.h"
23 #include "../../lib/flags.h"
24 #include "../../lib/irc_string.h"
25 #include "../../channel/channel.h"
26 #include "../../parser/parser.h"
27 #include "../../irc/irc.h"
28 #include "../../localuser/localuserchannel.h"
29 #include <string.h>
30 #include <stdio.h>
31
32 int csc_doremoveuser(void *source, int cargc, char **cargv) {
33 nick *sender=source;
34 chanindex *cip;
35 regchanuser *rcup;
36 regchan *rcp;
37 reguser *rup;
38 int isowner=0;
39 int removed=0;
40 int i;
41
42 if (cargc<2) {
43 chanservstdmessage(sender, QM_NOTENOUGHPARAMS, "removeuser");
44 return CMD_ERROR;
45 }
46
47 if (!(cip=cs_checkaccess(sender, cargv[0], CA_MASTERPRIV, NULL, "removeuser", QPRIV_CHANGECHANLEV, 0)))
48 return CMD_ERROR;
49
50 if (cs_checkaccess(sender, NULL, CA_OWNERPRIV, cip, "removeuser", QPRIV_CHANGECHANLEV, 1))
51 isowner=1;
52
53 rcp=cip->exts[chanservext];
54
55 for (i=1;i<cargc;i++) {
56 if (!(rup=findreguser(sender, cargv[i])))
57 continue;
58
59 if (!(rcup=findreguseronchannel(rcp, rup))) {
60 chanservstdmessage(sender, QM_CHANUSERUNKNOWN, cargv[i], cip->name->content);
61 continue;
62 }
63
64 if (CUIsOwner(rcup) && !cs_privcheck(QPRIV_CHANGECHANLEV, sender)) {
65 chanservstdmessage(sender, QM_CANNOTREMOVEOWNER, cargv[i], cip->name->content);
66 continue;
67 }
68
69 if (CUIsMaster(rcup) && !isowner && (rup != getreguserfromnick(sender))) {
70 chanservstdmessage(sender, QM_CANNOTREMOVEMASTER, cargv[i], cip->name->content);
71 continue;
72 }
73
74 cs_log(sender,"CHANLEV %s #%s -%s (%s -> +)",cip->name->content,rup->username,
75 printflags_noprefix(rcup->flags, rcuflags), printflags(rcup->flags, rcuflags));
76
77 csdb_deletechanuser(rcup);
78 delreguserfromchannel(rcp, rup);
79 csdb_chanlevhistory_insert(rcp, sender, rcup->user, rcup->flags, 0);
80 removed++;
81 }
82
83 rcp->status |= QCSTAT_OPCHECK;
84 cs_timerfunc(cip);
85
86 if (removed) {
87 if (cs_removechannelifempty(sender, rcp)) {
88 chanservstdmessage(sender, QM_CHANLEVEMPTIEDCHANNEL);
89 } else {
90 chanservstdmessage(sender, QM_DONE);
91 }
92 }
93
94 return CMD_OK;
95 }