X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fm_svshold.cpp;h=05a8d09b107c7cee5b622c523b729fc3a353dcf5;hb=551d687ec6d7ce44be35fae0dd7345fe73c4f63a;hp=a38776d8db7a501a7a8f1fefe20a19cb4cccfce9;hpb=44f42a13de52c8025942ddab42f51feb36821782;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/m_svshold.cpp b/src/modules/m_svshold.cpp index a38776d8d..05a8d09b1 100644 --- a/src/modules/m_svshold.cpp +++ b/src/modules/m_svshold.cpp @@ -38,10 +38,6 @@ public: this->nickname = nick.c_str(); } - ~SVSHold() - { - } - bool Matches(User *u) { if (u->nick == nickname) @@ -56,12 +52,6 @@ public: 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)); - } - const char* Displayable() { return nickname.c_str(); @@ -81,6 +71,11 @@ class SVSHoldFactory : public XLineFactory { return new SVSHold(set_time, duration, source, reason, xline_specific_mask); } + + bool AutoApplyToUserList(XLine *x) + { + return false; + } }; /** Handle /SVSHold @@ -115,45 +110,33 @@ class CommandSvshold : public Command { user->WriteServ("NOTICE %s :*** SVSHOLD %s not found in list, try /stats S.",user->nick.c_str(),parameters[0].c_str()); } - - return CMD_SUCCESS; } - else if (parameters.size() >= 2) + else { - // Adding - XXX todo make this respect tag perhaps.. - long duration = ServerInstance->Duration(parameters[1]); - SVSHold *r = NULL; + if (parameters.size() < 3) + return CMD_FAILURE; - try - { - r = new SVSHold(ServerInstance->Time(), duration, user->nick.c_str(), parameters[2].c_str(), parameters[0].c_str()); - } - catch (...) - { - ; // Do nothing. - } + 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 (r) + if (ServerInstance->XLines->AddLine(r, user)) { - if (ServerInstance->XLines->AddLine(r, user)) + if (!duration) { - if (!duration) - { - ServerInstance->SNO->WriteGlobalSno('x', "%s added permanent SVSHOLD for %s: %s", user->nick.c_str(), parameters[0].c_str(), parameters[2].c_str()); - } - else - { - time_t c_requires_crap = duration + ServerInstance->Time(); - ServerInstance->SNO->WriteGlobalSno('x', "%s added timed SVSHOLD for %s, expires on %s: %s", user->nick.c_str(), parameters[0].c_str(), ServerInstance->TimeString(c_requires_crap).c_str(), parameters[2].c_str()); - } - - ServerInstance->XLines->ApplyLines(); + ServerInstance->SNO->WriteGlobalSno('x', "%s added permanent SVSHOLD for %s: %s", user->nick.c_str(), parameters[0].c_str(), parameters[2].c_str()); } else { - delete r; + time_t c_requires_crap = duration + ServerInstance->Time(); + std::string timestr = ServerInstance->TimeString(c_requires_crap); + ServerInstance->SNO->WriteGlobalSno('x', "%s added timed SVSHOLD for %s, expires on %s: %s", user->nick.c_str(), parameters[0].c_str(), timestr.c_str(), parameters[2].c_str()); } } + else + { + delete r; + return CMD_FAILURE; + } } return CMD_SUCCESS; @@ -173,14 +156,17 @@ class ModuleSVSHold : public Module public: ModuleSVSHold() : cmd(this) + { + } + + void init() { ServerInstance->XLines->RegisterFactory(&s); - ServerInstance->AddCommand(&cmd); + ServerInstance->Modules->AddService(cmd); Implementation eventlist[] = { I_OnUserPreNick, I_OnStats }; - ServerInstance->Modules->Attach(eventlist, this, 2); + ServerInstance->Modules->Attach(eventlist, this, sizeof(eventlist)/sizeof(Implementation)); } - virtual ModResult OnStats(char symbol, User* user, string_list &out) { if(symbol != 'S')