]> jfr.im git - irc/quakenet/newserv.git/blob - chanserv/chancmds/invite.c
Update the help for INVITE to reflect new functionality.
[irc/quakenet/newserv.git] / chanserv / chancmds / invite.c
1 /* Automatically generated by refactor.pl.
2 *
3 *
4 * CMDNAME: invite
5 * CMDLEVEL: QCMD_AUTHED
6 * CMDARGS: 1
7 * CMDDESC: Invites you to a channel or channels.
8 * CMDFUNC: csc_doinvite
9 * CMDPROTO: int csc_doinvite(void *source, int cargc, char **cargv);
10 * CMDHELP: Usage: INVITE [<channel>]
11 * CMDHELP: Invites you to one or more channels, where:
12 * CMDHELP: channel - channel to be invited to. If no channel is specified,
13 * CMDHELP: you will be invited to all channels where you have
14 * CMDHELP: appropriate access and are not already joined.
15 * CMDHELP: INVITE requires you to be known (+k) on the named channel.
16 */
17
18 #include "../chanserv.h"
19 #include "../../nick/nick.h"
20 #include "../../lib/flags.h"
21 #include "../../lib/irc_string.h"
22 #include "../../channel/channel.h"
23 #include "../../parser/parser.h"
24 #include "../../irc/irc.h"
25 #include "../../localuser/localuserchannel.h"
26 #include <string.h>
27 #include <stdio.h>
28
29 int csc_doinvite(void *source, int cargc, char **cargv) {
30 nick *sender=source;
31 chanindex *cip;
32
33 /* If no argument supplied, try and invite the user to every channel
34 * we can. */
35 if (cargc<1) {
36 reguser *rup=getreguserfromnick(sender);
37 regchanuser *rcup;
38
39 if (!rup)
40 return CMD_ERROR;
41
42 for (rcup=rup->knownon;rcup;rcup=rcup->nextbyuser) {
43 /* skip empty or suspended channels */
44 if (!rcup->chan->index->channel || CIsSuspended(rcup->chan)) {
45 continue;
46 }
47
48 /* skip channels the user is already on */
49 if (getnumerichandlefromchanhash(rcup->chan->index->channel->users, sender->numeric)) {
50 continue;
51 }
52
53 /* skip channels where the user can't do INVITE */
54 if (!CUKnown(rcup)) {
55 continue;
56 }
57
58 localinvite(chanservnick, rcup->chan->index->channel, sender);
59 }
60
61 chanservstdmessage(sender, QM_DONE);
62 return CMD_OK;
63 }
64
65 if (!(cip=cs_checkaccess(sender, cargv[0], CA_KNOWN | CA_OFFCHAN,
66 NULL, "invite", 0, 0)))
67 return CMD_ERROR;
68
69 if (cip->channel) {
70 localinvite(chanservnick, cip->channel, sender);
71 }
72 chanservstdmessage(sender, QM_DONE);
73
74 return CMD_OK;
75 }