mirror of
https://github.com/anope/anope.git
synced 2026-07-02 02:26:38 +02:00
Always reset the levels of newly created channels, fixed DetermineLevel matching ACCESS_INVALID levels, and added in a disabled config option for levels
This commit is contained in:
+6
-1
@@ -692,6 +692,11 @@ class CoreExport Module : public Extensible
|
||||
*/
|
||||
virtual void OnChanUnsuspend(ChannelInfo *ci) { }
|
||||
|
||||
/** Called when a channel is being created, for any reason
|
||||
* @param ci The channel
|
||||
*/
|
||||
virtual void OnCreateChan(ChannelInfo *ci) { }
|
||||
|
||||
/** Called when a channel is being deleted, for any reason
|
||||
* @param ci The channel
|
||||
*/
|
||||
@@ -1030,7 +1035,7 @@ enum Implementation
|
||||
|
||||
/* ChanServ */
|
||||
I_OnChanForbidden, I_OnChanSuspend, I_OnChanDrop, I_OnPreChanExpire, I_OnChanExpire, I_OnAccessAdd,
|
||||
I_OnAccessDel, I_OnAccessClear, I_OnLevelChange, I_OnChanRegistered, I_OnChanUnsuspend, I_OnDelChan, I_OnChannelCreate,
|
||||
I_OnAccessDel, I_OnAccessClear, I_OnLevelChange, I_OnChanRegistered, I_OnChanUnsuspend, I_OnCreateChan, I_OnDelChan, I_OnChannelCreate,
|
||||
I_OnChannelDelete, I_OnAkickAdd, I_OnAkickDel, I_OnCheckKick,
|
||||
I_OnChanInfo, I_OnFindChan, I_OnCheckPriv,
|
||||
|
||||
|
||||
@@ -94,7 +94,7 @@ class AccessChanAccess : public ChanAccess
|
||||
{
|
||||
for (int i = 0; defaultLevels[i].priv != CA_SIZE; ++i)
|
||||
if (defaultLevels[i].priv == priv)
|
||||
return DetermineLevel(this) >= this->ci->levels[priv];
|
||||
return this->ci->levels[priv] != ACCESS_INVALID && DetermineLevel(this) >= this->ci->levels[priv];
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -884,8 +884,8 @@ class CSAccess : public Module
|
||||
ModuleManager::RegisterService(&commandcsaccess);
|
||||
ModuleManager::RegisterService(&commandcslevels);
|
||||
|
||||
Implementation i[] = { I_OnReload, I_OnChanRegistered };
|
||||
ModuleManager::Attach(i, this, 2);
|
||||
Implementation i[] = { I_OnReload, I_OnChanRegistered, I_OnCreateChan };
|
||||
ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation));
|
||||
|
||||
this->OnReload();
|
||||
}
|
||||
@@ -901,6 +901,8 @@ class CSAccess : public Module
|
||||
const Anope::string &value = config.ReadValue("chanserv", l.config_name, "", 0);
|
||||
if (value.equals_ci("founder"))
|
||||
l.default_level = ACCESS_FOUNDER;
|
||||
else if (value.equals_ci("disabled"))
|
||||
l.default_level = ACCESS_INVALID;
|
||||
else
|
||||
l.default_level = config.ReadInteger("chanserv", l.config_name, 0, false);
|
||||
}
|
||||
@@ -910,6 +912,11 @@ class CSAccess : public Module
|
||||
{
|
||||
reset_levels(ci);
|
||||
}
|
||||
|
||||
void OnCreateChan(ChannelInfo *ci)
|
||||
{
|
||||
reset_levels(ci);
|
||||
}
|
||||
};
|
||||
|
||||
MODULE_INIT(CSAccess)
|
||||
|
||||
@@ -56,6 +56,8 @@ ChannelInfo::ChannelInfo(const Anope::string &chname) : Flags<ChannelInfoFlag, C
|
||||
this->ttb[i] = 0;
|
||||
|
||||
RegisteredChannelList[this->name] = this;
|
||||
|
||||
FOREACH_MOD(I_OnCreateChan, OnCreateChan(this));
|
||||
}
|
||||
|
||||
/** Copy constructor
|
||||
|
||||
Reference in New Issue
Block a user