]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_rline.cpp
Convert InspIRCd::SetSignals to a static function.
[user/henk/code/inspircd.git] / src / modules / m_rline.cpp
index 77b3bc3aa66d98e5dcd42227ed83ba654abd8714..f9abe2158fffd769f99227edd37e4d68b061c59e 100644 (file)
@@ -32,7 +32,7 @@ class RLine : public XLine
 {
  public:
 
-       /** Create a R-Line.
+       /** Create a R-line.
         * @param s_time The set time
         * @param d The duration of the xline
         * @param src The sender of the xline
@@ -80,9 +80,9 @@ class RLine : public XLine
                        ZLine* zl = new ZLine(ServerInstance->Time(), duration ? expiry - ServerInstance->Time() : 0, ServerInstance->Config->ServerName.c_str(), reason.c_str(), u->GetIPString());
                        if (ServerInstance->XLines->AddLine(zl, NULL))
                        {
-                               std::string timestr = InspIRCd::TimeString(zl->expiry);
-                               ServerInstance->SNO->WriteToSnoMask('x', "Z-line added due to R-line match on *@%s%s%s: %s",
-                                       zl->ipaddr.c_str(), zl->duration ? " to expire on " : "", zl->duration ? timestr.c_str() : "", zl->reason.c_str());
+                               std::string expirystr = zl->duration ? InspIRCd::Format(" to expire in %s (on %s)", InspIRCd::DurationString(zl->duration).c_str(), InspIRCd::TimeString(zl->expiry).c_str()) : "";
+                               ServerInstance->SNO->WriteToSnoMask('x', "Z-line added due to R-line match on %s%s: %s",
+                                       zl->ipaddr.c_str(), expirystr.c_str(), zl->reason.c_str());
                                added_zline = true;
                        }
                        else
@@ -137,7 +137,7 @@ class CommandRLine : public Command
  public:
        CommandRLine(Module* Creator, RLineFactory& rlf) : Command(Creator,"RLINE", 1, 3), factory(rlf)
        {
-               flags_needed = 'o'; this->syntax = "<regex> [<rline-duration>] :<reason>";
+               flags_needed = 'o'; this->syntax = "<regex> [<duration> :<reason>]";
        }
 
        CmdResult Handle(User* user, const Params& parameters) CXX11_OVERRIDE
@@ -150,7 +150,7 @@ class CommandRLine : public Command
                        unsigned long duration;
                        if (!InspIRCd::Duration(parameters[1], duration))
                        {
-                               user->WriteNotice("*** Invalid duration for R-line");
+                               user->WriteNotice("*** Invalid duration for R-line.");
                                return CMD_FAILURE;
                        }
                        XLine *r = NULL;
@@ -161,7 +161,7 @@ class CommandRLine : public Command
                        }
                        catch (ModuleException &e)
                        {
-                               ServerInstance->SNO->WriteToSnoMask('a',"Could not add RLINE: " + e.GetReason());
+                               ServerInstance->SNO->WriteToSnoMask('a', "Could not add R-line: " + e.GetReason());
                        }
 
                        if (r)
@@ -170,13 +170,13 @@ class CommandRLine : public Command
                                {
                                        if (!duration)
                                        {
-                                               ServerInstance->SNO->WriteToSnoMask('x',"%s added permanent R-line for %s: %s", user->nick.c_str(), parameters[0].c_str(), parameters[2].c_str());
+                                               ServerInstance->SNO->WriteToSnoMask('x', "%s added permanent R-line for %s: %s", user->nick.c_str(), parameters[0].c_str(), parameters[2].c_str());
                                        }
                                        else
                                        {
-                                               time_t c_requires_crap = duration + ServerInstance->Time();
-                                               std::string timestr = InspIRCd::TimeString(c_requires_crap);
-                                               ServerInstance->SNO->WriteToSnoMask('x', "%s added timed R-line for %s to expire on %s: %s", user->nick.c_str(), parameters[0].c_str(), timestr.c_str(), parameters[2].c_str());
+                                               ServerInstance->SNO->WriteToSnoMask('x', "%s added timed R-line for %s, expires in %s (on %s): %s",
+                                                       user->nick.c_str(), parameters[0].c_str(), InspIRCd::DurationString(duration).c_str(),
+                                                       InspIRCd::TimeString(ServerInstance->Time() + duration).c_str(), parameters[2].c_str());
                                        }
 
                                        ServerInstance->XLines->ApplyLines();
@@ -184,19 +184,21 @@ class CommandRLine : public Command
                                else
                                {
                                        delete r;
-                                       user->WriteNotice("*** R-Line for " + parameters[0] + " already exists");
+                                       user->WriteNotice("*** R-line for " + parameters[0] + " already exists.");
                                }
                        }
                }
                else
                {
-                       if (ServerInstance->XLines->DelLine(parameters[0].c_str(), "R", user))
+                       std::string reason;
+
+                       if (ServerInstance->XLines->DelLine(parameters[0].c_str(), "R", reason, user))
                        {
-                               ServerInstance->SNO->WriteToSnoMask('x',"%s removed R-line on %s",user->nick.c_str(),parameters[0].c_str());
+                               ServerInstance->SNO->WriteToSnoMask('x', "%s removed R-line on %s: %s", user->nick.c_str(), parameters[0].c_str(), reason.c_str());
                        }
                        else
                        {
-                               user->WriteNotice("*** R-Line " + parameters[0] + " not found in list, try /stats R.");
+                               user->WriteNotice("*** R-line " + parameters[0] + " not found on the list.");
                        }
                }
 
@@ -244,7 +246,7 @@ class ModuleRLine : public Module, public Stats::EventListener
 
        Version GetVersion() CXX11_OVERRIDE
        {
-               return Version("RLINE: Regexp user banning.", VF_COMMON | VF_VENDOR, rxfactory ? rxfactory->name : "");
+               return Version("Provides support for banning users through regular expression patterns", VF_COMMON | VF_VENDOR, rxfactory ? rxfactory->name : "");
        }
 
        ModResult OnUserRegister(LocalUser* user) CXX11_OVERRIDE
@@ -279,15 +281,15 @@ class ModuleRLine : public Module, public Stats::EventListener
                if (!rxfactory)
                {
                        if (newrxengine.empty())
-                               ServerInstance->SNO->WriteToSnoMask('a', "WARNING: No regex engine loaded - R-Line functionality disabled until this is corrected.");
+                               ServerInstance->SNO->WriteToSnoMask('a', "WARNING: No regex engine loaded - R-line functionality disabled until this is corrected.");
                        else
-                               ServerInstance->SNO->WriteToSnoMask('a', "WARNING: Regex engine '%s' is not loaded - R-Line functionality disabled until this is corrected.", newrxengine.c_str());
+                               ServerInstance->SNO->WriteToSnoMask('a', "WARNING: Regex engine '%s' is not loaded - R-line functionality disabled until this is corrected.", newrxengine.c_str());
 
                        ServerInstance->XLines->DelAll(f.GetType());
                }
                else if ((!initing) && (rxfactory.operator->() != factory))
                {
-                       ServerInstance->SNO->WriteToSnoMask('a', "Regex engine has changed, removing all R-Lines");
+                       ServerInstance->SNO->WriteToSnoMask('a', "Regex engine has changed, removing all R-lines.");
                        ServerInstance->XLines->DelAll(f.GetType());
                }
 
@@ -331,7 +333,7 @@ class ModuleRLine : public Module, public Stats::EventListener
 
        void OnUnloadModule(Module* mod) CXX11_OVERRIDE
        {
-               // If the regex engine became unavailable or has changed, remove all rlines
+               // If the regex engine became unavailable or has changed, remove all R-lines.
                if (!rxfactory)
                {
                        ServerInstance->XLines->DelAll(f.GetType());