From fce789c2e9ab33494ad06ce133bf1bc7d01c54ea Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Sun, 25 Oct 2020 12:17:59 +0000 Subject: [PATCH] Avoid duplication --- newsdaemon.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/newsdaemon.py b/newsdaemon.py index ccc74cb7..19f9a384 100644 --- a/newsdaemon.py +++ b/newsdaemon.py @@ -90,16 +90,12 @@ def hashtagRuleResolve(tree: [], hashtags: [], moderated: bool, content, url) elif tree[0] == 'contains': if len(tree) == 2: + matchStr = None if isinstance(tree[1], str): matchStr = tree[1] - if matchStr.startswith('"') and matchStr.endswith('"'): - matchStr = matchStr[1:] - matchStr = matchStr[:len(matchStr) - 1] - matchStrLower = matchStr.lower() - contentWithoutTags = content.replace('#' + matchStrLower, '') - return matchStrLower in contentWithoutTags elif isinstance(tree[1], list): matchStr = tree[1][0] + if matchStr: if matchStr.startswith('"') and matchStr.endswith('"'): matchStr = matchStr[1:] matchStr = matchStr[:len(matchStr) - 1]