1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd is copyright (C) 2002-2006 ChatSpike-Dev.
7 * <brain@chatspike.net>
8 * <Craig@chatspike.net>
10 * Written by Craig Edwards, Craig McLure, and others.
11 * This program is free but copyrighted software; see
12 * the file COPYING for details.
14 * ---------------------------------------------------
19 #include "inspircd_config.h"
21 #include "inspircd_io.h"
32 #include "inspstring.h"
33 #include "helperfuncs.h"
36 #include "command_parse.h"
37 #include "cmd_invite.h"
39 extern ServerConfig* Config;
41 extern std::vector<Module*> modules;
42 extern std::vector<ircd_module*> factory;
44 void cmd_invite::Handle (char **parameters, int pcnt, userrec *user)
48 userrec* u = Find(parameters[0]);
49 chanrec* c = FindChan(parameters[1]);
55 WriteServ(user->fd,"401 %s %s :No such nick/channel",user->nick, parameters[1]);
59 WriteServ(user->fd,"401 %s %s :No such nick/channel",user->nick, parameters[0]);
65 if (c->binarymodes & CM_INVITEONLY)
67 if (cstatus(user,c) < STATUS_HOP)
69 WriteServ(user->fd,"482 %s %s :You must be at least a half-operator to change modes on this channel",user->nick, c->name);
75 WriteServ(user->fd,"443 %s %s %s :Is already on channel %s",user->nick,u->nick,c->name,c->name);
78 if (!has_channel(user,c))
80 WriteServ(user->fd,"442 %s %s :You're not on that channel!",user->nick, c->name);
85 FOREACH_RESULT(I_OnUserPreInvite,OnUserPreInvite(user,u,c));
86 if (MOD_RESULT == 1) {
90 irc::string xname(c->name);
92 WriteFrom(u->fd,user,"INVITE %s :%s",u->nick,c->name);
93 WriteServ(user->fd,"341 %s %s %s",user->nick,u->nick,c->name);
94 FOREACH_MOD(I_OnUserInvite,OnUserInvite(user,u,c));
98 // pinched from ircu - invite with not enough parameters shows channels
99 // youve been invited to but haven't joined yet.
100 InvitedList* il = user->GetInviteList();
101 for (InvitedList::iterator i = il->begin(); i != il->end(); i++)
103 WriteServ(user->fd,"346 %s :%s",user->nick,i->channel.c_str());
105 WriteServ(user->fd,"347 %s :End of INVITE list",user->nick);