]> jfr.im git - irc/quakenet/newserv.git/blame - chanserv/chancmds/autolimit.c
Implement --help parameter.
[irc/quakenet/newserv.git] / chanserv / chancmds / autolimit.c
CommitLineData
1dd6d55d 1/* Automatically generated by refactor.pl.
2 *
3 *
4 * CMDNAME: autolimit
5 * CMDLEVEL: QCMD_AUTHED
6 * CMDARGS: 2
7 * CMDDESC: Shows or changes the autolimit threshold on a channel.
8 * CMDFUNC: csc_doautolimit
9 * CMDPROTO: int csc_doautolimit(void *source, int cargc, char **cargv);
cabd7271 10 * CMDHELP: Usage: AUTOLIMIT <channel> [<threshold>]
0a53499c 11 * CMDHELP: The autolimit feature maintains a user limit (+l) on the channel which is
12 * CMDHELP: regularly updated to keep a fixed number of spaces free on the channel for
13 * CMDHELP: people to join. This is useful since it prevents a large number of \"clones\"
14 * CMDHELP: joining at the same time. However, if the number of free spaces is too small
15 * CMDHELP: it's possible that legitimate users won't be able to join. This command allows
16 * CMDHELP: you to adjust the number of free spaces to maintain when autolimit is enabled.
17 * CMDHELP: To actually turn the autolimit feature on or off, see CHANFLAGS. Where:
cabd7271 18 * CMDHELP: channel - the channel to use.
19 * CMDHELP: threshold - specifies the new threshold. If not specified, the current threshold
20 * CMDHELP: is displayed.
21 * CMDHELP: Viewing the current threshold requires operator (+o) access on the named channel.
22 * CMDHELP: Updating the threshold requires master (+m) access on the named channel.
1dd6d55d 23 */
24
25#include "../chanserv.h"
26#include "../../nick/nick.h"
27#include "../../lib/flags.h"
28#include "../../lib/irc_string.h"
29#include "../../channel/channel.h"
30#include "../../parser/parser.h"
31#include "../../irc/irc.h"
32#include "../../localuser/localuserchannel.h"
33#include <string.h>
34#include <stdio.h>
35
36int csc_doautolimit(void *source, int cargc, char **cargv) {
37 nick *sender=source;
38 chanindex *cip;
39 regchan *rcp;
40 int oldlimit;
41
42 if (cargc<1) {
43 chanservstdmessage(sender, QM_NOTENOUGHPARAMS, "autolimit");
44 return CMD_ERROR;
45 }
46
47 if (!(cip=cs_checkaccess(sender, cargv[0], CA_OPPRIV,
48 NULL, "autolimit", QPRIV_VIEWAUTOLIMIT, 0)))
49 return CMD_ERROR;
50
51 rcp=cip->exts[chanservext];
52
53 if (cargc>1) {
54 if (!cs_checkaccess(sender, NULL, CA_MASTERPRIV,
55 cip, "autolimit", QPRIV_CHANGEAUTOLIMIT, 0))
56 return CMD_ERROR;
57
58 oldlimit=rcp->autolimit;
59 rcp->autolimit=strtol(cargv[1],NULL,10);
fdedb559
CP
60 if (rcp->autolimit<1) {
61 rcp->autolimit=oldlimit;
62 chanservstdmessage(sender, QM_INVALIDLIMIT, cargv[1]);
63 return CMD_ERROR;
64 }
1dd6d55d 65
66 csdb_updatechannel(rcp);
67
68 cs_log(sender,"AUTOLIMIT %s %s (%d -> %d)",cip->name->content,cargv[1],oldlimit,rcp->autolimit);
69 chanservstdmessage(sender, QM_DONE);
70 rcp->limit=0;
71 cs_timerfunc(cip);
72 }
73
74 chanservstdmessage(sender, QM_CHANAUTOLIMIT, cargv[0], rcp->autolimit);
75 return CMD_OK;
76}