diff options
author | Adam <Adam@anope.org> | 2012-12-22 14:49:48 -0500 |
---|---|---|
committer | Adam <Adam@anope.org> | 2012-12-22 14:49:48 -0500 |
commit | dc751bd2f10ab498352ee8a64d2c4b0dcac7c4ea (patch) | |
tree | e2652e8831fc1c77d5e46d58d8c4a236d0bc4fa5 /modules/extra/cs_statusupdate.cpp | |
parent | 0cde0aee34a658e8059106ee51641cac2f48d92a (diff) |
Combine all of the set modules now that having them split apart is almost completely pointless
Diffstat (limited to 'modules/extra/cs_statusupdate.cpp')
-rw-r--r-- | modules/extra/cs_statusupdate.cpp | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/modules/extra/cs_statusupdate.cpp b/modules/extra/cs_statusupdate.cpp new file mode 100644 index 000000000..41ea8833e --- /dev/null +++ b/modules/extra/cs_statusupdate.cpp @@ -0,0 +1,68 @@ +/* + * (C) 2003-2012 Anope Team + * Contact us at team@anope.org + * + * Please read COPYING and README for further details. + */ + +#include "module.h" + +static struct ModeInfo +{ + Anope::string priv; + ChannelModeName name; +} modeInfo[] = { + { "AUTOOWNER", CMODE_OWNER }, + { "AUTOPROTECT", CMODE_PROTECT }, + { "AUTOOP", CMODE_OP }, + { "AUTOHALFOP", CMODE_HALFOP }, + { "AUTOVOICE", CMODE_VOICE }, + { "", CMODE_END } +}; + +class StatusUpdate : public Module +{ + public: + StatusUpdate(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, SUPPORTED) + { + this->SetAuthor("Anope"); + + Implementation i[] = { I_OnAccessAdd, I_OnAccessDel }; + ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation)); + } + + void OnAccessAdd(ChannelInfo *ci, CommandSource &, ChanAccess *access) anope_override + { + if (ci->c) + for (CUserList::iterator it = ci->c->users.begin(), it_end = ci->c->users.end(); it != it_end; ++it) + { + User *user = (*it)->user; + + if (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); + ci->c->SetCorrectModes(user, true, false); + } + } + } + + void OnAccessDel(ChannelInfo *ci, CommandSource &, ChanAccess *access) anope_override + { + if (ci->c) + for (CUserList::iterator it = ci->c->users.begin(), it_end = ci->c->users.end(); it != it_end; ++it) + { + User *user = (*it)->user; + + if (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); + } + } + } +}; + +MODULE_INIT(StatusUpdate) |