Anope IRC Services  Version 2.0
os_reload.cpp
Go to the documentation of this file.
1 /* OperServ core functions
2  *
3  * (C) 2003-2014 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 CommandOSReload : public Command
15 {
16  public:
17  CommandOSReload(Module *creator) : Command(creator, "operserv/reload", 0, 0)
18  {
19  this->SetDesc(_("Reload services' configuration file"));
20  }
21 
22  void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
23  {
24  try
25  {
26  Log(LOG_ADMIN, source, this);
27 
28  Configuration::Conf *new_config = new Configuration::Conf();
30  Config = new_config;
31  Config->Post(old);
32  delete old;
33 
34  source.Reply(_("Services' configuration has been reloaded."));
35  }
36  catch (const ConfigException &ex)
37  {
38  Log(this->owner) << "Error reloading configuration file: " << ex.GetReason();
39  source.Reply(_("Error reloading configuration file: %s"), ex.GetReason().c_str());
40  }
41  }
42 
43  bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
44  {
45  this->SendSyntax(source);
46  source.Reply(" ");
47  source.Reply(_("Causes Services to reload the configuration file. Note that\n"
48  "some directives still need the restart of the Services to\n"
49  "take effect (such as Services' nicknames, activation of the\n"
50  "session limitation, etc.)."));
51  return true;
52  }
53 };
54 
55 class OSReload : public Module
56 {
58 
59  public:
60  OSReload(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR),
61  commandosreload(this)
62  {
63 
64  }
65 };
66 
OSReload(const Anope::string &modname, const Anope::string &creator)
Definition: os_reload.cpp:60
CommandOSReload(Module *creator)
Definition: os_reload.cpp:17
void SetDesc(const Anope::string &d)
Definition: command.cpp:130
Definition: Config.cs:26
#define anope_override
Definition: services.h:56
CommandOSReload commandosreload
Definition: os_reload.cpp:57
#define MODULE_INIT(x)
Definition: modules.h:45
bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
Definition: os_reload.cpp:43
virtual const Anope::string & GetReason() const
Definition: anope.h:672
void SendSyntax(CommandSource &)
Definition: command.cpp:145
const char * c_str() const
Definition: anope.h:117
Definition: logger.h:53
CoreExport Configuration::Conf * Config
Definition: config.cpp:24
void Execute(CommandSource &source, const std::vector< Anope::string > &params) anope_override
Definition: os_reload.cpp:22
#define _(x)
Definition: services.h:50
Module * owner
Definition: service.h:84