X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fm_svshold.cpp;h=fc1eb5381a84505395b2c9954f190cc75f027178;hb=e950f568d0f571e9475aa38177486468714de4d3;hp=d2269839d94bf95d74cade0a14a750e6c396395e;hpb=391ec2c499523e98c681ccf5bf9f03a4fe551f57;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/m_svshold.cpp b/src/modules/m_svshold.cpp index d2269839d..fc1eb5381 100644 --- a/src/modules/m_svshold.cpp +++ b/src/modules/m_svshold.cpp @@ -23,23 +23,17 @@ #include "inspircd.h" #include "xline.h" -/* $ModDesc: Implements SVSHOLD. Like Q:Lines, but can only be added/removed by Services. */ - /** Holds a SVSHold item */ class SVSHold : public XLine { public: - irc::string nickname; + std::string nickname; - SVSHold(time_t s_time, long d, std::string src, std::string re, std::string nick) + SVSHold(time_t s_time, long d, const std::string& src, const std::string& re, const std::string& nick) : XLine(s_time, d, src, re, "SVSHOLD") { - this->nickname = nick.c_str(); - } - - ~SVSHold() - { + this->nickname = nick; } bool Matches(User *u) @@ -51,20 +45,12 @@ public: bool Matches(const std::string &s) { - if (nickname == s) - return true; - return false; - } - - void DisplayExpiry() - { - ServerInstance->SNO->WriteToSnoMask('x',"Removing expired SVSHOLD %s (set by %s %ld seconds ago)", - this->nickname.c_str(), this->source.c_str(), (long int)(ServerInstance->Time() - this->set_time)); + return InspIRCd::Match(s, nickname); } - const char* Displayable() + const std::string& Displayable() { - return nickname.c_str(); + return nickname; } }; @@ -96,7 +82,6 @@ class CommandSvshold : public Command CommandSvshold(Module* Creator) : Command(Creator, "SVSHOLD", 1) { flags_needed = 'o'; this->syntax = " [ :]"; - TRANSLATE4(TR_TEXT, TR_TEXT, TR_TEXT, TR_END); } CmdResult Handle(const std::vector ¶meters, User *user) @@ -118,7 +103,7 @@ class CommandSvshold : public Command } else { - user->WriteServ("NOTICE %s :*** SVSHOLD %s not found in list, try /stats S.",user->nick.c_str(),parameters[0].c_str()); + user->WriteNotice("*** SVSHOLD " + parameters[0] + " not found in list, try /stats S."); } } else @@ -126,8 +111,7 @@ class CommandSvshold : public Command if (parameters.size() < 3) return CMD_FAILURE; - // Adding - XXX todo make this respect tag perhaps.. - long duration = ServerInstance->Duration(parameters[1]); + unsigned long duration = InspIRCd::Duration(parameters[1]); SVSHold* r = new SVSHold(ServerInstance->Time(), duration, user->nick.c_str(), parameters[2].c_str(), parameters[0].c_str()); if (ServerInstance->XLines->AddLine(r, user)) @@ -170,15 +154,13 @@ class ModuleSVSHold : public Module { } - void init() + void init() CXX11_OVERRIDE { ServerInstance->XLines->RegisterFactory(&s); ServerInstance->Modules->AddService(cmd); - Implementation eventlist[] = { I_OnUserPreNick, I_OnStats }; - ServerInstance->Modules->Attach(eventlist, this, sizeof(eventlist)/sizeof(Implementation)); } - virtual ModResult OnStats(char symbol, User* user, string_list &out) + ModResult OnStats(char symbol, User* user, string_list &out) CXX11_OVERRIDE { if(symbol != 'S') return MOD_RES_PASSTHRU; @@ -187,7 +169,7 @@ class ModuleSVSHold : public Module return MOD_RES_DENY; } - virtual ModResult OnUserPreNick(User *user, const std::string &newnick) + ModResult OnUserPreNick(User *user, const std::string &newnick) CXX11_OVERRIDE { XLine *rl = ServerInstance->XLines->MatchesLine("SVSHOLD", newnick); @@ -200,13 +182,13 @@ class ModuleSVSHold : public Module return MOD_RES_PASSTHRU; } - virtual ~ModuleSVSHold() + ~ModuleSVSHold() { ServerInstance->XLines->DelAll("SVSHOLD"); ServerInstance->XLines->UnregisterFactory(&s); } - virtual Version GetVersion() + Version GetVersion() CXX11_OVERRIDE { return Version("Implements SVSHOLD. Like Q:Lines, but can only be added/removed by Services.", VF_COMMON | VF_VENDOR); }