anope

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

cs_sync.cpp (1884B)

      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  * Based on the original code of Epona by Lara.
      9  * Based on the original code of Services by Andy Church.
     10  */
     11 
     12 #include "module.h"
     13 
     14 class CommandCSSync : public Command
     15 {
     16  public:
     17 	CommandCSSync(Module *creator) : Command(creator, "chanserv/sync", 1, 1)
     18 	{
     19 		this->SetDesc(_("Sync users channel modes"));
     20 		this->SetSyntax(_("\037channel\037"));
     21 	}
     22 
     23 	void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
     24 	{
     25 		ChannelInfo *ci = ChannelInfo::Find(params[0]);
     26 
     27 		if (ci == NULL)
     28 			source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str());
     29 		else if (ci->c == NULL)
     30 			source.Reply(CHAN_X_NOT_IN_USE, params[0].c_str());
     31 		else if (!source.AccessFor(ci).HasPriv("ACCESS_CHANGE") && !source.HasPriv("chanserv/administration"))
     32 			source.Reply(ACCESS_DENIED);
     33 		else
     34 		{
     35 			bool override = !source.AccessFor(ci).HasPriv("ACCESS_CHANGE") && source.HasPriv("chanserv/administration");
     36 			Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci);
     37 
     38 			for (Channel::ChanUserList::iterator it = ci->c->users.begin(), it_end = ci->c->users.end(); it != it_end; ++it)
     39 				ci->c->SetCorrectModes(it->second->user, true);
     40 
     41 			source.Reply(_("All user modes on \002%s\002 have been synced."), ci->name.c_str());
     42 		}
     43 	}
     44 
     45 	bool OnHelp(CommandSource &source, const Anope::string &params) anope_override
     46 	{
     47 		this->SendSyntax(source);
     48 		source.Reply(" ");
     49 		source.Reply(_("Syncs all modes set on users on the channel with the modes\n"
     50 				"they should have based on their access."));
     51 		return true;
     52 	}
     53 };
     54 
     55 class CSSync : public Module
     56 {
     57 	CommandCSSync commandcssync;
     58  public:
     59 	CSSync(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR),
     60 		commandcssync(this)
     61 	{
     62 
     63 	}
     64 };
     65 
     66 MODULE_INIT(CSSync)