]>
Commit | Line | Data |
---|---|---|
1dd6d55d | 1 | /* Automatically generated by refactor.pl. |
2 | * | |
3 | * | |
4 | * CMDNAME: suspendchan | |
5 | * CMDLEVEL: QCMD_OPER | |
6 | * CMDARGS: 2 | |
7 | * CMDDESC: Suspends a channel from the bot. | |
8 | * CMDFUNC: csc_dosuspendchan | |
9 | * CMDPROTO: int csc_dosuspendchan(void *source, int cargc, char **cargv); | |
94e4d2f4 CP |
10 | * CMDHELP: Usage: suspendchan <channel> [<reason>] |
11 | * CMDHELP: Suspends the specified channel, with an optional reason. | |
1dd6d55d | 12 | */ |
13 | ||
14 | #include "../chanserv.h" | |
15 | #include "../../nick/nick.h" | |
16 | #include "../../lib/flags.h" | |
17 | #include "../../lib/irc_string.h" | |
18 | #include "../../channel/channel.h" | |
19 | #include "../../parser/parser.h" | |
20 | #include "../../irc/irc.h" | |
21 | #include "../../localuser/localuserchannel.h" | |
22 | #include <string.h> | |
23 | #include <stdio.h> | |
24 | ||
25 | int csc_dosuspendchan(void *source, int cargc, char **cargv) { | |
26 | nick *sender=source; | |
27 | reguser *rup=getreguserfromnick(sender); | |
28 | chanindex *cip; | |
29 | regchan *rcp; | |
30 | ||
31 | if (!rup) | |
32 | return CMD_ERROR; | |
33 | ||
34 | if (cargc<2) { | |
35 | chanservstdmessage(sender, QM_NOTENOUGHPARAMS, "suspendchan"); | |
36 | return CMD_ERROR; | |
37 | } | |
38 | ||
39 | if (!(cip=findchanindex(cargv[0])) || !(rcp=cip->exts[chanservext])) { | |
40 | chanservstdmessage(sender, QM_UNKNOWNCHAN, cargv[0]); | |
41 | return CMD_ERROR; | |
42 | } | |
43 | ||
44 | if (CIsSuspended(rcp)) { | |
45 | chanservstdmessage(sender, QM_CHANNELALREADYSUSPENDED, cip->name->content); | |
46 | return CMD_ERROR; | |
47 | } | |
48 | ||
49 | CSetSuspended(rcp); | |
50 | rcp->suspendreason = getsstring(cargv[1], 250); | |
51 | rcp->suspendby = rup->ID; | |
c1e6c982 | 52 | rcp->suspendtime = time(NULL); |
1dd6d55d | 53 | cs_log(sender,"SUSPENDCHAN %s (%s)",cip->name->content,rcp->suspendreason->content); |
9d53322f CP |
54 | if(cip->channel) |
55 | chanservjoinchan(cip->channel); | |
1dd6d55d | 56 | |
57 | csdb_updatechannel(rcp); | |
58 | chanservstdmessage(sender, QM_DONE); | |
59 | ||
60 | return CMD_OK; | |
61 | } |