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 class cmd_uninvite : public command_t
33 cmd_uninvite () : command_t("UNINVITE", 0, 2)
35 this->source = "m_uninvite.so";
38 void Handle (const char** parameters, int pcnt, userrec *user)
40 userrec* u = Find(parameters[0]);
41 chanrec* c = FindChan(parameters[1]);
47 WriteServ(user->fd,"401 %s %s :No such nick/channel",user->nick, parameters[1]);
51 WriteServ(user->fd,"401 %s %s :No such nick/channel",user->nick, parameters[0]);
57 if (c->modes[CM_INVITEONLY])
59 if (cstatus(user,c) < STATUS_HOP)
61 WriteServ(user->fd,"482 %s %s :You must be at least a half-operator to change modes on this channel",user->nick, c->name);
66 irc::string xname(c->name);
68 if (!u->IsInvited(xname))
70 WriteServ(user->fd,"491 %s %s %s :Is not invited to channel %s",user->nick,u->nick,c->name,c->name);
73 if (!c->HasUser(user))
75 WriteServ(user->fd,"492 %s %s :You're not on that channel!",user->nick, c->name);
79 u->RemoveInvite(xname);
80 WriteServ(user->fd,"494 %s %s %s :Uninvited",user->nick,c->name,u->nick);
81 WriteServ(u->fd,"493 %s :You were uninvited from %s by %s",u->nick,c->name,user->nick);
82 WriteChannel(c,user,"NOTICE %s :*** %s uninvited %s.",c->name,user->nick,u->nick);
86 class ModuleUninvite : public Module
88 cmd_uninvite *mycommand;
92 ModuleUninvite(Server* Me) : Module::Module(Me)
95 mycommand = new cmd_uninvite();
96 Srv->AddCommand(mycommand);
99 virtual ~ModuleUninvite()
103 virtual Version GetVersion()
105 /* Must be static, because we dont want to desync invite lists */
106 return Version(1, 0, 0, 0, VF_VENDOR|VF_STATIC);
111 class ModuleUninviteFactory : public ModuleFactory
114 ModuleUninviteFactory()
118 ~ModuleUninviteFactory()
122 virtual Module * CreateModule(Server* Me)
124 return new ModuleUninvite(Me);
130 extern "C" void * init_module( void )
132 return new ModuleUninviteFactory;