+ // If the user is an oper and opers are allowed to enter this blacklisted channel
+ // then allow the join.
+ if (user->IsOper() && badchan.allowopers)
+ return MOD_RES_PASSTHRU;
+
+ // If the channel matches a whitelist then allow the join.
+ for (GoodChannels::const_iterator i = goodchannels.begin(); i != goodchannels.end(); ++i)
+ if (InspIRCd::Match(cname, *i))
+ return MOD_RES_PASSTHRU;
+
+ // If there is no redirect chan, the user has enabled the antiredirect mode, or
+ // the target channel redirects elsewhere we just tell the user and deny the join.
+ Channel* target = NULL;
+ if (badchan.redirect.empty() || user->IsModeSet(antiredirectmode)
+ || ((target = ServerInstance->FindChan(badchan.redirect)) && target->IsModeSet(redirectmode)))
+ {
+ user->WriteNumeric(ERR_BADCHANNEL, cname, InspIRCd::Format("Channel %s is forbidden: %s",
+ cname.c_str(), badchan.reason.c_str()));
+ return MOD_RES_DENY;
+ }
+
+ // Redirect the user to the target channel.
+ user->WriteNumeric(ERR_BADCHANNEL, cname, InspIRCd::Format("Channel %s is forbidden, redirecting to %s: %s",
+ cname.c_str(), badchan.redirect.c_str(), badchan.reason.c_str()));
+ Channel::JoinUser(user, badchan.redirect);
+ return MOD_RES_DENY;
+ }
+ return MOD_RES_PASSTHRU;
+ }
+};