1
0
mirror of https://github.com/anope/anope.git synced 2026-07-09 20:03:13 +02:00

Added chanserv:require config option to set which modes must be on all registered channels. Prevents the core from always enforcing +r on every channel, even if chanserv is not loaded.

This commit is contained in:
Adam
2012-02-26 23:23:15 -05:00
parent a78790eac4
commit a5b9e235ae
18 changed files with 139 additions and 172 deletions
-83
View File
@@ -22,89 +22,6 @@ registered_channel_map RegisteredChannelList;
/*************************************************************************/
/* Check the current modes on a channel; if they conflict with a mode lock,
* fix them.
*/
void check_modes(Channel *c)
{
if (!c)
{
Log() << "check_modes called with NULL values";
return;
}
if (c->bouncy_modes)
return;
/* Check for mode bouncing */
if (c->server_modecount >= 3 && c->chanserv_modecount >= 3)
{
Log() << "Warning: unable to set modes on channel " << c->name << ". Are your servers' U:lines configured correctly?";
c->bouncy_modes = 1;
return;
}
if (c->chanserv_modetime != Anope::CurTime)
{
c->chanserv_modecount = 0;
c->chanserv_modetime = Anope::CurTime;
}
c->chanserv_modecount++;
/* Check if the channel is registered; if not remove mode -r */
ChannelInfo *ci = c->ci;
if (!ci)
{
if (c->HasMode(CMODE_REGISTERED))
c->RemoveMode(NULL, CMODE_REGISTERED);
return;
}
for (std::multimap<ChannelModeName, ModeLock>::const_iterator it = ci->GetMLock().begin(), it_end = ci->GetMLock().end(); it != it_end; ++it)
{
const ModeLock &ml = it->second;
ChannelMode *cm = ModeManager::FindChannelModeByName(ml.name);
if (!cm)
continue;
if (cm->Type == MODE_REGULAR)
{
if (!c->HasMode(cm->Name) && ml.set)
c->SetMode(NULL, cm);
else if (c->HasMode(cm->Name) && !ml.set)
c->RemoveMode(NULL, cm);
}
else if (cm->Type == MODE_PARAM)
{
Anope::string param;
c->GetParam(cm->Name, param);
/* If the channel doesnt have the mode, or it does and it isn't set correctly */
if (ml.set)
{
if (!c->HasMode(cm->Name) || (!param.empty() && !ml.param.empty() && !param.equals_cs(ml.param)))
c->SetMode(NULL, cm, ml.param);
}
else
{
if (c->HasMode(cm->Name))
c->RemoveMode(NULL, cm);
}
}
else if (cm->Type == MODE_LIST)
{
if (ml.set)
c->SetMode(NULL, cm, ml.param);
else
c->RemoveMode(NULL, cm, ml.param);
}
}
}
/*************************************************************************/
ChannelInfo *cs_findchan(const Anope::string &chan)
{
FOREACH_MOD(I_OnFindChan, OnFindChan(chan));