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 /* $ModDesc: Provides the UNINVITE command which lets users un-invite other users from channels (!) */
25 #include "helperfuncs.h"
30 extern InspIRCd* ServerInstance;
32 class cmd_uninvite : public command_t
35 cmd_uninvite () : command_t("UNINVITE", 0, 2)
37 this->source = "m_uninvite.so";
38 syntax = "<nick> <channel>";
41 void Handle (const char** parameters, int pcnt, userrec *user)
43 userrec* u = ServerInstance->FindNick(parameters[0]);
44 chanrec* c = ServerInstance->FindChan(parameters[1]);
50 user->WriteServ("401 %s %s :No such nick/channel",user->nick, parameters[1]);
54 user->WriteServ("401 %s %s :No such nick/channel",user->nick, parameters[0]);
60 if (c->modes[CM_INVITEONLY])
62 if (cstatus(user,c) < STATUS_HOP)
64 user->WriteServ("482 %s %s :You must be at least a half-operator to change modes on this channel",user->nick, c->name);
69 irc::string xname(c->name);
71 if (!u->IsInvited(xname))
73 user->WriteServ("491 %s %s %s :Is not invited to channel %s",user->nick,u->nick,c->name,c->name);
76 if (!c->HasUser(user))
78 user->WriteServ("492 %s %s :You're not on that channel!",user->nick, c->name);
82 u->RemoveInvite(xname);
83 user->WriteServ("494 %s %s %s :Uninvited",user->nick,c->name,u->nick);
84 u->WriteServ("493 %s :You were uninvited from %s by %s",u->nick,c->name,user->nick);
85 c->WriteChannelWithServ(Srv->GetServerName().c_str(), "NOTICE %s :*** %s uninvited %s.", c->name, user->nick, u->nick);
89 class ModuleUninvite : public Module
91 cmd_uninvite *mycommand;
95 ModuleUninvite(Server* Me) : Module::Module(Me)
98 mycommand = new cmd_uninvite();
99 Srv->AddCommand(mycommand);
102 virtual ~ModuleUninvite()
106 virtual Version GetVersion()
108 /* Must be static, because we dont want to desync invite lists */
109 return Version(1, 0, 0, 0, VF_VENDOR|VF_STATIC);
114 class ModuleUninviteFactory : public ModuleFactory
117 ModuleUninviteFactory()
121 ~ModuleUninviteFactory()
125 virtual Module * CreateModule(Server* Me)
127 return new ModuleUninvite(Me);
133 extern "C" void * init_module( void )
135 return new ModuleUninviteFactory;