- 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 = j->second->getString("reason");
+ std::string redirect = j->second->getString("redirect");
+
+ ConfigTagList goodchans = ServerInstance->Config->ConfTags("goodchan");
+ for (ConfigIter i = goodchans.first; i != goodchans.second; ++i)
+ {
+ if (InspIRCd::Match(cname, i->second->getString("name")))
+ {
+ return MOD_RES_PASSTHRU;
+ }
+ }
+
+ if (ServerInstance->IsChannel(redirect))
+ {
+ /* 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.c_str(),cname.c_str(),redirect.c_str(), reason.c_str());
+ Channel::JoinUser(user, redirect);
+ return MOD_RES_DENY;
+ }
+ }
+
+ user->WriteNumeric(926, "%s %s :Channel %s is forbidden: %s",user->nick.c_str(),cname.c_str(),cname.c_str(),reason.c_str());
+ return MOD_RES_DENY;