1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd: (C) 2002-2007 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 "configreader.h"
18 #include "commands/cmd_invite.h"
20 extern "C" DllExport command_t* init_command(InspIRCd* Instance)
22 return new cmd_invite(Instance);
27 CmdResult cmd_invite::Handle (const char** parameters, int pcnt, userrec *user)
33 userrec* u = ServerInstance->FindNick(parameters[0]);
34 chanrec* c = ServerInstance->FindChan(parameters[1]);
40 user->WriteServ("401 %s %s :No such nick/channel",user->nick, parameters[1]);
44 user->WriteServ("401 %s %s :No such nick/channel",user->nick, parameters[0]);
50 if ((c->IsModeSet('i')) && (IS_LOCAL(user)))
52 if (c->GetStatus(user) < STATUS_HOP)
54 user->WriteServ("482 %s %s :You must be at least a half-operator to change modes on this channel",user->nick, c->name);
61 user->WriteServ("443 %s %s %s :is already on channel",user->nick,u->nick,c->name);
65 if ((IS_LOCAL(user)) && (!c->HasUser(user)))
67 user->WriteServ("442 %s %s :You're not on that channel!",user->nick, c->name);
71 FOREACH_RESULT(I_OnUserPreInvite,OnUserPreInvite(user,u,c));
79 u->WriteFrom(user,"INVITE %s :%s",u->nick,c->name);
80 user->WriteServ("341 %s %s %s",user->nick,u->nick,c->name);
81 switch (ServerInstance->Config->AnnounceInvites)
83 case ServerConfig::INVITE_ANNOUNCE_ALL:
84 c->WriteChannelWithServ(ServerInstance->Config->ServerName, "NOTICE %s :*** %s invited %s into the channel", c->name, user->nick, u->nick);
86 case ServerConfig::INVITE_ANNOUNCE_OPS:
87 c->WriteAllExceptSender(user, true, '@', "NOTICE %s :*** %s invited %s into the channel", c->name, user->nick, u->nick);
89 case ServerConfig::INVITE_ANNOUNCE_DYNAMIC:
90 if (c->IsModeSet('i'))
91 c->WriteAllExceptSender(user, true, '@', "NOTICE %s :*** %s invited %s into the channel", c->name, user->nick, u->nick);
93 c->WriteChannelWithServ(ServerInstance->Config->ServerName, "NOTICE %s :*** %s invited %s into the channel", c->name, user->nick, u->nick);
99 FOREACH_MOD(I_OnUserInvite,OnUserInvite(user,u,c));
103 // pinched from ircu - invite with not enough parameters shows channels
104 // youve been invited to but haven't joined yet.
105 InvitedList* il = user->GetInviteList();
106 for (InvitedList::iterator i = il->begin(); i != il->end(); i++)
108 user->WriteServ("346 %s :%s",user->nick,i->c_str());
110 user->WriteServ("347 %s :End of INVITE list",user->nick);