- if (IS_OPER(user) && Conf->ReadFlag("badchan","allowopers",j))
- {
- return 0;
- }
- else
- {
- 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 0;
- }
- }
-
- 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(ServerInstance,user,redirect.c_str(),false,"",false,ServerInstance->Time());
- return 1;
- }
- }
-
- user->WriteNumeric(926, "%s %s :Channel %s is forbidden: %s",user->nick.c_str(),cname,cname,reason.c_str());
- return 1;
- }
+ user->WriteNumeric(ERR_BADCHANNEL, cname, InspIRCd::Format("Channel %s is forbidden: %s",
+ cname.c_str(), badchan.reason.c_str()));
+ return MOD_RES_DENY;