]>
Commit | Line | Data |
---|---|---|
1dd6d55d | 1 | /* Automatically generated by refactor.pl. |
2 | * | |
3 | * | |
4 | * CMDNAME: delchan | |
5 | * CMDLEVEL: QCMD_OPER | |
6 | * CMDARGS: 2 | |
7 | * CMDDESC: Removes a channel from the bot. | |
8 | * CMDFUNC: csc_dodelchan | |
9 | * CMDPROTO: int csc_dodelchan(void *source, int cargc, char **cargv); | |
86001668 CP |
10 | * CMDHELP: Usage: delchan <channel> <reason> |
11 | * CMDHELP: Removes a channel from the bot. | |
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_dodelchan(void *source, int cargc, char **cargv) { | |
26 | nick *sender=source; | |
27 | reguser *rup=getreguserfromnick(sender); | |
28 | chanindex *cip; | |
29 | regchan *rcp; | |
86001668 CP |
30 | char *reason; |
31 | char buf[512]; | |
1dd6d55d | 32 | |
33 | if (!rup) | |
34 | return CMD_ERROR; | |
35 | ||
86001668 | 36 | if (cargc<2) { |
1dd6d55d | 37 | chanservstdmessage(sender, QM_NOTENOUGHPARAMS, "delchan"); |
38 | return CMD_ERROR; | |
39 | } | |
40 | ||
86001668 CP |
41 | reason = cargv[1]; |
42 | if(!checkreason(sender, reason)) | |
43 | return CMD_ERROR; | |
44 | ||
1dd6d55d | 45 | if (!(cip=findchanindex(cargv[0])) || !(rcp=cip->exts[chanservext])) { |
46 | chanservstdmessage(sender, QM_UNKNOWNCHAN, cargv[0]); | |
47 | return CMD_ERROR; | |
48 | } | |
49 | ||
78fdeaf6 CP |
50 | if (rcp->ID == lastchannelID) { |
51 | chanservsendmessage(sender, "Sorry, can't delete last channel -- wait a while and try again."); | |
52 | return CMD_ERROR; | |
53 | } | |
54 | ||
86001668 CP |
55 | cs_log(sender,"DELCHAN %s (%s)",cip->name->content,reason); |
56 | chanservwallmessage("%s (%s) just used DELCHAN on %s (reason: %s)", sender->nick, rup->username, cip->name->content, reason); | |
57 | snprintf(buf, sizeof(buf), "Channel deleted: %s", reason); | |
58 | cs_removechannel(rcp, buf); | |
1dd6d55d | 59 | chanservstdmessage(sender, QM_DONE); |
60 | ||
61 | return CMD_OK; | |
62 | } |