Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: znc/znc
base: a212f081291d
...
head fork: znc/znc
compare: 89f586d17362
Checking mergeability… Don't worry, you can still create the pull request.
  • 2 commits
  • 1 file changed
  • 0 commit comments
  • 2 contributors
Commits on Jun 27, 2012
@rohieb rohieb watch module: Don't handle multiple matching patterns for each target
Keep track of the targets which have already been notified of a matching
message, and do not notify them again if other patterns in the same
message match also. For example, consider the following match patterns:

  1) <*watch> /msg *watch ADD *!*@* *highlight *%nick%*
  2) <*watch> /msg *watch ADD *!*@* *highlight *testuser*
  3) <*watch> /msg *watch ADD *!*@* *testhilights *test*

If %nick% ist something like "testuser123", all of the these patterns
match the following message:

  <otheruser> hey testuser123, look at this: ...

Without this patch, the watch module would generate two notify messages
for target *highlight, and one notify message for target *testhilights.
This is unneccessary because patterns 1 and 2 will result in
generating the same notify message twice for target *highlight.

By using a std::set, the implementation in this patch keeps track of
which targets have already been notified and does not notify them more
than once.
84fae4c
Commits on Nov 08, 2012
@DarthGandalf DarthGandalf Merge commit 'refs/pull/188/head' of github.com:znc/znc
Conflicts:
	modules/watch.cpp
89f586d
Showing with 7 additions and 1 deletion.
  1. +7 −1 modules/watch.cpp
View
8 modules/watch.cpp
@@ -10,9 +10,11 @@
#include <znc/User.h>
#include <znc/IRCNetwork.h>
#include <list>
+#include <set>
using std::list;
using std::vector;
+using std::set;
class CWatchSource {
public:
@@ -287,15 +289,19 @@ class CWatcherMod : public CModule {
private:
void Process(const CNick& Nick, const CString& sMessage, const CString& sSource) {
+ set<CString> sHandledTargets;
+
for (list<CWatchEntry>::iterator it = m_lsWatchers.begin(); it != m_lsWatchers.end(); ++it) {
CWatchEntry& WatchEntry = *it;
- if (WatchEntry.IsMatch(Nick, sMessage, sSource, m_pNetwork)) {
+ if (WatchEntry.IsMatch(Nick, sMessage, sSource, m_pNetwork) &&
+ sHandledTargets.count(WatchEntry.GetTarget()) < 1) {
if (m_pNetwork->IsUserAttached()) {
m_pNetwork->PutUser(":" + WatchEntry.GetTarget() + "!watch@znc.in PRIVMSG " + m_pNetwork->GetCurNick() + " :" + sMessage);
} else {
m_Buffer.AddLine(":" + _NAMEDFMT(WatchEntry.GetTarget()) + "!watch@znc.in PRIVMSG {target} :{text}", sMessage);
}
+ sHandledTargets.insert(WatchEntry.GetTarget());
}
}
}

No commit comments for this range

Something went wrong with that request. Please try again.