Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #include "module.h"
00015
00016 class CommandHSDel : public Command
00017 {
00018 public:
00019 CommandHSDel(Module *creator) : Command(creator, "hostserv/del", 1, 1)
00020 {
00021 this->SetDesc(_("Delete the vhost of another user"));
00022 this->SetSyntax(_("\037nick\037"));
00023 }
00024
00025 void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override
00026 {
00027 const Anope::string &nick = params[0];
00028 NickAlias *na = NickAlias::Find(nick);
00029 if (na)
00030 {
00031 Log(LOG_ADMIN, source, this) << "for user " << na->nick;
00032 FOREACH_MOD(I_OnDeleteVhost, OnDeleteVhost(na));
00033 na->RemoveVhost();
00034 source.Reply(_("Vhost for \002%s\002 removed."), nick.c_str());
00035 }
00036 else
00037 source.Reply(NICK_X_NOT_REGISTERED, nick.c_str());
00038 }
00039
00040 bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
00041 {
00042 this->SendSyntax(source);
00043 source.Reply(" ");
00044 source.Reply(_("Deletes the vhost assigned to the given nick from the\n"
00045 "database."));
00046 return true;
00047 }
00048 };
00049
00050 class CommandHSDelAll : public Command
00051 {
00052 public:
00053 CommandHSDelAll(Module *creator) : Command(creator, "hostserv/delall", 1, 1)
00054 {
00055 this->SetDesc(_("Delete the vhost for all nicks in a group"));
00056 this->SetSyntax(_("\037nick\037"));
00057 }
00058
00059 void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override
00060 {
00061 const Anope::string &nick = params[0];
00062 NickAlias *na = NickAlias::Find(nick);
00063 if (na)
00064 {
00065 FOREACH_MOD(I_OnDeleteVhost, OnDeleteVhost(na));
00066 const NickCore *nc = na->nc;
00067 for (unsigned i = 0; i < nc->aliases->size(); ++i)
00068 {
00069 na = nc->aliases->at(i);
00070 na->RemoveVhost();
00071 }
00072 Log(LOG_ADMIN, source, this) << "for all nicks in group " << nc->display;
00073 source.Reply(_("vhosts for group \002%s\002 have been removed."), nc->display.c_str());
00074 }
00075 else
00076 source.Reply(NICK_X_NOT_REGISTERED, nick.c_str());
00077 }
00078
00079 bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
00080 {
00081 this->SendSyntax(source);
00082 source.Reply(" ");
00083 source.Reply(_("Deletes the vhost for all nicks in the same group as\n"
00084 "that of the given nick."));
00085 return true;
00086 }
00087 };
00088
00089 class HSDel : public Module
00090 {
00091 CommandHSDel commandhsdel;
00092 CommandHSDelAll commandhsdelall;
00093
00094 public:
00095 HSDel(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, CORE),
00096 commandhsdel(this), commandhsdelall(this)
00097 {
00098 this->SetAuthor("Anope");
00099
00100 }
00101 };
00102
00103 MODULE_INIT(HSDel)