diff options
Diffstat (limited to 'src/modules/m_allowinvite.cpp')
-rw-r--r-- | src/modules/m_allowinvite.cpp | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/src/modules/m_allowinvite.cpp b/src/modules/m_allowinvite.cpp new file mode 100644 index 000000000..f137598e2 --- /dev/null +++ b/src/modules/m_allowinvite.cpp @@ -0,0 +1,69 @@ +/* +------------------------------------+ + * | Inspire Internet Relay Chat Daemon | + * +------------------------------------+ + * + * InspIRCd: (C) 2002-2008 InspIRCd Development Team + * See: http://www.inspircd.org/wiki/index.php/Credits + * + * This program is free but copyrighted software; see + * the file COPYING for details. + * + * --------------------------------------------------- + */ + +#include "inspircd.h" + +/* $ModDesc: Provides support for channel mode +A, allowing /invite freely on a channel (and extban A to allow specific users it) */ + +class AllowInvite : public SimpleChannelModeHandler +{ + public: + AllowInvite(InspIRCd* Instance) : SimpleChannelModeHandler(Instance, 'A') { } +}; + +class ModuleAllowInvite : public Module +{ + AllowInvite *ni; + public: + + ModuleAllowInvite(InspIRCd* Me) : Module(Me) + { + ni = new AllowInvite(ServerInstance); + if (!ServerInstance->Modes->AddMode(ni)) + throw ModuleException("Could not add new modes!"); + Implementation eventlist[] = { I_OnUserPreInvite, I_On005Numeric }; + ServerInstance->Modules->Attach(eventlist, this, 2); + } + + virtual void On005Numeric(std::string &output) + { + ServerInstance->AddExtBanChar('A'); + } + + virtual int OnUserPreInvite(User* user,User* dest,Channel* channel, time_t timeout) + { + if (IS_LOCAL(user)) + { + if (channel->IsModeSet('A') || channel->IsExtBanned(user, 'A')) + { + // Explicitly allow /invite + return -1; + } + } + + return 0; + } + + virtual ~ModuleAllowInvite() + { + ServerInstance->Modes->DelMode(ni); + delete ni; + } + + virtual Version GetVersion() + { + return Version(1,2,0,0,VF_COMMON|VF_VENDOR,API_VERSION); + } +}; + +MODULE_INIT(ModuleAllowInvite) |