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"
24 class CoreModChannel : public Module
26 Invite::APIImpl invapi;
27 CommandInvite cmdinvite;
30 CommandNames cmdnames;
31 CommandTopic cmdtopic;
33 ModResult IsInvited(User* user, Channel* chan)
35 LocalUser* localuser = IS_LOCAL(user);
36 if ((localuser) && (invapi.IsInvited(localuser, chan)))
38 return MOD_RES_PASSTHRU;
44 , cmdinvite(this, invapi), cmdjoin(this), cmdkick(this), cmdnames(this), cmdtopic(this)
48 void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE
50 ConfigTag* optionstag = ServerInstance->Config->ConfValue("options");
51 Implementation events[] = { I_OnCheckKey, I_OnCheckLimit, I_OnCheckChannelBan };
52 if (optionstag->getBool("invitebypassmodes", true))
53 ServerInstance->Modules.Attach(events, this, sizeof(events)/sizeof(Implementation));
56 for (unsigned int i = 0; i < sizeof(events)/sizeof(Implementation); i++)
57 ServerInstance->Modules.Detach(events[i], this);
61 void OnPostJoin(Membership* memb) CXX11_OVERRIDE
63 Channel* const chan = memb->chan;
64 LocalUser* const localuser = IS_LOCAL(memb->user);
67 // Remove existing invite, if any
68 invapi.Remove(localuser, chan);
71 Topic::ShowTopic(localuser, chan);
73 // Show all members of the channel, including invisible (+i) users
74 cmdnames.SendNames(localuser, chan, true);
78 ModResult OnCheckKey(User* user, Channel* chan, const std::string& keygiven) CXX11_OVERRIDE
80 // Hook only runs when being invited bypasses +bkl
81 return IsInvited(user, chan);
84 ModResult OnCheckChannelBan(User* user, Channel* chan) CXX11_OVERRIDE
86 // Hook only runs when being invited bypasses +bkl
87 return IsInvited(user, chan);
90 ModResult OnCheckLimit(User* user, Channel* chan) CXX11_OVERRIDE
92 // Hook only runs when being invited bypasses +bkl
93 return IsInvited(user, chan);
96 ModResult OnCheckInvite(User* user, Channel* chan) CXX11_OVERRIDE
99 return IsInvited(user, chan);
102 void OnUserDisconnect(LocalUser* user) CXX11_OVERRIDE
104 invapi.RemoveAll(user);
107 void OnChannelDelete(Channel* chan) CXX11_OVERRIDE
109 // Make sure the channel won't appear in invite lists from now on, don't wait for cull to unset the ext
110 invapi.RemoveAll(chan);
113 void Prioritize() CXX11_OVERRIDE
115 ServerInstance->Modules.SetPriority(this, I_OnPostJoin, PRIORITY_FIRST);
118 Version GetVersion() CXX11_OVERRIDE
120 return Version("Provides the INVITE, JOIN, KICK, NAMES, and TOPIC commands", VF_VENDOR|VF_CORE);
124 MODULE_INIT(CoreModChannel)