- std::string reason = Conf->ReadValue("badchan","reason",j);
- user->WriteServ("926 %s %s :Channel %s is forbidden: %s",user->nick,cname,cname,reason.c_str());
- return 1;
+ std::string reason = Conf.ReadValue("badchan","reason",j);
+ std::string redirect = Conf.ReadValue("badchan","redirect",j);
+
+ for (int i = 0; i < Conf.Enumerate("goodchan"); i++)
+ {
+ if (InspIRCd::Match(cname, Conf.ReadValue("goodchan", "name", i)))
+ {
+ return MOD_RES_PASSTHRU;
+ }
+ }
+
+ if (ServerInstance->IsChannel(redirect.c_str(), ServerInstance->Config->Limits.ChanMax))
+ {
+ /* simple way to avoid potential loops: don't redirect to +L channels */
+ Channel *newchan = ServerInstance->FindChan(redirect);
+ if ((!newchan) || (!(newchan->IsModeSet('L'))))
+ {
+ user->WriteNumeric(926, "%s %s :Channel %s is forbidden, redirecting to %s: %s",user->nick.c_str(),cname,cname,redirect.c_str(), reason.c_str());
+ Channel::JoinUser(user,redirect.c_str(),false,"",false,ServerInstance->Time());
+ return MOD_RES_DENY;
+ }
+ }
+
+ user->WriteNumeric(926, "%s %s :Channel %s is forbidden: %s",user->nick.c_str(),cname,cname,reason.c_str());
+ return MOD_RES_DENY;