diff options
author | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2008-09-21 12:17:31 +0000 |
---|---|---|
committer | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2008-09-21 12:17:31 +0000 |
commit | be609949e3ec2543d6cb16d23240870028732f36 (patch) | |
tree | 2f55fa5ed596ac1b2f6c9322fb883ec2d8ee99c5 | |
parent | ce6764c87f83c3a74aae0fcd75547a368601b14a (diff) |
Fix various rline bugs, implement /stats R, and fix the issue where you get no error. "Something will already have said why it fucked up" -- what
about when the rline fails due to missing provider?
Also fix the fact that we dont have a catch around the Generate() in addline, which would just make insp abort.
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@10577 e03df62e-2008-0410-955e-edbf42e46eb7
-rw-r--r-- | src/modules/m_rline.cpp | 31 | ||||
-rw-r--r-- | src/modules/m_spanningtree/addline.cpp | 11 |
2 files changed, 28 insertions, 14 deletions
diff --git a/src/modules/m_rline.cpp b/src/modules/m_rline.cpp index 7ea9d36b4..3b15ec89e 100644 --- a/src/modules/m_rline.cpp +++ b/src/modules/m_rline.cpp @@ -49,7 +49,7 @@ class CoreExport RLine : public XLine catch (ModuleException& ex) { ServerInstance->SNO->WriteToSnoMask('x', "Bad regex: %s", ex.GetReason()); - throw; + throw ex; } } @@ -149,9 +149,9 @@ class CommandRLine : public Command { r = new RLine(ServerInstance, ServerInstance->Time(), duration, user->nick.c_str(), parameters[2].c_str(), parameters[0].c_str()); } - catch (...) + catch (ModuleException &e) { - ; // Do nothing. If we get here, the regex was fucked up, and they already got told it fucked up. + ServerInstance->SNO->WriteToSnoMask('x',"Could not add RLINE: %s", e.GetReason()); } if (r) @@ -186,8 +186,7 @@ class CommandRLine : public Command } else { - // XXX todo implement stats - user->WriteServ("NOTICE %s :*** R-Line %s not found in list, try /stats g.",user->nick.c_str(),parameters[0].c_str()); + user->WriteServ("NOTICE %s :*** R-Line %s not found in list, try /stats R.",user->nick.c_str(),parameters[0].c_str()); } } @@ -218,8 +217,8 @@ class ModuleRLine : public Module f = new RLineFactory(ServerInstance); ServerInstance->XLines->RegisterFactory(f); - Implementation eventlist[] = { I_OnUserConnect, I_OnRehash, I_OnUserPostNick, I_OnLoadModule }; - ServerInstance->Modules->Attach(eventlist, this, 3); + Implementation eventlist[] = { I_OnUserConnect, I_OnRehash, I_OnUserPostNick, I_OnLoadModule, I_OnStats }; + ServerInstance->Modules->Attach(eventlist, this, 5); } @@ -252,15 +251,13 @@ class ModuleRLine : public Module ConfigReader Conf(ServerInstance); MatchOnNickChange = Conf.ReadFlag("rline", "matchonnickchange", 0); - - std::string newrxengine; - - newrxengine = Conf.ReadValue("rline", "engine", 0); + std::string newrxengine = Conf.ReadValue("rline", "engine", 0); if (!RegexEngine.empty()) { if (RegexEngine == newrxengine) return; + ServerInstance->SNO->WriteToSnoMask('x', "Dumping all R-Lines due to regex engine change (was '%s', now '%s')", RegexEngine.c_str(), newrxengine.c_str()); ServerInstance->XLines->DelAll("R"); } @@ -271,8 +268,7 @@ class ModuleRLine : public Module { for (modulelist::iterator i = ml->begin(); i != ml->end(); ++i) { - std::string rxname = RegexNameRequest(this, *i).Send(); - if (rxname == newrxengine) + if (RegexNameRequest(this, *i).Send() == newrxengine) { ServerInstance->SNO->WriteToSnoMask('x', "R-Line now using engine '%s'", RegexEngine.c_str()); rxengine = *i; @@ -285,6 +281,15 @@ class ModuleRLine : public Module } } + virtual int OnStats(char symbol, User* user, string_list &results) + { + if (symbol != 'R') + return 0; + + ServerInstance->XLines->InvokeStats("R", 223, user, results); + return 1; + } + virtual void OnLoadModule(Module* mod, const std::string& name) { if (ServerInstance->Modules->ModuleHasInterface(mod, "RegularExpression")) diff --git a/src/modules/m_spanningtree/addline.cpp b/src/modules/m_spanningtree/addline.cpp index b9bca3109..dde9f45d3 100644 --- a/src/modules/m_spanningtree/addline.cpp +++ b/src/modules/m_spanningtree/addline.cpp @@ -47,7 +47,16 @@ bool TreeSocket::AddLine(const std::string &prefix, std::deque<std::string> &par return true; } - XLine* xl = xlf->Generate(Instance->Time(), atoi(params[4].c_str()), params[2].c_str(), params[5].c_str(), params[1].c_str()); + XLine* xl = NULL; + try + { + xl = xlf->Generate(Instance->Time(), atoi(params[4].c_str()), params[2].c_str(), params[5].c_str(), params[1].c_str()); + } + catch (ModuleException &e) + { + this->Instance->SNO->WriteToSnoMask('x',"Unable to ADDLINE type %s from %s: %s", params[0].c_str(), setter.c_str(), e.GetReason()); + return true; + } xl->SetCreateTime(atoi(params[3].c_str())); if (Instance->XLines->AddLine(xl,NULL)) { |