#include "inspircd.h"
#include "core_channel.h"
+#include "invite.h"
class CoreModChannel : public Module
{
+ Invite::APIImpl invapi;
CommandInvite cmdinvite;
CommandJoin cmdjoin;
CommandKick cmdkick;
ModResult IsInvited(User* user, Channel* chan)
{
LocalUser* localuser = IS_LOCAL(user);
- if ((localuser) && (localuser->IsInvited(chan)))
+ if ((localuser) && (invapi.IsInvited(localuser, chan)))
return MOD_RES_ALLOW;
return MOD_RES_PASSTHRU;
}
public:
CoreModChannel()
- : cmdinvite(this), cmdjoin(this), cmdkick(this), cmdnames(this), cmdtopic(this)
+ : invapi(this)
+ , cmdinvite(this, invapi), cmdjoin(this), cmdkick(this), cmdnames(this), cmdtopic(this)
{
}
void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE
{
+ ConfigTag* optionstag = ServerInstance->Config->ConfValue("options");
Implementation events[] = { I_OnCheckKey, I_OnCheckLimit, I_OnCheckChannelBan };
- if (ServerInstance->Config->InvBypassModes)
+ if (optionstag->getBool("invitebypassmodes", true))
ServerInstance->Modules.Attach(events, this, sizeof(events)/sizeof(Implementation));
else
{
if (localuser)
{
// Remove existing invite, if any
- localuser->RemoveInvite(chan);
+ invapi.Remove(localuser, chan);
if (chan->topicset)
Topic::ShowTopic(localuser, chan);
return IsInvited(user, chan);
}
+ void OnUserDisconnect(LocalUser* user) CXX11_OVERRIDE
+ {
+ invapi.RemoveAll(user);
+ }
+
+ void OnChannelDelete(Channel* chan) CXX11_OVERRIDE
+ {
+ // Make sure the channel won't appear in invite lists from now on, don't wait for cull to unset the ext
+ invapi.RemoveAll(chan);
+ }
+
void Prioritize() CXX11_OVERRIDE
{
ServerInstance->Modules.SetPriority(this, I_OnPostJoin, PRIORITY_FIRST);