fixed Message.filter_tags
This commit is contained in:
@@ -436,13 +436,14 @@ class Message():
|
||||
Filter tags based on their prefix (i. e. the tag starts with a given string)
|
||||
or some contained string.
|
||||
"""
|
||||
res_tags = self.tags
|
||||
if res_tags:
|
||||
if prefix and len(prefix) > 0:
|
||||
res_tags -= {tag for tag in res_tags if not tag.startswith(prefix)}
|
||||
if contain and len(contain) > 0:
|
||||
res_tags -= {tag for tag in res_tags if contain not in tag}
|
||||
return res_tags or set()
|
||||
if not self.tags:
|
||||
return set()
|
||||
res_tags = self.tags.copy()
|
||||
if prefix and len(prefix) > 0:
|
||||
res_tags -= {tag for tag in res_tags if not tag.startswith(prefix)}
|
||||
if contain and len(contain) > 0:
|
||||
res_tags -= {tag for tag in res_tags if contain not in tag}
|
||||
return res_tags
|
||||
|
||||
def tags_str(self, prefix: Optional[str] = None, contain: Optional[str] = None) -> str:
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user