X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fm_silence.cpp;h=3a213c6e7c2e0b2c43d8526a75f3137d04736767;hb=7acb4ced207da7308d471a4ca434ce1cc7b9e9cb;hp=0e9a45720b3b99bfc3f41a0be938621db388fd19;hpb=7a67685bcb863b0d4199715e86697fee423596c2;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/m_silence.cpp b/src/modules/m_silence.cpp index 0e9a45720..3a213c6e7 100644 --- a/src/modules/m_silence.cpp +++ b/src/modules/m_silence.cpp @@ -23,8 +23,6 @@ #include "inspircd.h" -/* $ModDesc: Provides support for the /SILENCE command */ - /* Improved drop-in replacement for the /SILENCE command * syntax: /SILENCE [+|-] as in * @@ -66,7 +64,7 @@ class CommandSVSSilence : public Command CommandSVSSilence(Module* Creator) : Command(Creator,"SVSSILENCE", 2) { syntax = " {[+|-] }"; - TRANSLATE4(TR_NICK, TR_TEXT, TR_TEXT, TR_END); /* we watch for a nick. not a UID. */ + TRANSLATE3(TR_NICK, TR_TEXT, TR_TEXT); } CmdResult Handle (const std::vector& parameters, User *user) @@ -78,7 +76,7 @@ class CommandSVSSilence : public Command * style command so services can modify lots of entries at once. * leaving it backwards compatible for now as it's late. -- w */ - if (!ServerInstance->ULine(user->server)) + if (!user->server->IsULine()) return CMD_FAILURE; User *u = ServerInstance->FindNick(parameters[0]); @@ -87,7 +85,7 @@ class CommandSVSSilence : public Command if (IS_LOCAL(u)) { - ServerInstance->Parser->CallHandler("SILENCE", std::vector(++parameters.begin(), parameters.end()), u); + ServerInstance->Parser->CallHandler("SILENCE", std::vector(parameters.begin() + 1, parameters.end()), u); } return CMD_SUCCESS; @@ -112,7 +110,6 @@ class CommandSilence : public Command { allow_empty_last_param = false; syntax = "{[+|-] }"; - TRANSLATE3(TR_TEXT, TR_TEXT, TR_END); } CmdResult Handle (const std::vector& parameters, User *user) @@ -127,10 +124,10 @@ class CommandSilence : public Command for (silencelist::const_iterator c = sl->begin(); c != sl->end(); c++) { std::string decomppattern = DecompPattern(c->second); - user->WriteNumeric(271, "%s %s %s %s",user->nick.c_str(), user->nick.c_str(),c->first.c_str(), decomppattern.c_str()); + user->WriteNumeric(271, "%s %s %s", user->nick.c_str(),c->first.c_str(), decomppattern.c_str()); } } - user->WriteNumeric(272, "%s :End of Silence List",user->nick.c_str()); + user->WriteNumeric(272, ":End of Silence List"); return CMD_SUCCESS; } @@ -176,7 +173,7 @@ class CommandSilence : public Command if (listitem == mask && i->second == pattern) { sl->erase(i); - user->WriteNumeric(950, "%s %s :Removed %s %s from silence list",user->nick.c_str(), user->nick.c_str(), mask.c_str(), decomppattern.c_str()); + user->WriteNumeric(950, "%s :Removed %s %s from silence list", user->nick.c_str(), mask.c_str(), decomppattern.c_str()); if (!sl->size()) { ext.unset(user); @@ -185,7 +182,7 @@ class CommandSilence : public Command } } } - user->WriteNumeric(952, "%s %s :%s %s does not exist on your silence list",user->nick.c_str(), user->nick.c_str(), mask.c_str(), decomppattern.c_str()); + user->WriteNumeric(952, "%s :%s %s does not exist on your silence list", user->nick.c_str(), mask.c_str(), decomppattern.c_str()); } else if (action == '+') { @@ -198,7 +195,7 @@ class CommandSilence : public Command } if (sl->size() > maxsilence) { - user->WriteNumeric(952, "%s %s :Your silence list is full",user->nick.c_str(), user->nick.c_str()); + user->WriteNumeric(952, "%s :Your silence list is full",user->nick.c_str()); return CMD_FAILURE; } @@ -208,7 +205,7 @@ class CommandSilence : public Command irc::string listitem = n->first.c_str(); if (listitem == mask && n->second == pattern) { - user->WriteNumeric(952, "%s %s :%s %s is already on your silence list",user->nick.c_str(), user->nick.c_str(), mask.c_str(), decomppattern.c_str()); + user->WriteNumeric(952, "%s :%s %s is already on your silence list", user->nick.c_str(), mask.c_str(), decomppattern.c_str()); return CMD_FAILURE; } } @@ -220,7 +217,7 @@ class CommandSilence : public Command { sl->push_back(silenceset(mask,pattern)); } - user->WriteNumeric(951, "%s %s :Added %s %s to silence list",user->nick.c_str(), user->nick.c_str(), mask.c_str(), decomppattern.c_str()); + user->WriteNumeric(951, "%s :Added %s %s to silence list", user->nick.c_str(), mask.c_str(), decomppattern.c_str()); return CMD_SUCCESS; } } @@ -302,20 +299,9 @@ class ModuleSilence : public Module { } - void init() CXX11_OVERRIDE - { - OnRehash(NULL); - ServerInstance->Modules->AddService(cmdsilence); - ServerInstance->Modules->AddService(cmdsvssilence); - ServerInstance->Modules->AddService(cmdsilence.ext); - - Implementation eventlist[] = { I_OnRehash, I_On005Numeric, I_OnUserPreMessage, I_OnUserPreInvite }; - ServerInstance->Modules->Attach(eventlist, this, sizeof(eventlist)/sizeof(Implementation)); - } - - void OnRehash(User* user) CXX11_OVERRIDE + void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE { - maxsilence = ServerInstance->Config->ConfValue("showwhois")->getInt("maxentries", 32); + maxsilence = ServerInstance->Config->ConfValue("silence")->getInt("maxentries", 32); if (!maxsilence) maxsilence = 32; } @@ -352,10 +338,7 @@ class ModuleSilence : public Module else if (target_type == TYPE_CHANNEL) { Channel* chan = (Channel*)dest; - if (chan) - { - this->OnBuildExemptList(msgtype, chan, user, status, exempt_list, ""); - } + this->OnBuildExemptList(msgtype, chan, user, status, exempt_list, ""); } return MOD_RES_PASSTHRU; } @@ -367,10 +350,6 @@ class ModuleSilence : public Module ModResult MatchPattern(User* dest, User* source, int pattern) { - /* Server source */ - if (!source || !dest) - return MOD_RES_ALLOW; - silencelist* sl = cmdsilence.ext.get(dest); if (sl) {