diff options
| author | Adam <Adam@anope.org> | 2013-04-08 00:19:07 -0500 |
|---|---|---|
| committer | Adam <Adam@anope.org> | 2013-04-08 00:19:07 -0500 |
| commit | 1a37e1c0480f8bd11f57dfba514069a4e9c7d8de (patch) | |
| tree | 41798df9056ef555f00c4a6c0964f1219c357dc3 /modules/extra | |
| parent | fb7fef7a849342ab8463743497e781c5c3e6ae88 (diff) | |
Made auto* chanserv privileges not hard coded.
Made cs_statusupdate not remove status on users if they still match other entries.
Move privilege descriptions out of the config
Diffstat (limited to 'modules/extra')
| -rw-r--r-- | modules/extra/cs_statusupdate.cpp | 41 |
1 files changed, 20 insertions, 21 deletions
diff --git a/modules/extra/cs_statusupdate.cpp b/modules/extra/cs_statusupdate.cpp index 4a53956d7..934b928d1 100644 --- a/modules/extra/cs_statusupdate.cpp +++ b/modules/extra/cs_statusupdate.cpp @@ -7,19 +7,6 @@ #include "module.h" -static struct ModeInfo -{ - Anope::string priv; - Anope::string name; -} modeInfo[] = { - { "AUTOOWNER", "OWNER" }, - { "AUTOPROTECT", "PROTECT" }, - { "AUTOOP", "OP" }, - { "AUTOHALFOP", "HALFOP" }, - { "AUTOVOICE", "VOICE" }, - { "", "" } -}; - class StatusUpdate : public Module { public: @@ -38,11 +25,14 @@ class StatusUpdate : public Module { User *user = it->second->user; - if (access->Matches(user, user->Account())) + if (user->server != Me && access->Matches(user, user->Account())) { - for (int i = 0; !modeInfo[i].priv.empty(); ++i) - if (!access->HasPriv(modeInfo[i].priv)) - ci->c->RemoveMode(NULL, modeInfo[i].name, user->nick); + for (unsigned i = 0; i < ModeManager::GetStatusChannelModesByRank().size(); ++i) + { + ChannelModeStatus *cms = ModeManager::GetStatusChannelModesByRank()[i]; + if (!access->HasPriv("AUTO" + cms->name)) + ci->c->RemoveMode(NULL, cms, user->GetUID()); + } ci->c->SetCorrectModes(user, true, false); } } @@ -55,11 +45,20 @@ class StatusUpdate : public Module { User *user = it->second->user; - if (access->Matches(user, user->Account())) + if (user->server != Me && access->Matches(user, user->Account())) { - for (int i = 0; !modeInfo[i].priv.empty(); ++i) - if (access->HasPriv(modeInfo[i].priv)) - ci->c->RemoveMode(NULL, modeInfo[i].name, user->nick); + /* Get user's current access and remove the entry about to be deleted */ + AccessGroup ag = ci->AccessFor(user); + AccessGroup::iterator iter = std::find(ag.begin(), ag.end(), access); + if (iter != ag.end()) + ag.erase(iter); + + for (unsigned i = 0; i < ModeManager::GetStatusChannelModesByRank().size(); ++i) + { + ChannelModeStatus *cms = ModeManager::GetStatusChannelModesByRank()[i]; + if (!ag.HasPriv("AUTO" + cms->name)) + ci->c->RemoveMode(NULL, cms, user->GetUID()); + } } } } |
