X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fm_shun.cpp;h=e11aa995604f809a485376f442f4b240b87dd136;hb=2f8303334f2c5a62bcce47d39e8cf41208a9a296;hp=43359c28a04c4bfce40bd3e969d65cbd57c6e75c;hpb=86775e2e98f55b3b88befe2daff0ca23f02f3155;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/m_shun.cpp b/src/modules/m_shun.cpp index 43359c28a..e11aa9956 100644 --- a/src/modules/m_shun.cpp +++ b/src/modules/m_shun.cpp @@ -2,7 +2,7 @@ * | Inspire Internet Relay Chat Daemon | * +------------------------------------+ * - * InspIRCd: (C) 2002-2009 InspIRCd Development Team + * InspIRCd: (C) 2002-2010 InspIRCd Development Team * See: http://wiki.inspircd.org/Credits * * This program is free but copyrighted software; see @@ -21,8 +21,8 @@ class Shun : public XLine public: std::string matchtext; - Shun(InspIRCd* Instance, time_t s_time, long d, std::string src, std::string re, std::string shunmask) - : XLine(Instance, s_time, d, src, re, "SHUN") + Shun(time_t s_time, long d, std::string src, std::string re, std::string shunmask) + : XLine(s_time, d, src, re, "SHUN") { this->matchtext = shunmask; } @@ -72,13 +72,13 @@ public: class ShunFactory : public XLineFactory { public: - ShunFactory(InspIRCd* Instance) : XLineFactory(Instance, "SHUN") { } + ShunFactory() : XLineFactory("SHUN") { } /** Generate a shun */ XLine* Generate(time_t set_time, long duration, std::string source, std::string reason, std::string xline_specific_mask) { - return new Shun(ServerInstance, set_time, duration, source, reason, xline_specific_mask); + return new Shun(set_time, duration, source, reason, xline_specific_mask); } }; @@ -87,9 +87,9 @@ class ShunFactory : public XLineFactory class CommandShun : public Command { public: - CommandShun(InspIRCd* Me, Module* Creator) : Command(Me, Creator, "SHUN", "o", 1, 3) + CommandShun(Module* Creator) : Command(Creator, "SHUN", 1, 3) { - this->syntax = " [] :"; + flags_needed = 'o'; this->syntax = " [] :"; } CmdResult Handle(const std::vector& parameters, User *user) @@ -107,12 +107,11 @@ class CommandShun : public Command { if (ServerInstance->XLines->DelLine(target.c_str(), "SHUN", user)) { - ServerInstance->SNO->WriteToSnoMask('x',"%s Removed shun on %s.",user->nick.c_str(),target.c_str()); + ServerInstance->SNO->WriteToSnoMask('x',"%s removed SHUN on %s",user->nick.c_str(),target.c_str()); } else { - // XXX todo implement stats - user->WriteServ("NOTICE %s :*** Shun %s not found in list, try /stats S.",user->nick.c_str(),target.c_str()); + user->WriteServ("NOTICE %s :*** Shun %s not found in list, try /stats H.",user->nick.c_str(),target.c_str()); } return CMD_SUCCESS; @@ -136,7 +135,7 @@ class CommandShun : public Command try { - r = new Shun(ServerInstance, ServerInstance->Time(), duration, user->nick.c_str(), expr.c_str(), target.c_str()); + r = new Shun(ServerInstance->Time(), duration, user->nick.c_str(), expr.c_str(), target.c_str()); } catch (...) { @@ -149,13 +148,13 @@ class CommandShun : public Command { if (!duration) { - ServerInstance->SNO->WriteToSnoMask('x',"%s added permanent shun for %s: %s", + ServerInstance->SNO->WriteToSnoMask('x',"%s added permanent SHUN for %s: %s", user->nick.c_str(), target.c_str(), expr.c_str()); } else { time_t c_requires_crap = duration + ServerInstance->Time(); - ServerInstance->SNO->WriteToSnoMask('x', "%s added timed shun for %s, expires on %s: %s", + ServerInstance->SNO->WriteToSnoMask('x', "%s added timed SHUN for %s to expire on %s: %s", user->nick.c_str(), target.c_str(), ServerInstance->TimeString(c_requires_crap).c_str(), expr.c_str()); } @@ -171,6 +170,11 @@ class CommandShun : public Command return CMD_FAILURE; } + + RouteDescriptor GetRouting(User* user, const std::vector& parameters) + { + return ROUTE_BROADCAST; + } }; class ModuleShun : public Module @@ -182,7 +186,7 @@ class ModuleShun : public Module bool affectopers; public: - ModuleShun(InspIRCd* Me) : Module(Me), cmd(Me, this), f(Me) + ModuleShun() : cmd(this) { ServerInstance->XLines->RegisterFactory(&f); ServerInstance->AddCommand(&cmd); @@ -198,9 +202,15 @@ class ModuleShun : public Module ServerInstance->XLines->UnregisterFactory(&f); } + void Prioritize() + { + Module* alias = ServerInstance->Modules->Find("m_alias.so"); + ServerInstance->Modules->SetPriority(this, I_OnPreCommand, PRIORITY_BEFORE, &alias); + } + virtual ModResult OnStats(char symbol, User* user, string_list& out) { - if (symbol != 'S') + if (symbol != 'H') return MOD_RES_PASSTHRU; ServerInstance->XLines->InvokeStats("SHUN", 223, user, out); @@ -209,7 +219,7 @@ class ModuleShun : public Module virtual void OnRehash(User* user) { - ConfigReader MyConf(ServerInstance); + ConfigReader MyConf; std::string cmds = MyConf.ReadValue("shun", "enabledcommands", 0); if (cmds.empty()) @@ -231,7 +241,7 @@ class ModuleShun : public Module affectopers = MyConf.ReadFlag("shun", "affectopers", "no", 0); } - virtual void OnUserConnect(User* user) + virtual void OnUserConnect(LocalUser* user) { if (!IS_LOCAL(user)) return; @@ -246,7 +256,7 @@ class ModuleShun : public Module } } - virtual ModResult OnPreCommand(std::string &command, std::vector& parameters, User* user, bool validated, const std::string &original_line) + virtual ModResult OnPreCommand(std::string &command, std::vector& parameters, LocalUser* user, bool validated, const std::string &original_line) { if (validated) return MOD_RES_PASSTHRU; @@ -289,7 +299,7 @@ class ModuleShun : public Module virtual Version GetVersion() { - return Version("$Id$",VF_VENDOR|VF_COMMON,API_VERSION); + return Version("Provides the /shun command, which stops a user executing all commands except PING and PONG.",VF_VENDOR|VF_COMMON); } };