]>
Commit | Line | Data |
---|---|---|
1dd6d55d | 1 | /* Automatically generated by refactor.pl. |
2 | * | |
3 | * | |
4 | * CMDNAME: tempban | |
5 | * CMDLEVEL: QCMD_AUTHED | |
6 | * CMDARGS: 4 | |
7 | * CMDDESC: Bans a hostmask on a channel for a specified time period. | |
8 | * CMDFUNC: csc_dotempban | |
9 | * CMDPROTO: int csc_dotempban(void *source, int cargc, char **cargv); | |
10 | */ | |
11 | ||
12 | #include "../chanserv.h" | |
13 | #include "../../nick/nick.h" | |
14 | #include "../../lib/flags.h" | |
15 | #include "../../lib/irc_string.h" | |
16 | #include "../../channel/channel.h" | |
17 | #include "../../parser/parser.h" | |
18 | #include "../../irc/irc.h" | |
19 | #include "../../localuser/localuserchannel.h" | |
20 | #include <string.h> | |
21 | #include <stdio.h> | |
22 | ||
23 | int csc_dotempban(void *source, int cargc, char **cargv) { | |
24 | nick *sender=source; | |
25 | chanindex *cip; | |
26 | regban *rbp; | |
27 | regchan *rcp; | |
28 | reguser *rup=getreguserfromnick(sender); | |
29 | unsigned int duration; | |
30 | ||
31 | if (cargc<3) { | |
32 | chanservstdmessage(sender, QM_NOTENOUGHPARAMS, "tempban"); | |
33 | return CMD_ERROR; | |
34 | } | |
35 | ||
36 | if (!(cip=cs_checkaccess(sender, cargv[0], CA_MASTERPRIV, NULL, "tempban",0, 0))) | |
37 | return CMD_ERROR; | |
38 | ||
39 | rcp=cip->exts[chanservext]; | |
40 | ||
41 | duration=durationtolong(cargv[2]); | |
42 | ||
43 | rbp=getregban(); | |
44 | rbp->ID=++lastbanID; | |
45 | rbp->cbp=makeban(cargv[1]); | |
46 | rbp->setby=rup->ID; | |
47 | rbp->expiry=time(NULL)+duration; | |
48 | if (cargc>3) | |
49 | rbp->reason=getsstring(cargv[3],200); | |
50 | else | |
51 | rbp->reason=NULL; | |
52 | rbp->next=rcp->bans; | |
53 | rcp->bans=rbp; | |
54 | ||
55 | cs_setregban(cip, rbp); | |
56 | csdb_createban(rcp, rbp); | |
57 | ||
58 | chanservstdmessage(sender, QM_DONE); | |
59 | return CMD_OK; | |
60 | } |