]> jfr.im git - irc/quakenet/newserv.git/blob - chanserv/chancmds/delchan.c
CHANSERV: channel and user cleanup now 240/120 days
[irc/quakenet/newserv.git] / chanserv / chancmds / delchan.c
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);
10 * CMDHELP: Usage: delchan <channel> <reason>
11 * CMDHELP: Removes a channel from the bot.
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;
30 char *reason;
31 char buf[512];
32
33 if (!rup)
34 return CMD_ERROR;
35
36 if (cargc<2) {
37 chanservstdmessage(sender, QM_NOTENOUGHPARAMS, "delchan");
38 return CMD_ERROR;
39 }
40
41 reason = cargv[1];
42 if(!checkreason(sender, reason))
43 return CMD_ERROR;
44
45 if (!(cip=findchanindex(cargv[0])) || !(rcp=cip->exts[chanservext])) {
46 chanservstdmessage(sender, QM_UNKNOWNCHAN, cargv[0]);
47 return CMD_ERROR;
48 }
49
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
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);
59 chanservstdmessage(sender, QM_DONE);
60
61 return CMD_OK;
62 }