- std::string ckey = chan->GetModeParameter(keymode);
- if (!ckey.empty())
- {
- FIRST_MOD_RESULT(OnCheckKey, MOD_RESULT, (user, chan, key));
- if (!MOD_RESULT.check(InspIRCd::TimingSafeCompare(ckey, key)))
- {
- // If no key provided, or key is not the right one, and can't bypass +k (not invited or option not enabled)
- user->WriteNumeric(ERR_BADCHANNELKEY, chan->name, "Cannot join channel (Incorrect channel key)");
- return NULL;
- }
- }
-
- if (chan->IsModeSet(inviteonlymode))
- {
- FIRST_MOD_RESULT(OnCheckInvite, MOD_RESULT, (user, chan));
- if (MOD_RESULT != MOD_RES_ALLOW)
- {
- user->WriteNumeric(ERR_INVITEONLYCHAN, chan->name, "Cannot join channel (Invite only)");
- return NULL;
- }
- }
-
- std::string limit = chan->GetModeParameter(limitmode);
- if (!limit.empty())
- {
- FIRST_MOD_RESULT(OnCheckLimit, MOD_RESULT, (user, chan));
- if (!MOD_RESULT.check(chan->GetUserCounter() < ConvToNum<size_t>(limit)))
- {
- user->WriteNumeric(ERR_CHANNELISFULL, chan->name, "Cannot join channel (Channel is full)");
- return NULL;
- }
- }
-