bs_set_private.cpp

Go to the documentation of this file.
00001 /* BotServ 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 CommandBSSetPrivate : public Command
00017 {
00018  public:
00019         CommandBSSetPrivate(Module *creator, const Anope::string &sname = "botserv/set/private") : Command(creator, sname, 2, 2)
00020         {
00021                 this->SetDesc(_("Prevent a bot from being assigned by non IRC operators"));
00022                 this->SetSyntax(_("\037botname\037 {\037ON|OFF\037}"));
00023         }
00024 
00025         void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
00026         {
00027                 BotInfo *bi = BotInfo::Find(params[0], true);
00028                 const Anope::string &value = params[1];
00029 
00030                 if (bi == NULL)
00031                 {
00032                         source.Reply(BOT_DOES_NOT_EXIST, params[0].c_str());
00033                         return;
00034                 }
00035 
00036                 if (!source.HasCommand("botserv/set/private"))
00037                 {
00038                         source.Reply(ACCESS_DENIED);
00039                         return;
00040                 }
00041 
00042                 if (value.equals_ci("ON"))
00043                 {
00044                         bi->SetFlag(BI_PRIVATE);
00045                         source.Reply(_("Private mode of bot %s is now \002on\002."), bi->nick.c_str());
00046                 }
00047                 else if (value.equals_ci("OFF"))
00048                 {
00049                         bi->UnsetFlag(BI_PRIVATE);
00050                         source.Reply(_("Private mode of bot %s is now \002off\002."), bi->nick.c_str());
00051                 }
00052                 else
00053                         this->OnSyntaxError(source, source.command);
00054         }
00055 
00056         bool OnHelp(CommandSource &source, const Anope::string &) anope_override
00057         {
00058                 this->SendSyntax(source);
00059                 source.Reply(_(" \n"
00060                         "This option prevents a bot from being assigned to a\n"
00061                         "channel by users that aren't IRC operators."));
00062                 return true;
00063         }
00064 };
00065 
00066 class BSSetPrivate : public Module
00067 {
00068         CommandBSSetPrivate commandbssetprivate;
00069 
00070  public:
00071         BSSetPrivate(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, CORE),
00072                 commandbssetprivate(this)
00073         {
00074                 this->SetAuthor("Anope");
00075         }
00076 };
00077 
00078 MODULE_INIT(BSSetPrivate)