cs_set_description.cpp

Go to the documentation of this file.
00001 /* ChanServ core functions
00002  *
00003  * (C) 2003-2012 Anope Team
00004  * Contact us at team@anope.org
00005  *
00006  * Please read COPYING and README for further details.
00007  *
00008  * Based on the original code of Epona by Lara.
00009  * Based on the original code of Services by Andy Church.
00010  */
00011 
00012 /*************************************************************************/
00013 
00014 #include "module.h"
00015 
00016 class CommandCSSetDescription : public Command
00017 {
00018  public:
00019         CommandCSSetDescription(Module *creator, const Anope::string &cname = "chanserv/set/description") : Command(creator, cname, 1, 2)
00020         {
00021                 this->SetDesc(_("Set the channel description"));
00022                 this->SetSyntax(_("\037channel\037 [\037description\037]"));
00023         }
00024 
00025         void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
00026         {
00027                 ChannelInfo *ci = ChannelInfo::Find(params[0]);
00028                 if (ci == NULL)
00029                 {
00030                         source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str());
00031                         return;
00032                 }
00033 
00034                 EventReturn MOD_RESULT;
00035                 FOREACH_RESULT(I_OnSetChannelOption, OnSetChannelOption(source, this, ci, params[1]));
00036                 if (MOD_RESULT == EVENT_STOP)
00037                         return;
00038 
00039                 if (MOD_RESULT != EVENT_ALLOW && source.permission.empty() && !source.AccessFor(ci).HasPriv("SET"))
00040                 {
00041                         source.Reply(ACCESS_DENIED);
00042                         return;
00043                 }
00044 
00045                 if (params.size() > 1)
00046                 {
00047                         ci->desc = params[1];
00048                         source.Reply(_("Description of %s changed to \002%s\002."), ci->name.c_str(), ci->desc.c_str());
00049                 }
00050                 else
00051                 {
00052                         ci->desc.clear();
00053                         source.Reply(_("Description of %s unset."), ci->name.c_str());
00054                 }
00055 
00056                 return;
00057         }
00058 
00059         bool OnHelp(CommandSource &source, const Anope::string &) anope_override
00060         {
00061                 this->SendSyntax(source);
00062                 source.Reply(" ");
00063                 source.Reply(_("Sets the description for the channel, which shows up with\n"
00064                                 "the \002LIST\002 and \002INFO\002 commands."), this->name.c_str());
00065                 return true;
00066         }
00067 };
00068 
00069 class CSSetDescription : public Module
00070 {
00071         CommandCSSetDescription commandcssetdescription;
00072 
00073  public:
00074         CSSetDescription(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, CORE),
00075                 commandcssetdescription(this)
00076         {
00077                 this->SetAuthor("Anope");
00078 
00079         }
00080 };
00081 
00082 MODULE_INIT(CSSetDescription)