summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swift/Controllers/HighlightRule.cpp')
-rw-r--r--Swift/Controllers/HighlightRule.cpp21
1 files changed, 17 insertions, 4 deletions
diff --git a/Swift/Controllers/HighlightRule.cpp b/Swift/Controllers/HighlightRule.cpp
index 40b7560..021e15d 100644
--- a/Swift/Controllers/HighlightRule.cpp
+++ b/Swift/Controllers/HighlightRule.cpp
@@ -10,13 +10,15 @@
* See the COPYING file for more information.
*/
+#include <Swift/Controllers/HighlightRule.h>
+
#include <algorithm>
+
#include <boost/algorithm/string.hpp>
#include <boost/lambda/lambda.hpp>
-#include <Swiften/Base/foreach.h>
#include <Swiften/Base/Regex.h>
-#include <Swift/Controllers/HighlightRule.h>
+#include <Swiften/Base/foreach.h>
namespace Swift {
@@ -69,10 +71,21 @@ bool HighlightRule::isMatch(const std::string& body, const std::string& sender,
bool matchesKeyword = keywords_.empty() && (nick.empty() || !nickIsKeyword_);
bool matchesSender = senders_.empty();
- if (!matchesKeyword && nickIsKeyword_ && !nick.empty()) {
- if (boost::regex_search(body, regexFromString(nick))) {
+ if (!matchesKeyword) {
+ // check if the nickname matches
+ if (nickIsKeyword_ && !nick.empty() && boost::regex_search(body, regexFromString(nick))) {
matchesKeyword = true;
}
+
+ // check if a keyword matches
+ if (!matchesKeyword && !keywords_.empty()) {
+ foreach (const boost::regex &keyword, keywordRegex_) {
+ if (boost::regex_search(body, keyword)) {
+ matchesKeyword = true;
+ break;
+ }
+ }
+ }
}
foreach (const boost::regex & rx, senderRegex_) {