1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd: (C) 2002-2008 InspIRCd Development Team
6 * See: http://www.inspircd.org/wiki/index.php/Credits
8 * This program is free but copyrighted software; see
9 * the file COPYING for details.
11 * ---------------------------------------------------
15 #include "commands/cmd_invite.h"
17 extern "C" DllExport Command* init_command(InspIRCd* Instance)
19 return new CommandInvite(Instance);
24 CmdResult CommandInvite::Handle (const char* const* parameters, int pcnt, User *user)
28 if (pcnt == 2 || pcnt == 3)
30 User* u = ServerInstance->FindNick(parameters[0]);
31 Channel* c = ServerInstance->FindChan(parameters[1]);
35 timeout = time(NULL) + ServerInstance->Duration(parameters[2]);
42 user->WriteNumeric(401, "%s %s :No such nick/channel",user->nick, parameters[1]);
46 user->WriteNumeric(401, "%s %s :No such nick/channel",user->nick, parameters[0]);
52 if ((c->IsModeSet('i')) && (IS_LOCAL(user)))
54 if (c->GetStatus(user) < STATUS_HOP)
56 user->WriteNumeric(482, "%s %s :You must be a channel %soperator", user->nick, c->name, c->GetStatus(u) == STATUS_HOP ? "" : "half-");
63 user->WriteNumeric(443, "%s %s %s :is already on channel",user->nick,u->nick,c->name);
67 if ((IS_LOCAL(user)) && (!c->HasUser(user)))
69 user->WriteNumeric(442, "%s %s :You're not on that channel!",user->nick, c->name);
73 FOREACH_RESULT(I_OnUserPreInvite,OnUserPreInvite(user,u,c,timeout));
80 u->InviteTo(c->name, timeout);
81 u->WriteFrom(user,"INVITE %s :%s",u->nick,c->name);
82 user->WriteNumeric(341, "%s %s %s",user->nick,u->nick,c->name);
83 switch (ServerInstance->Config->AnnounceInvites)
85 case ServerConfig::INVITE_ANNOUNCE_ALL:
86 c->WriteChannelWithServ(ServerInstance->Config->ServerName, "NOTICE %s :*** %s invited %s into the channel", c->name, user->nick, u->nick);
88 case ServerConfig::INVITE_ANNOUNCE_OPS:
89 c->WriteAllExceptSender(user, true, '@', "NOTICE %s :*** %s invited %s into the channel", c->name, user->nick, u->nick);
91 case ServerConfig::INVITE_ANNOUNCE_DYNAMIC:
92 if (c->IsModeSet('i'))
93 c->WriteAllExceptSender(user, true, '@', "NOTICE %s :*** %s invited %s into the channel", c->name, user->nick, u->nick);
95 c->WriteChannelWithServ(ServerInstance->Config->ServerName, "NOTICE %s :*** %s invited %s into the channel", c->name, user->nick, u->nick);
101 FOREACH_MOD(I_OnUserInvite,OnUserInvite(user,u,c,timeout));
105 // pinched from ircu - invite with not enough parameters shows channels
106 // youve been invited to but haven't joined yet.
107 InvitedList* il = user->GetInviteList();
108 for (InvitedList::iterator i = il->begin(); i != il->end(); i++)
110 user->WriteNumeric(346, "%s :%s",user->nick,i->first.c_str());
112 user->WriteNumeric(347, "%s :End of INVITE list",user->nick);