anope

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

cs_getkey.cpp (1775B)

      1 /* ChanServ core functions
      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 CommandCSGetKey : public Command
     15 {
     16  public:
     17 	CommandCSGetKey(Module *creator) : Command(creator, "chanserv/getkey", 1, 1)
     18 	{
     19 		this->SetDesc(_("Returns the key of the given channel"));
     20 		this->SetSyntax(_("\037channel\037"));
     21 	}
     22 
     23 	void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
     24 	{
     25 		const Anope::string &chan = params[0];
     26 
     27 		ChannelInfo *ci = ChannelInfo::Find(params[0]);
     28 		if (ci == NULL)
     29 		{
     30 			source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str());
     31 			return;
     32 		}
     33 
     34 		if (!source.AccessFor(ci).HasPriv("GETKEY") && !source.HasCommand("chanserv/getkey"))
     35 		{
     36 			source.Reply(ACCESS_DENIED);
     37 			return;
     38 		}
     39 
     40 		Anope::string key;
     41 		if (!ci->c || !ci->c->GetParam("KEY", key))
     42 		{
     43 			source.Reply(_("Channel \002%s\002 has no key."), chan.c_str());
     44 			return;
     45 		}
     46 
     47 		bool override = !source.AccessFor(ci).HasPriv("GETKEY");
     48 		Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci);
     49 
     50 		source.Reply(_("Key for channel \002%s\002 is \002%s\002."), chan.c_str(), key.c_str());
     51 	}
     52 
     53 	bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
     54 	{
     55 		this->SendSyntax(source);
     56 		source.Reply(" ");
     57 		source.Reply(_("Returns the key of the given channel."));
     58 		return true;
     59 	}
     60 };
     61 
     62 class CSGetKey : public Module
     63 {
     64 	CommandCSGetKey commandcsgetkey;
     65 
     66  public:
     67 	CSGetKey(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), commandcsgetkey(this)
     68 	{
     69 
     70 	}
     71 };
     72 
     73 MODULE_INIT(CSGetKey)