From af85aa91f88035ef3ece079381aa99a0e3873ab2 Mon Sep 17 00:00:00 2001 From: prozacx Date: Thu, 10 Mar 2005 05:37:20 +0000 Subject: [PATCH] Notice user on /watch instead of privmsg git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@38 726aef4b-f618-498e-8847-2d620e286838 --- modules/watch.cpp | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/modules/watch.cpp b/modules/watch.cpp index 4ab6c059..b37eb067 100644 --- a/modules/watch.cpp +++ b/modules/watch.cpp @@ -179,7 +179,7 @@ public: virtual bool OnUserRaw(string& sLine) { if (strncasecmp(sLine.c_str(), "WATCH ", 6) == 0) { - Watch(CUtils::Token(sLine, 1), CUtils::Token(sLine, 2), CUtils::Token(sLine, 3, true)); + Watch(CUtils::Token(sLine, 1), CUtils::Token(sLine, 2), CUtils::Token(sLine, 3, true), true); return true; } @@ -438,21 +438,33 @@ private: } } - void Watch(const string& sHostMask, const string& sTarget, const string& sPattern) { + void Watch(const string& sHostMask, const string& sTarget, const string& sPattern, bool bNotice = false) { + string sMessage; + if (sHostMask.size()) { CWatchEntry WatchEntry(sHostMask, sTarget, sPattern); + bool bExists = false; for (list::iterator it = m_lsWatchers.begin(); it != m_lsWatchers.end(); it++) { if (*it == WatchEntry) { - PutModule("Entry for [" + WatchEntry.GetHostMask() + "] already exists."); - return; + sMessage = "Entry for [" + WatchEntry.GetHostMask() + "] already exists."; + bExists = true; + break; } } - PutModule("Adding entry: [" + WatchEntry.GetHostMask() + "] watching for [" + WatchEntry.GetPattern() + "] -> [" + WatchEntry.GetTarget() + "]"); - m_lsWatchers.push_back(WatchEntry); + if (!bExists) { + sMessage = "Adding entry: [" + WatchEntry.GetHostMask() + "] watching for [" + WatchEntry.GetPattern() + "] -> [" + WatchEntry.GetTarget() + "]"; + m_lsWatchers.push_back(WatchEntry); + } } else { - PutModule("Watch: Not enough arguments. Try Help"); + sMessage = "Watch: Not enough arguments. Try Help"; + } + + if (bNotice) { + PutModNotice(sMessage); + } else { + PutModule(sMessage); } }