]> jfr.im git - irc/quakenet/newserv.git/blame - chanserv/chancmds/invite.c
Update the help for INVITE to reflect new functionality.
[irc/quakenet/newserv.git] / chanserv / chancmds / invite.c
CommitLineData
1dd6d55d 1/* Automatically generated by refactor.pl.
2 *
3 *
4 * CMDNAME: invite
5 * CMDLEVEL: QCMD_AUTHED
6 * CMDARGS: 1
c6b444ed 7 * CMDDESC: Invites you to a channel or channels.
1dd6d55d 8 * CMDFUNC: csc_doinvite
9 * CMDPROTO: int csc_doinvite(void *source, int cargc, char **cargv);
c6b444ed 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.
1e32d528 15 * CMDHELP: INVITE requires you to be known (+k) on the named channel.
1dd6d55d 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
29int csc_doinvite(void *source, int cargc, char **cargv) {
30 nick *sender=source;
31 chanindex *cip;
32
704eb127 33 /* If no argument supplied, try and invite the user to every channel
34 * we can. */
1dd6d55d 35 if (cargc<1) {
704eb127 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;
1dd6d55d 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}