]> jfr.im git - irc/quakenet/newserv.git/blame - chanserv/chancmds/rejoin.c
A4STATS: remove E style escapes and switch to createtable for indices
[irc/quakenet/newserv.git] / chanserv / chancmds / rejoin.c
CommitLineData
1dd6d55d 1/* Automatically generated by refactor.pl.
2 *
3 *
4 * CMDNAME: rejoin
5 * CMDLEVEL: QCMD_OPER
6 * CMDARGS: 1
7 * CMDDESC: Makes the bot rejoin a channel.
8 * CMDFUNC: csc_dorejoin
9 * CMDPROTO: int csc_dorejoin(void *source, int cargc, char **cargv);
94e4d2f4
CP
10 * CMDHELP: Usage: rejoin <channel>
11 * CMDHELP: Makes the bot rejoin the specified channel.
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
25int csc_dorejoin(void *source, int cargc, char **cargv) {
26 nick *sender=source;
27 chanindex *cip;
28 regchan *rcp;
29
30 if (cargc<1) {
31 chanservstdmessage(sender, QM_NOTENOUGHPARAMS, "rejoin");
32 return CMD_ERROR;
33 }
34
35 if (!(cip=findchanindex(cargv[0])) || !(rcp=cip->exts[chanservext])) {
36 chanservstdmessage(sender, QM_UNKNOWNCHAN, cargv[0]);
37 return CMD_ERROR;
38 }
7050de1d 39
40 if (!cip->channel) {
41 chanservstdmessage(sender, QM_EMPTYCHAN, cip->name->content);
42 return CMD_ERROR;
43 }
1dd6d55d 44
45 if (CIsJoined(rcp) && !CIsSuspended(rcp)) {
46 CSetSuspended(rcp);
47 chanservjoinchan(cip->channel);
48 CClearSuspended(rcp);
4807b4c3 49 /* Parting the channel may have destroyed it. In that case, don't bother rejoining. */
50 if (cip->channel)
51 chanservjoinchan(cip->channel);
1dd6d55d 52 }
53
54 chanservstdmessage(sender, QM_DONE);
55
56 return CMD_OK;
57}