From a95853c96493bbf8609febfc4395a21ff0b711d5 Mon Sep 17 00:00:00 2001 From: Attila Molnar Date: Mon, 2 Nov 2015 12:32:20 +0100 Subject: Move handling of into core_channel --- src/coremods/core_channel/core_channel.cpp | 49 +++++++++++++++++++++++++++++- 1 file changed, 48 insertions(+), 1 deletion(-) (limited to 'src/coremods') diff --git a/src/coremods/core_channel/core_channel.cpp b/src/coremods/core_channel/core_channel.cpp index 99ad74d3d..ec617af13 100644 --- a/src/coremods/core_channel/core_channel.cpp +++ b/src/coremods/core_channel/core_channel.cpp @@ -1,7 +1,7 @@ /* * InspIRCd -- Internet Relay Chat Daemon * - * Copyright (C) 2014 Attila Molnar + * Copyright (C) 2014-2015 Attila Molnar * * This file is part of InspIRCd. InspIRCd is free software: you can * redistribute it and/or modify it under the terms of the GNU General Public @@ -28,18 +28,41 @@ class CoreModChannel : public Module CommandNames cmdnames; CommandTopic cmdtopic; + ModResult IsInvited(User* user, Channel* chan) + { + LocalUser* localuser = IS_LOCAL(user); + if ((localuser) && (localuser->IsInvited(chan))) + return MOD_RES_ALLOW; + return MOD_RES_PASSTHRU; + } + public: CoreModChannel() : cmdinvite(this), cmdjoin(this), cmdkick(this), cmdnames(this), cmdtopic(this) { } + void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE + { + Implementation events[] = { I_OnCheckKey, I_OnCheckLimit, I_OnCheckChannelBan }; + if (ServerInstance->Config->InvBypassModes) + ServerInstance->Modules.Attach(events, this, sizeof(events)/sizeof(Implementation)); + else + { + for (unsigned int i = 0; i < sizeof(events)/sizeof(Implementation); i++) + ServerInstance->Modules.Detach(events[i], this); + } + } + void OnPostJoin(Membership* memb) CXX11_OVERRIDE { Channel* const chan = memb->chan; LocalUser* const localuser = IS_LOCAL(memb->user); if (localuser) { + // Remove existing invite, if any + localuser->RemoveInvite(chan); + if (chan->topicset) Topic::ShowTopic(localuser, chan); @@ -48,6 +71,30 @@ class CoreModChannel : public Module } } + ModResult OnCheckKey(User* user, Channel* chan, const std::string& keygiven) CXX11_OVERRIDE + { + // Hook only runs when being invited bypasses +bkl + return IsInvited(user, chan); + } + + ModResult OnCheckChannelBan(User* user, Channel* chan) CXX11_OVERRIDE + { + // Hook only runs when being invited bypasses +bkl + return IsInvited(user, chan); + } + + ModResult OnCheckLimit(User* user, Channel* chan) CXX11_OVERRIDE + { + // Hook only runs when being invited bypasses +bkl + return IsInvited(user, chan); + } + + ModResult OnCheckInvite(User* user, Channel* chan) CXX11_OVERRIDE + { + // Hook always runs + return IsInvited(user, chan); + } + void Prioritize() CXX11_OVERRIDE { ServerInstance->Modules.SetPriority(this, I_OnPostJoin, PRIORITY_FIRST); -- cgit v1.2.3