summaryrefslogtreecommitdiff
path: root/src/coremods
diff options
context:
space:
mode:
authorAttila Molnar <attilamolnar@hush.com>2015-11-02 12:32:20 +0100
committerAttila Molnar <attilamolnar@hush.com>2015-11-02 12:32:20 +0100
commita95853c96493bbf8609febfc4395a21ff0b711d5 (patch)
tree6e1d7ae53b0538f332ff098804eb0a00e8480914 /src/coremods
parenta2461fb7e1c28e28e64b61256d7a547162a83f6e (diff)
Move handling of <options:invitebypassmodes> into core_channel
Diffstat (limited to 'src/coremods')
-rw-r--r--src/coremods/core_channel/core_channel.cpp49
1 files changed, 48 insertions, 1 deletions
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 <attilamolnar@hush.com>
+ * Copyright (C) 2014-2015 Attila Molnar <attilamolnar@hush.com>
*
* 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);