]>
jfr.im git - irc/quakenet/newserv.git/blob - chanserv/chancmds/permban.c
1 /* Automatically generated by refactor.pl.
6 * CMDLEVEL: QCMD_AUTHED
8 * CMDDESC: Permanently bans a hostmask on a channel.
9 * CMDFUNC: csc_dopermban
10 * CMDPROTO: int csc_dopermban(void *source, int cargc, char **cargv);
11 * CMDHELP: Usage: @UCOMMAND@ <channel> <hostmask> [<reason>]
12 * CMDHELP: Permanently bans the provided hostmask on the channel. If the ban is
13 * CMDHELP: removed from the channel e.g. by a channel op or the BANTIMER feature, the
14 * CMDHELP: ban will be reapplied if a matching user joins the channel. Bans
15 * CMDHELP: set with the @UCOMMAND@ command can be removed with BANCLEAR or BANDEL. Any users
16 * CMDHELP: matching the hostmask will be kicked from the channel.
18 * CMDHELP: channel - channel to set a ban on
19 * CMDHELP: hostmask - hostmask (nick!user@host) to ban.
20 * CMDHELP: reason - reason for the ban. This will be used in kick messages when kicking
21 * CMDHELP: users matching the ban. If this is not provided the generic message
22 * CMDHELP: \"Banned.\" will be used.
23 * CMDHELP: @UCOMMAND@ requires master (+m) access on the named channel.
26 #include "../chanserv.h"
27 #include "../../nick/nick.h"
28 #include "../../lib/flags.h"
29 #include "../../lib/irc_string.h"
30 #include "../../channel/channel.h"
31 #include "../../parser/parser.h"
32 #include "../../irc/irc.h"
33 #include "../../localuser/localuserchannel.h"
37 int csc_dopermban(void *source
, int cargc
, char **cargv
) {
40 regban
*rbp
, *toreplace
=NULL
;
42 reguser
*rup
=getreguserfromnick(sender
);
45 unsigned int count
= 0;
48 chanservstdmessage(sender
, QM_NOTENOUGHPARAMS
, "permban");
52 if (!(cip
=cs_checkaccess(sender
, cargv
[0], CA_MASTERPRIV
, NULL
, "permban",0, 0)))
55 rcp
=cip
->exts
[chanservext
];
57 /* saves us having to do repeat a LOT more sanity checking *wink* *wink* */
59 snprintf(banbuf
,sizeof(banbuf
),"%s",bantostring(b
));
63 for(rbp
=rcp
->bans
;rbp
;rbp
=rbp
->next
) {
65 if(banequal(b
,rbp
->cbp
)) { /* if they're equal and one is temporary we just replace it */
67 if(toreplace
) { /* shouldn't happen */
68 chanservsendmessage(sender
, "Internal error, duplicate bans found on banlist.");
74 chanservstdmessage(sender
, QM_PERMBANALREADYSET
);
76 } else if(banoverlap(rbp
->cbp
,b
)) { /* new ban is contained in an already existing one */
77 chanservstdmessage(sender
, QM_NEWBANALREADYBANNED
, bantostring(rbp
->cbp
));
78 }else if(banoverlap(b
,rbp
->cbp
)) { /* existing ban is contained in new one */
79 chanservstdmessage(sender
, QM_NEWBANOVERLAPS
, bantostring(rbp
->cbp
), banbuf
);
87 if(count
>= MAXBANS
) {
88 /* HACK: oper founder channels have 20x the ban limit */
89 reguser
*founder
=findreguserbyID(rcp
->founder
);
90 if(!founder
|| !UHasOperPriv(founder
) || count
>= MAXBANS
* 20) {
92 chanservstdmessage(sender
, QM_TOOMANYBANS
);
99 chanservstdmessage(sender
, QM_REPLACINGTEMPBAN
);
103 freesstring(toreplace
->reason
);
116 rbp
->reason
=getsstring(cargv
[2],200);
120 cs_setregban(cip
, rbp
);
122 csdb_updateban(rcp
, rbp
);
124 csdb_createban(rcp
, rbp
);
126 chanservstdmessage(sender
, QM_DONE
);