Anope IRC Services  Version 1.8
cs_invite.c
Go to the documentation of this file.
1 /* ChanServ core functions
2  *
3  * (C) 2003-2014 Anope Team
4  * Contact us at team@anope.org
5  *
6  * Please read COPYING and README for further details.
7  *
8  * Based on the original code of Epona by Lara.
9  * Based on the original code of Services by Andy Church.
10  *
11  *
12  */
13 /*************************************************************************/
14 
15 #include "module.h"
16 
17 static void myChanServHelp(User * u);
18 static int do_invite(User * u);
19 
26 int AnopeInit(int argc, char **argv)
27 {
28  Command *c;
29 
30  moduleAddAuthor("Anope");
31  moduleAddVersion(VERSION_STRING);
33 
34  c = createCommand("INVITE", do_invite, NULL, CHAN_HELP_INVITE, -1, -1,
35  -1, -1);
37 
39 
40  return MOD_CONT;
41 }
42 
46 void AnopeFini(void)
47 {
48 
49 }
50 
51 
52 
57 static void myChanServHelp(User * u)
58 {
59  notice_lang(s_ChanServ, u, CHAN_HELP_CMD_INVITE);
60 }
61 
67 static int do_invite(User * u)
68 {
69  char *chan = strtok(NULL, " ");
70  Channel *c;
71  ChannelInfo *ci;
72 
73  if (!chan) {
74  syntax_error(s_ChanServ, u, "INVITE", CHAN_INVITE_SYNTAX);
75  } else if (!(c = findchan(chan))) {
76  notice_lang(s_ChanServ, u, CHAN_X_NOT_IN_USE, chan);
77  } else if (!(ci = c->ci)) {
78  notice_lang(s_ChanServ, u, CHAN_X_NOT_REGISTERED, chan);
79  } else if (ci->flags & CI_VERBOTEN) {
80  notice_lang(s_ChanServ, u, CHAN_X_FORBIDDEN, chan);
81  } else if (ci->flags & CI_SUSPENDED) {
82  notice_lang(s_ChanServ, u, CHAN_X_FORBIDDEN, chan);
83  } else if (!u || !check_access(u, ci, CA_INVITE)) {
84  notice_lang(s_ChanServ, u, PERMISSION_DENIED);
85  } else {
86  anope_cmd_invite(whosends(ci), chan, u->nick);
87  }
88  return MOD_CONT;
89 }
#define CI_SUSPENDED
Definition: services.h:743
static void myChanServHelp(User *u)
Definition: cs_invite.c:57
char nick[NICKMAX]
Definition: services.h:875
E void anope_cmd_invite(char *source, char *chan, char *nick)
Definition: ircd.c:362
E int check_access(User *user, ChannelInfo *ci, int what)
Definition: chanserv.c:1974
#define CI_VERBOTEN
Definition: services.h:725
MDE void moduleAddAuthor(const char *author)
Definition: modules.c:1772
ChannelInfo * ci
Definition: services.h:1001
E void syntax_error(char *service, User *u, const char *command, int msgnum)
Definition: language.c:295
E void notice_lang(char *source, User *dest, int message,...)
Definition: send.c:169
MDE void moduleSetType(MODType type)
Definition: modules.c:818
E Channel * findchan(const char *chan)
Definition: channels.c:394
uint32 flags
Definition: services.h:669
#define CA_INVITE
Definition: services.h:749
MDE void moduleAddVersion(const char *version)
Definition: modules.c:1760
MDE void moduleSetChanHelp(void(*func)(User *u))
Definition: modules.c:2090
Command * c
Definition: ns_recover.c:17
#define CHANSERV
Definition: modules.h:60
static int do_invite(User *u)
Definition: cs_invite.c:67
#define MOD_CONT
Definition: modules.h:54
#define whosends(ci)
Definition: extern.h:163
void AnopeFini(void)
Definition: cs_invite.c:46
Definition: modules.h:99
MDE Command * createCommand(const char *name, int(*func)(User *u), int(*has_priv)(User *u), int help_all, int help_reg, int help_oper, int help_admin, int help_root)
Definition: modules.c:987
E char * s_ChanServ
Definition: extern.h:285
MDE int moduleAddCommand(CommandHash *cmdTable[], Command *c, int pos)
Definition: modules.c:1082
int AnopeInit(int argc, char **argv)
Definition: cs_invite.c:26
#define MOD_UNIQUE
Definition: module.h:11