X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fm_shun.cpp;h=cbaa6840991d3dda1163352cf94de001b0987c7b;hb=551d687ec6d7ce44be35fae0dd7345fe73c4f63a;hp=197bbc1bf9823a26086c44f6b2c0978baf07113c;hpb=2ab2de1dda8f2043898b9df8004ba5b6c4df7349;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/m_shun.cpp b/src/modules/m_shun.cpp index 197bbc1bf..cbaa68409 100644 --- a/src/modules/m_shun.cpp +++ b/src/modules/m_shun.cpp @@ -36,14 +36,11 @@ public: this->matchtext = shunmask; } - ~Shun() - { - } - bool Matches(User *u) { // E: overrides shun - if (u->exempt) + LocalUser* lu = IS_LOCAL(u); + if (lu && lu->exempt) return false; if (InspIRCd::Match(u->GetFullHost(), matchtext) || InspIRCd::Match(u->GetFullRealHost(), matchtext) || InspIRCd::Match(u->nick+"!"+u->ident+"@"+u->GetIPString(), matchtext)) @@ -59,12 +56,6 @@ 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() { return matchtext.c_str(); @@ -107,9 +98,9 @@ class CommandShun : public Command /* 'time' is a human-readable timestring, like 2d3h2s. */ std::string target = parameters[0]; - - User *find = ServerInstance->FindNick(target.c_str()); - if (find) + + User *find = ServerInstance->FindNick(target); + if ((find) && (find->registered == REG_ALL)) target = std::string("*!*@") + find->GetIPString(); if (parameters.size() == 1) @@ -127,11 +118,11 @@ class CommandShun : public Command else { // Adding - XXX todo make this respect tag perhaps.. - long duration; + unsigned long duration; std::string expr; if (parameters.size() > 2) { - duration = ServerInstance->Duration(parameters[1]); + duration = InspIRCd::Duration(parameters[1]); expr = parameters[2]; } else @@ -151,8 +142,9 @@ class CommandShun : public Command else { time_t c_requires_crap = duration + ServerInstance->Time(); + std::string timestr = ServerInstance->TimeString(c_requires_crap); 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()); + user->nick.c_str(), target.c_str(), timestr.c_str(), expr.c_str()); } } else @@ -167,7 +159,10 @@ class CommandShun : public Command RouteDescriptor GetRouting(User* user, const std::vector& parameters) { - return ROUTE_LOCALONLY; + if (IS_LOCAL(user)) + return ROUTE_LOCALONLY; // spanningtree will send ADDLINE + + return ROUTE_BROADCAST; } }; @@ -181,12 +176,16 @@ class ModuleShun : public Module public: ModuleShun() : cmd(this) + { + } + + void init() { ServerInstance->XLines->RegisterFactory(&f); - ServerInstance->AddCommand(&cmd); + ServerInstance->Modules->AddService(cmd); Implementation eventlist[] = { I_OnStats, I_OnPreCommand, I_OnRehash }; - ServerInstance->Modules->Attach(eventlist, this, 3); + ServerInstance->Modules->Attach(eventlist, this, sizeof(eventlist)/sizeof(Implementation)); OnRehash(NULL); } @@ -213,8 +212,9 @@ class ModuleShun : public Module virtual void OnRehash(User* user) { - ConfigReader MyConf; - std::string cmds = MyConf.ReadValue("shun", "enabledcommands", 0); + ConfigTag* tag = ServerInstance->Config->ConfValue("shun"); + std::string cmds = tag->getString("enabledcommands"); + std::transform(cmds.begin(), cmds.end(), cmds.begin(), ::toupper); if (cmds.empty()) cmds = "PING PONG QUIT"; @@ -229,8 +229,8 @@ class ModuleShun : public Module ShunEnabledCommands.insert(thiscmd); } - NotifyOfShun = MyConf.ReadFlag("shun", "notifyuser", "yes", 0); - affectopers = MyConf.ReadFlag("shun", "affectopers", "no", 0); + NotifyOfShun = tag->getBool("notifyuser", true); + affectopers = tag->getBool("affectopers", false); } virtual ModResult OnPreCommand(std::string &command, std::vector& parameters, LocalUser* user, bool validated, const std::string &original_line) @@ -244,7 +244,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; @@ -281,4 +281,3 @@ class ModuleShun : public Module }; MODULE_INIT(ModuleShun) -