diff options
author | w00t <w00t@e03df62e-2008-0410-955e-edbf42e46eb7> | 2008-08-07 16:35:58 +0000 |
---|---|---|
committer | w00t <w00t@e03df62e-2008-0410-955e-edbf42e46eb7> | 2008-08-07 16:35:58 +0000 |
commit | 6d64862fb556c43568efdf6b4f65de3fbd33c576 (patch) | |
tree | 4a819a2c3fb6c1630d6df477a388f61dbe2a56ce /src/channels.cpp | |
parent | fd657b6cd1e459359902deeb10ec55610fe7539f (diff) |
Implement <options:invitebypassmodes>, optionally circumvent +blk if invited on join. Based on a patch provided by mixx941, closes bug #589.
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@10120 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/channels.cpp')
-rw-r--r-- | src/channels.cpp | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/src/channels.cpp b/src/channels.cpp index 4d32f6719..0b24aa4b7 100644 --- a/src/channels.cpp +++ b/src/channels.cpp @@ -336,32 +336,36 @@ Channel* Channel::JoinUser(InspIRCd* Instance, User *user, const char* cn, bool else if (MOD_RESULT == 0) { std::string ckey = Ptr->GetModeParameter('k'); + bool invited = user->IsInvited(Ptr->name.c_str()); + bool can_bypass = Instance->Config->InvBypassModes && invited; + if (!ckey.empty()) { MOD_RESULT = 0; FOREACH_RESULT_I(Instance, I_OnCheckKey, OnCheckKey(user, Ptr, key ? key : "")); if (!MOD_RESULT) { - if ((!key) || ckey != key) + // If no key provided, or key is not the right one, and can't bypass +k (not invited or option not enabled) + if ((!key || ckey != key) && !can_bypass) { user->WriteNumeric(ERR_BADCHANNELKEY, "%s %s :Cannot join channel (Incorrect channel key)",user->nick.c_str(), Ptr->name.c_str()); return NULL; } } } + if (Ptr->IsModeSet('i')) { MOD_RESULT = 0; FOREACH_RESULT_I(Instance,I_OnCheckInvite,OnCheckInvite(user, Ptr)); if (!MOD_RESULT) { - if (!user->IsInvited(Ptr->name.c_str())) + if (!invited) { user->WriteNumeric(ERR_INVITEONLYCHAN, "%s %s :Cannot join channel (Invite only)",user->nick.c_str(), Ptr->name.c_str()); return NULL; } } - user->RemoveInvite(Ptr->name.c_str()); } std::string limit = Ptr->GetModeParameter('l'); @@ -372,7 +376,7 @@ Channel* Channel::JoinUser(InspIRCd* Instance, User *user, const char* cn, bool if (!MOD_RESULT) { long llimit = atol(limit.c_str()); - if (Ptr->GetUserCounter() >= llimit) + if (Ptr->GetUserCounter() >= llimit && !can_bypass) { user->WriteNumeric(ERR_CHANNELISFULL, "%s %s :Cannot join channel (Channel is full)",user->nick.c_str(), Ptr->name.c_str()); return NULL; @@ -382,12 +386,21 @@ Channel* Channel::JoinUser(InspIRCd* Instance, User *user, const char* cn, bool if (Ptr->bans.size()) { - if (Ptr->IsBanned(user)) + if (Ptr->IsBanned(user) && !can_bypass) { user->WriteNumeric(ERR_BANNEDFROMCHAN, "%s %s :Cannot join channel (You're banned)",user->nick.c_str(), Ptr->name.c_str()); return NULL; } } + + /* + * If the user has invites for this channel, remove them now + * after a successful join so they don't build up. + */ + if (invited) + { + user->RemoveInvite(Ptr->name.c_str()); + } } } } |