]>
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); | |
1e32d528 | 10 | * CMDHELP: Usage: TEMPBAN <channel> <hostmask> <duration> [<reason>] |
11 | * CMDHELP: Temporarily bans the provided hostmask on the channel. If the ban is | |
12 | * CMDHELP: removed from the channel e.g. by a channel op or the BANTIMER feature, the | |
13 | * CMDHELP: ban will be reapplied if a matching user joins the channel. When the time | |
14 | * CMDHELP: expires the ban will be removed automatically. Bans set with the PERMBAN | |
15 | * CMDHELP: command can be removed via BANCLEAR or BANDEL. Any users matching the hostmask | |
16 | * CMDHELP: will be kicked from the channel. | |
17 | * CMDHELP: Where: | |
18 | * CMDHELP: channel - channel to set a ban on | |
19 | * CMDHELP: hostmask - hastmask (nick!user@host) to ban. | |
20 | * CMDHELP: duration - length of time to apply the ban for. Suffixes m (minutes), h (hours), | |
21 | * CMDHELP: d (days), w (weeks), M (months) and y (years) can be used to specify | |
22 | * CMDHELP: the duration, for example 3d, 5h, 1h30m, 1M. | |
23 | * CMDHELP: reason - reason for the ban. This will be used in kick messages when kicking | |
24 | * CMDHELP: users matching the ban. If this is not provided the generic message | |
25 | * CMDHELP: \"Banned.\" will be used. | |
26 | * CMDHELP: TEMPBAN requires master (+m) access on the named channel. | |
1dd6d55d | 27 | */ |
28 | ||
29 | #include "../chanserv.h" | |
30 | #include "../../nick/nick.h" | |
31 | #include "../../lib/flags.h" | |
32 | #include "../../lib/irc_string.h" | |
33 | #include "../../channel/channel.h" | |
34 | #include "../../parser/parser.h" | |
35 | #include "../../irc/irc.h" | |
36 | #include "../../localuser/localuserchannel.h" | |
37 | #include <string.h> | |
38 | #include <stdio.h> | |
39 | ||
40 | int csc_dotempban(void *source, int cargc, char **cargv) { | |
41 | nick *sender=source; | |
42 | chanindex *cip; | |
43 | regban *rbp; | |
44 | regchan *rcp; | |
45 | reguser *rup=getreguserfromnick(sender); | |
46 | unsigned int duration; | |
47 | ||
48 | if (cargc<3) { | |
49 | chanservstdmessage(sender, QM_NOTENOUGHPARAMS, "tempban"); | |
50 | return CMD_ERROR; | |
51 | } | |
52 | ||
53 | if (!(cip=cs_checkaccess(sender, cargv[0], CA_MASTERPRIV, NULL, "tempban",0, 0))) | |
54 | return CMD_ERROR; | |
55 | ||
56 | rcp=cip->exts[chanservext]; | |
57 | ||
58 | duration=durationtolong(cargv[2]); | |
cabd7271 | 59 | if (duration > 400000000) { |
60 | chanservstdmessage(sender, QM_DURATIONTOOLONG, cargv[2]); | |
61 | return CMD_ERROR; | |
62 | } | |
1dd6d55d | 63 | |
64 | rbp=getregban(); | |
65 | rbp->ID=++lastbanID; | |
66 | rbp->cbp=makeban(cargv[1]); | |
67 | rbp->setby=rup->ID; | |
68 | rbp->expiry=time(NULL)+duration; | |
69 | if (cargc>3) | |
70 | rbp->reason=getsstring(cargv[3],200); | |
71 | else | |
72 | rbp->reason=NULL; | |
73 | rbp->next=rcp->bans; | |
74 | rcp->bans=rbp; | |
75 | ||
76 | cs_setregban(cip, rbp); | |
77 | csdb_createban(rcp, rbp); | |
78 | ||
79 | chanservstdmessage(sender, QM_DONE); | |
80 | return CMD_OK; | |
81 | } |