]>
jfr.im git - irc/quakenet/newserv.git/blob - chanserv/chancmds/renchan.c
1 /* Automatically generated by refactor.pl.
7 * CMDDESC: Renames a channel on the bot.
8 * CMDFUNC: csc_dorenchan
9 * CMDPROTO: int csc_dorenchan(void *source, int cargc, char **cargv);
10 * CMDHELP: Usage: renchan <old channel> <new channel>
11 * CMDHELP: Moves the bot from one channel to another, preserving flags.
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"
25 int csc_dorenchan(void *source
, int cargc
, char **cargv
) {
27 reguser
*rup
=getreguserfromnick(sender
);
28 chanindex
*cip1
,*cip2
;
35 chanservstdmessage(sender
, QM_NOTENOUGHPARAMS
, "renchan");
39 if (!(cip1
=findchanindex(cargv
[0])) || !(rcp
=cip1
->exts
[chanservext
])) {
40 chanservstdmessage(sender
, QM_UNKNOWNCHAN
, cargv
[0]);
44 if (*cargv
[1] != '#') {
45 chanservstdmessage(sender
, QM_INVALIDCHANNAME
, cargv
[0]);
49 if (!(cip2
=findorcreatechanindex(cargv
[1])) || cip2
->exts
[chanservext
]) {
50 chanservstdmessage(sender
, QM_ALREADYREGISTERED
, cip2
->name
->content
);
54 cs_log(sender
,"RENCHAN %s -> %s",cip1
->name
->content
,cip2
->name
->content
);
56 /* Remove from the channel. Don't bother if the channel doesn't exist. */
57 if (!CIsSuspended(rcp
) && cip1
->channel
) {
59 chanservjoinchan(cip1
->channel
);
63 cip1
->exts
[chanservext
]=NULL
;
64 releasechanindex(cip1
);
66 cip2
->exts
[chanservext
]=rcp
;
69 chanservjoinchan(cip2
->channel
);
72 csdb_updatechannel(rcp
);
73 chanservstdmessage(sender
, QM_DONE
);