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