]>
jfr.im git - irc/quakenet/newserv.git/blob - chanserv/usercmds/suspenduser.c
1 /* Automatically generated by refactor.pl.
7 * CMDDESC: Suspend/delay GLINE/instantly GLINE a user.
8 * CMDFUNC: csu_dosuspenduser
9 * CMDPROTO: int csu_dosuspenduser(void *source, int cargc, char **cargv);
10 * CMDHELP: Usage: suspenduser <username> [<duration>] <reason>
11 * CMDHELP: -nokill <username> [<duration>] <reason>
12 * CMDHELP: -gline <username> [<duration>] <reason>
13 * CMDHELP: -instantgline <username> [<duration>] <reason>
14 * CMDHELP: Suspends the user with the specified username.
15 * CMDHELP: By default the user will be immediately disconnected unless
16 * CMDHELP: nokill is specified.
17 * CMDHELP: gline will gline the user at some random period of time after
18 * CMDHELP: they auth, instantgline will gline them the moment they auth.
21 #include "../chanserv.h"
22 #include "../../lib/irc_string.h"
26 static int killtheusers(nick
*sender
, reguser
*rup
) {
30 if (!(anp
=findauthname(rup
->ID
)))
34 chanservstdmessage(sender
, QM_DISCONNECTINGUSER
, anp
->nicks
->nick
, rup
->username
);
35 chanservkillstdmessage(anp
->nicks
, QM_SUSPENDKILL
);
42 int csu_dosuspenduser(void *source
, int cargc
, char **cargv
) {
44 reguser
*rup
=getreguserfromnick(sender
);
53 char expiresbuf
[TIMELEN
]="";
60 chanservstdmessage(sender
, QM_NOTENOUGHPARAMS
, "suspenduser");
64 if (cargv
[0][0] == '-') {
66 if (!(victim
=strchr(flag
, ' '))) {
67 chanservstdmessage(sender
, QM_NOTENOUGHPARAMS
, "suspenduser");
71 if (!(dur_p
=strchr(victim
, ' '))) {
72 chanservstdmessage(sender
, QM_NOTENOUGHPARAMS
, "suspenduser");
76 if ((reason
=strchr(dur_p
, ' '))) {
78 if ((duration
=durationtolong(dur_p
))) {
79 if ((duration
< 86400) || (duration
> 2592000)) {
80 chanservstdmessage(sender
, QM_INVALIDDURATION
);
83 expires
=time(0)+duration
;
96 if (!ircd_strcmp(flag
, "-nokill")) {
99 else if (!ircd_strcmp(flag
, "-gline")) {
102 else if (!ircd_strcmp(flag
, "-instantgline")) {
106 chanservstdmessage(sender
, QM_INVALIDCHANLEVCHANGE
);
112 if (!(dur_p
=strchr(victim
, ' '))) {
113 chanservstdmessage(sender
, QM_NOTENOUGHPARAMS
, "suspenduser");
117 if ((reason
=strchr(dur_p
, ' '))) {
119 if ((duration
=durationtolong(dur_p
))) {
120 if ((duration
< 86400) || (duration
> 2592000)) {
121 chanservstdmessage(sender
, QM_INVALIDDURATION
);
124 expires
=time(0)+duration
;
138 if(!checkreason(sender
, reason
))
142 q9strftime(expiresbuf
,sizeof(expiresbuf
),expires
);
144 if (!(vrup
=findreguser(sender
, victim
)))
147 if (!ircd_strcmp(vrup
->username
, rup
->username
)) {
148 chanservsendmessage(sender
, "You can't suspend yourself, silly.");
152 if (UHasSuspension(vrup
)) {
153 chanservstdmessage(sender
, QM_USERALREADYSUSPENDED
);
157 if (UHasStaffPriv(vrup
)) {
159 snprintf(buf
, sizeof(buf
), "suspenduser on %s (reason: %s)", vrup
->username
, reason
);
160 chanservstdmessage(sender
, QM_NOACCESS
, buf
);
161 chanservwallmessage("%s (%s) FAILED to SUSPENDUSER %s (reason: %s)", sender
->nick
, rup
->username
, vrup
->username
, reason
);
166 vrup
->flags
|=QUFLAG_GLINE
;
168 vrup
->flags
|=QUFLAG_DELAYEDGLINE
;
170 vrup
->flags
|=QUFLAG_SUSPENDED
;
171 vrup
->suspendby
=rup
->ID
;
172 vrup
->suspendexp
=expires
;
173 vrup
->suspendtime
=time(NULL
);
174 vrup
->suspendreason
=getsstring(reason
, strlen(reason
)+1);
176 stype
= (gline
)?((gline
== 2)?"instant gline":"delayed gline"):"normal";
178 chanservwallmessage("%s (%s) used SUSPENDUSER on %s, type: %s, expires: %s, reason: %s", sender
->nick
, rup
->username
, vrup
->username
, stype
, expires
?expiresbuf
:"never", reason
);
179 cs_log(sender
, "SUSPENDUSER %s (%s, expires: %s, reason: %s)", vrup
->username
, stype
, expires
?expiresbuf
:"never", reason
);
182 dgwait
=(gline
==2)?0:rand()%900
;
183 chanservsendmessage(sender
, "Scheduling delayed GLINE for account %s in %d %s",
184 vrup
->username
, (dgwait
>60)?(dgwait
/60):dgwait
, (dgwait
>60)?"minutes":"seconds");
185 deleteschedule(NULL
, &chanservdgline
, (void*)vrup
);
186 scheduleoneshot(time(NULL
)+dgwait
, &chanservdgline
, (void*)vrup
);
189 killtheusers(sender
,vrup
);
192 csdb_updateuser(vrup
);