diff --git a/discord_rss_bot/filter/blacklist.py b/discord_rss_bot/filter/blacklist.py
index bde6de1..45092ba 100644
--- a/discord_rss_bot/filter/blacklist.py
+++ b/discord_rss_bot/filter/blacklist.py
@@ -38,13 +38,17 @@ def should_be_skipped(custom_reader: Reader, entry: Entry) -> bool:
feed: Feed = entry.feed
blacklist_title: str = str(custom_reader.get_tag(feed, "blacklist_title", ""))
blacklist_summary: str = str(custom_reader.get_tag(feed, "blacklist_summary", ""))
- # blacklist_content: str = str(custom_reader.get_tag(feed, "blacklist_content", ""))
- # TODO: Fix content
- # TODO: Check author
+ blacklist_content: str = str(custom_reader.get_tag(feed, "blacklist_content", ""))
+ blacklist_author: str = str(custom_reader.get_tag(feed, "blacklist_author", ""))
# TODO: Also add support for entry_text
if entry.title and blacklist_title and is_word_in_text(blacklist_title, entry.title):
return True
elif entry.summary and blacklist_summary and is_word_in_text(blacklist_summary, entry.summary):
return True
+ elif entry.author and blacklist_author and is_word_in_text(blacklist_author, entry.author):
+ return True
+ elif entry.content:
+ if entry.content[0].value and blacklist_content and is_word_in_text(blacklist_content, entry.content[0].value):
+ return True
return False
diff --git a/discord_rss_bot/filter/whitelist.py b/discord_rss_bot/filter/whitelist.py
index d183219..03c8f45 100644
--- a/discord_rss_bot/filter/whitelist.py
+++ b/discord_rss_bot/filter/whitelist.py
@@ -38,12 +38,16 @@ def should_be_sent(custom_reader: Reader, entry: Entry) -> bool:
feed: Feed = entry.feed
whitelist_title: str = str(custom_reader.get_tag(feed, "whitelist_title", ""))
whitelist_summary: str = str(custom_reader.get_tag(feed, "whitelist_summary", ""))
- # whitelist_content: str = get_whitelist_content(custom_reader, feed)
- # TODO: Fix content
- # TODO: Check author
+ whitelist_content: str = str(custom_reader.get_tag(feed, "whitelist_content", ""))
+ whitelist_author: str = str(custom_reader.get_tag(feed, "whitelist_author", ""))
if entry.title and whitelist_title and is_word_in_text(whitelist_title, entry.title):
return True
elif entry.summary and whitelist_summary and is_word_in_text(whitelist_summary, entry.summary):
return True
+ elif entry.author and whitelist_author and is_word_in_text(whitelist_author, entry.author):
+ return True
+ elif entry.content:
+ if entry.content[0].value and whitelist_content and is_word_in_text(whitelist_content, entry.content[0].value):
+ return True
return False
diff --git a/discord_rss_bot/main.py b/discord_rss_bot/main.py
index d0a3112..dcfc6cb 100644
--- a/discord_rss_bot/main.py
+++ b/discord_rss_bot/main.py
@@ -113,14 +113,16 @@ async def post_set_whitelist(
whitelist_title: str = Form(None),
whitelist_summary: str = Form(None),
whitelist_content: str = Form(None),
+ whitelist_author: str = Form(None),
feed_url: str = Form(),
):
"""Set what the whitelist should be sent, if you have this set only words in the whitelist will be sent.
Args:
whitelist_title: Whitelisted words for when checking the title.
- whitelist_summary: Whitelisted words for when checking the title.
- whitelist_content: Whitelisted words for when checking the title.
+ whitelist_summary: Whitelisted words for when checking the summary.
+ whitelist_content: Whitelisted words for when checking the content.
+ whitelist_author: Whitelisted words for when checking the author.
feed_url: The feed we should set the whitelist for.
"""
clean_feed_url: str = feed_url.strip()
@@ -130,6 +132,8 @@ async def post_set_whitelist(
reader.set_tag(clean_feed_url, "whitelist_summary", whitelist_summary) # type: ignore
if whitelist_content:
reader.set_tag(clean_feed_url, "whitelist_content", whitelist_content) # type: ignore
+ if whitelist_author:
+ reader.set_tag(clean_feed_url, "whitelist_author", whitelist_author) # type: ignore
return RedirectResponse(url=f"/feed/?feed_url={urllib.parse.quote(clean_feed_url)}", status_code=303)
@@ -148,6 +152,7 @@ async def get_whitelist(feed_url: str, request: Request):
whitelist_title: str = str(reader.get_tag(feed, "whitelist_title", ""))
whitelist_summary: str = str(reader.get_tag(feed, "whitelist_summary", ""))
whitelist_content: str = str(reader.get_tag(feed, "whitelist_content", ""))
+ whitelist_author: str = str(reader.get_tag(feed, "whitelist_author", ""))
context = {
"request": request,
@@ -155,6 +160,7 @@ async def get_whitelist(feed_url: str, request: Request):
"whitelist_title": whitelist_title,
"whitelist_summary": whitelist_summary,
"whitelist_content": whitelist_content,
+ "whitelist_author": whitelist_author,
}
return templates.TemplateResponse("whitelist.html", context)
@@ -164,6 +170,7 @@ async def post_set_blacklist(
blacklist_title: str = Form(None),
blacklist_summary: str = Form(None),
blacklist_content: str = Form(None),
+ blacklist_author: str = Form(None),
feed_url: str = Form(),
):
"""Set the blacklist, if this is set we will check if words are in the title, summary or content
@@ -173,15 +180,18 @@ async def post_set_blacklist(
blacklist_title: Blacklisted words for when checking the title.
blacklist_summary: Blacklisted words for when checking the summary.
blacklist_content: Blacklisted words for when checking the content.
+ blacklist_author: Blacklisted words for when checking the author.
feed_url: What feed we should set the blacklist for.
"""
- clean_feed_url = feed_url.strip()
+ clean_feed_url: str = feed_url.strip()
if blacklist_title:
reader.set_tag(clean_feed_url, "blacklist_title", blacklist_title) # type: ignore
if blacklist_summary:
reader.set_tag(clean_feed_url, "blacklist_summary", blacklist_summary) # type: ignore
if blacklist_content:
reader.set_tag(clean_feed_url, "blacklist_content", blacklist_content) # type: ignore
+ if blacklist_author:
+ reader.set_tag(clean_feed_url, "blacklist_author", blacklist_author) # type: ignore
return RedirectResponse(url=f"/feed/?feed_url={urllib.parse.quote(feed_url)}", status_code=303)
@@ -194,6 +204,7 @@ async def get_blacklist(feed_url: str, request: Request):
blacklist_title: str = str(reader.get_tag(feed, "blacklist_title", ""))
blacklist_summary: str = str(reader.get_tag(feed, "blacklist_summary", ""))
blacklist_content: str = str(reader.get_tag(feed, "blacklist_content", ""))
+ blacklist_author: str = str(reader.get_tag(feed, "blacklist_author", ""))
context = {
"request": request,
@@ -201,6 +212,7 @@ async def get_blacklist(feed_url: str, request: Request):
"blacklist_title": blacklist_title,
"blacklist_summary": blacklist_summary,
"blacklist_content": blacklist_content,
+ "blacklist_author": blacklist_author,
}
return templates.TemplateResponse("blacklist.html", context)
diff --git a/discord_rss_bot/templates/blacklist.html b/discord_rss_bot/templates/blacklist.html
index 4e4893e..705e118 100644
--- a/discord_rss_bot/templates/blacklist.html
+++ b/discord_rss_bot/templates/blacklist.html
@@ -46,15 +46,22 @@
value="{% if blacklist_summary %}
{{- blacklist_summary -}}
{% endif %}"/>
-
+
+ {% endif %}"/>
+
+
diff --git a/discord_rss_bot/templates/whitelist.html b/discord_rss_bot/templates/whitelist.html
index 7cf52eb..129acb5 100644
--- a/discord_rss_bot/templates/whitelist.html
+++ b/discord_rss_bot/templates/whitelist.html
@@ -46,15 +46,22 @@
value="{% if whitelist_summary %}
{{- whitelist_summary -}}
{% endif %}"/>
-
+
+ {% endif %}"/>
+
+
diff --git a/tests/test_blacklist.py b/tests/test_blacklist.py
index fd9eba7..e190cd2 100644
--- a/tests/test_blacklist.py
+++ b/tests/test_blacklist.py
@@ -86,9 +86,21 @@ def test_should_be_skipped() -> None:
assert should_be_skipped(reader, first_entry[0]) is False
reader.set_tag(feed, "blacklist_content", "ffdnfdnfdnfdnfdndfn") # type: ignore
- # TODO: This is not impelemented yet
+ assert should_be_skipped(reader, first_entry[0]) is True
+ reader.delete_tag(feed, "blacklist_content")
+ assert should_be_skipped(reader, first_entry[0]) is False
+
+ reader.set_tag(feed, "blacklist_content", "åäö") # type: ignore
assert should_be_skipped(reader, first_entry[0]) is False
reader.delete_tag(feed, "blacklist_content")
assert should_be_skipped(reader, first_entry[0]) is False
- # TODO: Also add support for entry_text
+ reader.set_tag(feed, "blacklist_author", "TheLovinator") # type: ignore
+ assert should_be_skipped(reader, first_entry[0]) is True
+ reader.delete_tag(feed, "blacklist_author")
+ assert should_be_skipped(reader, first_entry[0]) is False
+
+ reader.set_tag(feed, "blacklist_author", "åäö") # type: ignore
+ assert should_be_skipped(reader, first_entry[0]) is False
+ reader.delete_tag(feed, "blacklist_author")
+ assert should_be_skipped(reader, first_entry[0]) is False
diff --git a/tests/test_whitelist.py b/tests/test_whitelist.py
index 4ea9deb..dccfb3f 100644
--- a/tests/test_whitelist.py
+++ b/tests/test_whitelist.py
@@ -86,9 +86,21 @@ def test_should_be_sent() -> None:
assert should_be_sent(reader, first_entry[0]) is False
reader.set_tag(feed, "whitelist_content", "ffdnfdnfdnfdnfdndfn") # type: ignore
- # TODO: This is not impelemented yet
+ assert should_be_sent(reader, first_entry[0]) is True
+ reader.delete_tag(feed, "whitelist_content")
+ assert should_be_sent(reader, first_entry[0]) is False
+
+ reader.set_tag(feed, "whitelist_content", "åäö") # type: ignore
assert should_be_sent(reader, first_entry[0]) is False
reader.delete_tag(feed, "whitelist_content")
assert should_be_sent(reader, first_entry[0]) is False
- # TODO: Also add support for entry_text
+ reader.set_tag(feed, "whitelist_author", "TheLovinator") # type: ignore
+ assert should_be_sent(reader, first_entry[0]) is True
+ reader.delete_tag(feed, "whitelist_author")
+ assert should_be_sent(reader, first_entry[0]) is False
+
+ reader.set_tag(feed, "whitelist_author", "åäö") # type: ignore
+ assert should_be_sent(reader, first_entry[0]) is False
+ reader.delete_tag(feed, "whitelist_author")
+ assert should_be_sent(reader, first_entry[0]) is False