X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fcommon%2Fignorelistmanager.cpp;h=bd37a20e3917397f956c401e3537c7f96a49a0a6;hp=dfd9ae2db03b1b747db4a53cb67ca5036b801ddd;hb=f6f67e9fa8012ce2cc45420838fa7469622d454e;hpb=f19fea582ace1d8f3dfe29c1096c48758079e56e diff --git a/src/common/ignorelistmanager.cpp b/src/common/ignorelistmanager.cpp index dfd9ae2d..bd37a20e 100644 --- a/src/common/ignorelistmanager.cpp +++ b/src/common/ignorelistmanager.cpp @@ -122,7 +122,7 @@ IgnoreListManager::StrictnessType IgnoreListManager::match(const Message &msg, c return UnmatchedStrictness; foreach(IgnoreListItem item, _ignoreList) { - if(!item.isActive) + if(!item.isActive || item.type == CtcpIgnore) continue; if(item.scope == GlobalScope || (item.scope == NetworkScope && scopeMatch(item.scopeRule, network)) || (item.scope == ChannelScope && scopeMatch(item.scopeRule, msg.bufferInfo().bufferName()))) { @@ -178,3 +178,28 @@ void IgnoreListManager::toggleIgnoreRule(const QString &ignoreRule) { _ignoreList[idx].isActive = !_ignoreList[idx].isActive; SYNC(ARG(ignoreRule)) } + +bool IgnoreListManager::ctcpMatch(const QString sender, const QString &network, const QString &type) { + foreach(IgnoreListItem item, _ignoreList) { + if(!item.isActive) + continue; + if(item.scope == GlobalScope || (item.scope == NetworkScope && scopeMatch(item.scopeRule, network))) { + QString sender_; + QStringList types = item.ignoreRule.split(QRegExp("\\s+"), QString::SkipEmptyParts); + + sender_ = types.takeAt(0); + + QRegExp ruleRx = QRegExp(sender_); + ruleRx.setCaseSensitivity(Qt::CaseInsensitive); + if(!item.isRegEx) + ruleRx.setPatternSyntax(QRegExp::Wildcard); + if((!item.isRegEx && ruleRx.exactMatch(sender)) || + (item.isRegEx && ruleRx.indexIn(sender) != -1)) { + + if(types.isEmpty() || types.contains(type, Qt::CaseInsensitive)) + return true; + } + } + } + return false; +}