2 * InspIRCd -- Internet Relay Chat Daemon
4 * Copyright (C) 2014-2015 Attila Molnar <attilamolnar@hush.com>
6 * This file is part of InspIRCd. InspIRCd is free software: you can
7 * redistribute it and/or modify it under the terms of the GNU General Public
8 * License as published by the Free Software Foundation, version 2.
10 * This program is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
21 #include "core_channel.h"
23 class CoreModChannel : public Module
25 CommandInvite cmdinvite;
28 CommandNames cmdnames;
29 CommandTopic cmdtopic;
31 ModResult IsInvited(User* user, Channel* chan)
33 LocalUser* localuser = IS_LOCAL(user);
34 if ((localuser) && (localuser->IsInvited(chan)))
36 return MOD_RES_PASSTHRU;
41 : cmdinvite(this), cmdjoin(this), cmdkick(this), cmdnames(this), cmdtopic(this)
45 void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE
47 ConfigTag* optionstag = ServerInstance->Config->ConfValue("options");
48 Implementation events[] = { I_OnCheckKey, I_OnCheckLimit, I_OnCheckChannelBan };
49 if (optionstag->getBool("invitebypassmodes", true))
50 ServerInstance->Modules.Attach(events, this, sizeof(events)/sizeof(Implementation));
53 for (unsigned int i = 0; i < sizeof(events)/sizeof(Implementation); i++)
54 ServerInstance->Modules.Detach(events[i], this);
58 void OnPostJoin(Membership* memb) CXX11_OVERRIDE
60 Channel* const chan = memb->chan;
61 LocalUser* const localuser = IS_LOCAL(memb->user);
64 // Remove existing invite, if any
65 localuser->RemoveInvite(chan);
68 Topic::ShowTopic(localuser, chan);
70 // Show all members of the channel, including invisible (+i) users
71 cmdnames.SendNames(localuser, chan, true);
75 ModResult OnCheckKey(User* user, Channel* chan, const std::string& keygiven) CXX11_OVERRIDE
77 // Hook only runs when being invited bypasses +bkl
78 return IsInvited(user, chan);
81 ModResult OnCheckChannelBan(User* user, Channel* chan) CXX11_OVERRIDE
83 // Hook only runs when being invited bypasses +bkl
84 return IsInvited(user, chan);
87 ModResult OnCheckLimit(User* user, Channel* chan) CXX11_OVERRIDE
89 // Hook only runs when being invited bypasses +bkl
90 return IsInvited(user, chan);
93 ModResult OnCheckInvite(User* user, Channel* chan) CXX11_OVERRIDE
96 return IsInvited(user, chan);
99 void Prioritize() CXX11_OVERRIDE
101 ServerInstance->Modules.SetPriority(this, I_OnPostJoin, PRIORITY_FIRST);
104 Version GetVersion() CXX11_OVERRIDE
106 return Version("Provides the INVITE, JOIN, KICK, NAMES, and TOPIC commands", VF_VENDOR|VF_CORE);
110 MODULE_INIT(CoreModChannel)