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";
36 syntax = "<nick> <channel>";
39 void Handle (const char** parameters, int pcnt, userrec *user)
41 userrec* u = Find(parameters[0]);
42 chanrec* c = FindChan(parameters[1]);
48 WriteServ(user->fd,"401 %s %s :No such nick/channel",user->nick, parameters[1]);
52 WriteServ(user->fd,"401 %s %s :No such nick/channel",user->nick, parameters[0]);
58 if (c->modes[CM_INVITEONLY])
60 if (cstatus(user,c) < STATUS_HOP)
62 WriteServ(user->fd,"482 %s %s :You must be at least a half-operator to change modes on this channel",user->nick, c->name);
67 irc::string xname(c->name);
69 if (!u->IsInvited(xname))
71 WriteServ(user->fd,"491 %s %s %s :Is not invited to channel %s",user->nick,u->nick,c->name,c->name);
74 if (!c->HasUser(user))
76 WriteServ(user->fd,"492 %s %s :You're not on that channel!",user->nick, c->name);
80 u->RemoveInvite(xname);
81 WriteServ(user->fd,"494 %s %s %s :Uninvited",user->nick,c->name,u->nick);
82 WriteServ(u->fd,"493 %s :You were uninvited from %s by %s",u->nick,c->name,user->nick);
83 WriteChannel(c,user,"NOTICE %s :*** %s uninvited %s.",c->name,user->nick,u->nick);
87 class ModuleUninvite : public Module
89 cmd_uninvite *mycommand;
93 ModuleUninvite(Server* Me) : Module::Module(Me)
96 mycommand = new cmd_uninvite();
97 Srv->AddCommand(mycommand);
100 virtual ~ModuleUninvite()
104 virtual Version GetVersion()
106 /* Must be static, because we dont want to desync invite lists */
107 return Version(1, 0, 0, 0, VF_VENDOR|VF_STATIC);
112 class ModuleUninviteFactory : public ModuleFactory
115 ModuleUninviteFactory()
119 ~ModuleUninviteFactory()
123 virtual Module * CreateModule(Server* Me)
125 return new ModuleUninvite(Me);
131 extern "C" void * init_module( void )
133 return new ModuleUninviteFactory;