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 * ---------------------------------------------------
14 /* $ModDesc: Provides the UNINVITE command which lets users un-invite other users from channels (!) */
20 #include "configreader.h"
25 class cmd_uninvite : public command_t
28 cmd_uninvite (InspIRCd* Instance) : command_t(Instance,"UNINVITE", 0, 2)
30 this->source = "m_uninvite.so";
31 syntax = "<nick> <channel>";
34 CmdResult Handle (const char** parameters, int pcnt, userrec *user)
36 userrec* u = ServerInstance->FindNick(parameters[0]);
37 chanrec* c = ServerInstance->FindChan(parameters[1]);
43 user->WriteServ("401 %s %s :No such nick/channel",user->nick, parameters[1]);
47 user->WriteServ("401 %s %s :No such nick/channel",user->nick, parameters[0]);
53 if (c->modes[CM_INVITEONLY])
55 if (c->GetStatus(user) < STATUS_HOP)
57 user->WriteServ("482 %s %s :You must be at least a half-operator to change modes on this channel",user->nick, c->name);
62 irc::string xname(c->name);
64 if (!u->IsInvited(xname))
66 user->WriteServ("491 %s %s %s :Is not invited to channel %s",user->nick,u->nick,c->name,c->name);
69 if (!c->HasUser(user))
71 user->WriteServ("492 %s %s :You're not on that channel!",user->nick, c->name);
75 u->RemoveInvite(xname);
76 user->WriteServ("494 %s %s %s :Uninvited",user->nick,c->name,u->nick);
77 u->WriteServ("493 %s :You were uninvited from %s by %s",u->nick,c->name,user->nick);
78 c->WriteChannelWithServ(ServerInstance->Config->ServerName, "NOTICE %s :*** %s uninvited %s.", c->name, user->nick, u->nick);
84 class ModuleUninvite : public Module
86 cmd_uninvite *mycommand;
90 ModuleUninvite(InspIRCd* Me) : Module::Module(Me)
93 mycommand = new cmd_uninvite(ServerInstance);
94 ServerInstance->AddCommand(mycommand);
97 virtual ~ModuleUninvite()
101 virtual Version GetVersion()
103 return Version(1, 1, 0, 0, VF_VENDOR, API_VERSION);
108 class ModuleUninviteFactory : public ModuleFactory
111 ModuleUninviteFactory()
115 ~ModuleUninviteFactory()
119 virtual Module * CreateModule(InspIRCd* Me)
121 return new ModuleUninvite(Me);
127 extern "C" void * init_module( void )
129 return new ModuleUninviteFactory;