anope- supernets anope source code & configuration |
git clone git://git.acid.vegas/anope.git |
Log | Files | Refs | Archive | README |
hs_del.cpp (2850B)
1 /* HostServ 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 CommandHSDel : public Command 15 { 16 public: 17 CommandHSDel(Module *creator) : Command(creator, "hostserv/del", 1, 1) 18 { 19 this->SetDesc(_("Delete the vhost of another user")); 20 this->SetSyntax(_("\037nick\037")); 21 } 22 23 void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override 24 { 25 if (Anope::ReadOnly) 26 { 27 source.Reply(READ_ONLY_MODE); 28 return; 29 } 30 31 const Anope::string &nick = params[0]; 32 NickAlias *na = NickAlias::Find(nick); 33 if (na) 34 { 35 Log(LOG_ADMIN, source, this) << "for user " << na->nick; 36 FOREACH_MOD(OnDeleteVhost, (na)); 37 na->RemoveVhost(); 38 source.Reply(_("Vhost for \002%s\002 removed."), nick.c_str()); 39 } 40 else 41 source.Reply(NICK_X_NOT_REGISTERED, nick.c_str()); 42 } 43 44 bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override 45 { 46 this->SendSyntax(source); 47 source.Reply(" "); 48 source.Reply(_("Deletes the vhost assigned to the given nick from the\n" 49 "database.")); 50 return true; 51 } 52 }; 53 54 class CommandHSDelAll : public Command 55 { 56 public: 57 CommandHSDelAll(Module *creator) : Command(creator, "hostserv/delall", 1, 1) 58 { 59 this->SetDesc(_("Deletes the vhost for all nicks in a group")); 60 this->SetSyntax(_("\037nick\037")); 61 } 62 63 void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override 64 { 65 if (Anope::ReadOnly) 66 { 67 source.Reply(READ_ONLY_MODE); 68 return; 69 } 70 71 const Anope::string &nick = params[0]; 72 NickAlias *na = NickAlias::Find(nick); 73 if (na) 74 { 75 FOREACH_MOD(OnDeleteVhost, (na)); 76 const NickCore *nc = na->nc; 77 for (unsigned i = 0; i < nc->aliases->size(); ++i) 78 { 79 na = nc->aliases->at(i); 80 na->RemoveVhost(); 81 } 82 Log(LOG_ADMIN, source, this) << "for all nicks in group " << nc->display; 83 source.Reply(_("vhosts for group \002%s\002 have been removed."), nc->display.c_str()); 84 } 85 else 86 source.Reply(NICK_X_NOT_REGISTERED, nick.c_str()); 87 } 88 89 bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override 90 { 91 this->SendSyntax(source); 92 source.Reply(" "); 93 source.Reply(_("Deletes the vhost for all nicks in the same group as\n" 94 "that of the given nick.")); 95 return true; 96 } 97 }; 98 99 class HSDel : public Module 100 { 101 CommandHSDel commandhsdel; 102 CommandHSDelAll commandhsdelall; 103 104 public: 105 HSDel(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), 106 commandhsdel(this), commandhsdelall(this) 107 { 108 if (!IRCD || !IRCD->CanSetVHost) 109 throw ModuleException("Your IRCd does not support vhosts"); 110 } 111 }; 112 113 MODULE_INIT(HSDel)