X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fm_shun.cpp;h=d3baffefb2714d6bf6debec3316776fcd6374b78;hb=909cba9b756179bfa16d985916db1084cb7b4a9d;hp=bf31cd70efb6c901361c6470f0c3f8a403d9d791;hpb=886f1ba488a5ab9d7fe4d7b4ac6b9c9dc2841738;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/m_shun.cpp b/src/modules/m_shun.cpp index bf31cd70e..d3baffefb 100644 --- a/src/modules/m_shun.cpp +++ b/src/modules/m_shun.cpp @@ -23,17 +23,15 @@ #include "inspircd.h" #include "xline.h" -/* $ModDesc: Provides the /SHUN command, which stops a user from executing all except configured commands. */ - class Shun : public XLine { public: std::string matchtext; - Shun(time_t s_time, long d, std::string src, std::string re, std::string shunmask) + Shun(time_t s_time, long d, const std::string& src, const std::string& re, const std::string& shunmask) : XLine(s_time, d, src, re, "SHUN") + , matchtext(shunmask) { - this->matchtext = shunmask; } bool Matches(User *u) @@ -56,15 +54,9 @@ public: return false; } - void DisplayExpiry() - { - ServerInstance->SNO->WriteToSnoMask('x',"Removing expired shun %s (set by %s %ld seconds ago)", - this->matchtext.c_str(), this->source.c_str(), (long int)(ServerInstance->Time() - this->set_time)); - } - - const char* Displayable() + const std::string& Displayable() { - return matchtext.c_str(); + return matchtext; } }; @@ -117,7 +109,7 @@ class CommandShun : public Command } else { - user->WriteServ("NOTICE %s :*** Shun %s not found in list, try /stats H.",user->nick.c_str(),target.c_str()); + user->WriteNotice("*** Shun " + target + " not found in list, try /stats H."); return CMD_FAILURE; } } @@ -156,7 +148,7 @@ class CommandShun : public Command else { delete r; - user->WriteServ("NOTICE %s :*** Shun for %s already exists", user->nick.c_str(), target.c_str()); + user->WriteNotice("*** Shun for " + target + " already exists"); return CMD_FAILURE; } } @@ -185,7 +177,7 @@ class ModuleShun : public Module { } - void init() + void init() CXX11_OVERRIDE { ServerInstance->XLines->RegisterFactory(&f); ServerInstance->Modules->AddService(cmd); @@ -195,7 +187,7 @@ class ModuleShun : public Module OnRehash(NULL); } - virtual ~ModuleShun() + ~ModuleShun() { ServerInstance->XLines->DelAll("SHUN"); ServerInstance->XLines->UnregisterFactory(&f); @@ -207,7 +199,7 @@ class ModuleShun : public Module ServerInstance->Modules->SetPriority(this, I_OnPreCommand, PRIORITY_BEFORE, &alias); } - virtual ModResult OnStats(char symbol, User* user, string_list& out) + ModResult OnStats(char symbol, User* user, string_list& out) CXX11_OVERRIDE { if (symbol != 'H') return MOD_RES_PASSTHRU; @@ -216,7 +208,7 @@ class ModuleShun : public Module return MOD_RES_DENY; } - virtual void OnRehash(User* user) + void OnRehash(User* user) CXX11_OVERRIDE { ConfigTag* tag = ServerInstance->Config->ConfValue("shun"); std::string cmds = tag->getString("enabledcommands"); @@ -239,7 +231,7 @@ class ModuleShun : public Module affectopers = tag->getBool("affectopers", false); } - virtual ModResult OnPreCommand(std::string &command, std::vector& parameters, LocalUser* user, bool validated, const std::string &original_line) + ModResult OnPreCommand(std::string &command, std::vector& parameters, LocalUser* user, bool validated, const std::string &original_line) CXX11_OVERRIDE { if (validated) return MOD_RES_PASSTHRU; @@ -250,7 +242,7 @@ class ModuleShun : public Module return MOD_RES_PASSTHRU; } - if (!affectopers && IS_OPER(user)) + if (!affectopers && user->IsOper()) { /* Don't do anything if the user is an operator and affectopers isn't set */ return MOD_RES_PASSTHRU; @@ -261,7 +253,7 @@ class ModuleShun : public Module if (i == ShunEnabledCommands.end()) { if (NotifyOfShun) - user->WriteServ("NOTICE %s :*** Command %s not processed, as you have been blocked from issuing commands (SHUN)", user->nick.c_str(), command.c_str()); + user->WriteNotice("*** Command " + command + " not processed, as you have been blocked from issuing commands (SHUN)"); return MOD_RES_DENY; } @@ -280,7 +272,7 @@ class ModuleShun : public Module return MOD_RES_PASSTHRU; } - virtual Version GetVersion() + Version GetVersion() CXX11_OVERRIDE { return Version("Provides the /SHUN command, which stops a user from executing all except configured commands.",VF_VENDOR|VF_COMMON); }