mirror of
https://github.com/davegallant/rfd-notify.git
synced 2025-08-05 16:23:39 +00:00
Add check for empty offer
This commit is contained in:
@@ -17,7 +17,8 @@ class Topic:
|
||||
self.title = title
|
||||
self.post_time = post_time
|
||||
self.web_path = web_path
|
||||
self.offer = Offer(**offer)
|
||||
if offer:
|
||||
self.offer = Offer(**offer)
|
||||
|
||||
def __repr__(self):
|
||||
return f"Topic({self.title})"
|
||||
|
@@ -18,12 +18,17 @@ def send_notification(
|
||||
apobj = apprise.Apprise()
|
||||
apobj.add(servers)
|
||||
|
||||
if topic.offer:
|
||||
dealer_name = topic.offer.dealer_name
|
||||
else:
|
||||
dealer_name = ""
|
||||
|
||||
subject = topic.title
|
||||
body = f"""\
|
||||
<b>Post age:</b> {datetime.now(timezone.utc) - datetime.fromisoformat(topic.post_time)}
|
||||
<br>
|
||||
<br>
|
||||
<b>Dealer:</b> {topic.offer.dealer_name}
|
||||
<b>Dealer:</b> {dealer_name}
|
||||
<br>
|
||||
<br>
|
||||
<b>Deal:</b> {topic.title}
|
||||
|
@@ -65,7 +65,7 @@ def look_for_matches(
|
||||
topic_title = topic.title.lower()
|
||||
dealer_name = ""
|
||||
|
||||
if topic.offer.dealer_name is not None:
|
||||
if topic.offer and topic.offer.dealer_name is not None:
|
||||
dealer_name = topic.offer.dealer_name.lower()
|
||||
if re.search(expression, topic_title):
|
||||
found_match = True
|
||||
@@ -86,7 +86,5 @@ def look_for_matches(
|
||||
previous_matches[str(topic.topic_id)] = 1
|
||||
send_notification(topic, posts, expression, apprise_url)
|
||||
else:
|
||||
logger.debug(
|
||||
f"Already matched topic '{topic.offer.dealer_name} - {topic.title}'"
|
||||
)
|
||||
logger.debug(f"Already matched topic '{topic.title}'")
|
||||
break
|
||||
|
Reference in New Issue
Block a user