anope

- supernets anope source code & configuration
git clone git://git.acid.vegas/anope.git
Log | Files | Refs | Archive | README

cs_statusupdate.cpp (1779B)

      1 /*
      2  *
      3  * (C) 2003-2022 Anope Team
      4  * Contact us at team@anope.org
      5  *
      6  * Please read COPYING and README for further details.
      7  */
      8 
      9 #include "module.h"
     10 
     11 class StatusUpdate : public Module
     12 {
     13  public:
     14 	StatusUpdate(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR)
     15 	{
     16 
     17 	}
     18 
     19 	void OnAccessAdd(ChannelInfo *ci, CommandSource &, ChanAccess *access) anope_override
     20 	{
     21 		if (ci->c)
     22 			for (Channel::ChanUserList::iterator it = ci->c->users.begin(), it_end = ci->c->users.end(); it != it_end; ++it)
     23 			{
     24 				User *user = it->second->user;
     25 
     26 				ChannelInfo *next;
     27 				if (user->server != Me && access->Matches(user, user->Account(), next))
     28 				{
     29 					AccessGroup ag = ci->AccessFor(user);
     30 
     31 					for (unsigned i = 0; i < ModeManager::GetStatusChannelModesByRank().size(); ++i)
     32 					{
     33 						ChannelModeStatus *cms = ModeManager::GetStatusChannelModesByRank()[i];
     34 						if (!ag.HasPriv("AUTO" + cms->name))
     35 							ci->c->RemoveMode(NULL, cms, user->GetUID());
     36 					}
     37 					ci->c->SetCorrectModes(user, true);
     38 				}
     39 			}
     40 	}
     41 
     42 	void OnAccessDel(ChannelInfo *ci, CommandSource &, ChanAccess *access) anope_override
     43 	{
     44 		if (ci->c)
     45 			for (Channel::ChanUserList::iterator it = ci->c->users.begin(), it_end = ci->c->users.end(); it != it_end; ++it)
     46 			{
     47 				User *user = it->second->user;
     48 
     49 				ChannelInfo *next;
     50 				if (user->server != Me && access->Matches(user, user->Account(), next))
     51 				{
     52 					AccessGroup ag = ci->AccessFor(user);
     53 
     54 					for (unsigned i = 0; i < ModeManager::GetStatusChannelModesByRank().size(); ++i)
     55 					{
     56 						ChannelModeStatus *cms = ModeManager::GetStatusChannelModesByRank()[i];
     57 						if (!ag.HasPriv("AUTO" + cms->name))
     58 							ci->c->RemoveMode(NULL, cms, user->GetUID());
     59 					}
     60 				}
     61 			}
     62 	}
     63 };
     64 
     65 MODULE_INIT(StatusUpdate)