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 * ---------------------------------------------------
17 #include "configreader.h"
20 #include "commands/cmd_invite.h"
22 void cmd_invite::Handle (const char** parameters, int pcnt, userrec *user)
28 userrec* u = ServerInstance->FindNick(parameters[0]);
29 chanrec* c = ServerInstance->FindChan(parameters[1]);
35 user->WriteServ("401 %s %s :No such nick/channel",user->nick, parameters[1]);
39 user->WriteServ("401 %s %s :No such nick/channel",user->nick, parameters[0]);
45 if ((c->modes[CM_INVITEONLY]) && (IS_LOCAL(user)))
47 if (c->GetStatus(user) < STATUS_HOP)
49 user->WriteServ("482 %s %s :You must be at least a half-operator to change modes on this channel",user->nick, c->name);
56 user->WriteServ("443 %s %s %s :Is already on channel %s",user->nick,u->nick,c->name,c->name);
60 if ((IS_LOCAL(user)) && (!c->HasUser(user)))
62 user->WriteServ("442 %s %s :You're not on that channel!",user->nick, c->name);
66 FOREACH_RESULT(I_OnUserPreInvite,OnUserPreInvite(user,u,c));
73 irc::string xname(c->name);
75 u->WriteFrom(user,"INVITE %s :%s",u->nick,c->name);
76 user->WriteServ("341 %s %s %s",user->nick,u->nick,c->name);
77 FOREACH_MOD(I_OnUserInvite,OnUserInvite(user,u,c));
81 // pinched from ircu - invite with not enough parameters shows channels
82 // youve been invited to but haven't joined yet.
83 InvitedList* il = user->GetInviteList();
84 for (InvitedList::iterator i = il->begin(); i != il->end(); i++)
86 user->WriteServ("346 %s :%s",user->nick,i->channel.c_str());
88 user->WriteServ("347 %s :End of INVITE list",user->nick);