2 Commits

Author SHA1 Message Date
renovate[bot]
547471de98 Update dependency pytest to v8.3.4 2025-02-14 01:11:44 +00:00
Dave Gallant
9a4a12bf54 Remove html formatting in notifications to support other notification systems 2025-02-13 20:10:42 -05:00
7 changed files with 14 additions and 38 deletions

View File

@@ -28,7 +28,7 @@ jobs:
TAGS="${IMAGE_NAME}:${VERSION}"
if [[ $VERSION =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then
TAGS="$TAGS,${IMAGE_NAME}:1"
TAGS="$TAGS,${IMAGE_NAME}:2"
fi
echo ::set-output name=tags::${TAGS}

View File

@@ -7,7 +7,6 @@ This was originally written before [alerts](https://www.redflagdeals.com/alerts/
## Prerequisites
- either [poetry](https://github.com/python-poetry/poetry), docker, or github actions
- for email notifications [see supported providers](https://github.com/caronc/apprise/wiki/Notify_email#using-built-in-email-services)
## Usage
@@ -30,7 +29,7 @@ The following environment variables are required:
| VARIABLE | DESCRIPTION |
| ----------- | ---------------------------------------------------------------------------------------- |
| APPRISE_URL | See [notifications](https://github.com/caronc/apprise#productivity-based-notifications). |
| APPRISE_URL | See [supported notifications](https://github.com/caronc/apprise#productivity-based-notifications). |
## Example Configuration
@@ -93,7 +92,7 @@ With Gitlab Pipelines, the following configuration works:
#.gitlab-ci.yml
default:
image:
name: ghcr.io/davegallant/rfd-notify:1
name: ghcr.io/davegallant/rfd-notify:2
entrypoint: [""]
run:

View File

@@ -1,3 +1,3 @@
FROM ghcr.io/davegallant/rfd-notify:1
FROM ghcr.io/davegallant/rfd-notify:2
ENTRYPOINT ["python", "/app/rfd_notify/cli.py", "-c", "config.yml"]

6
poetry.lock generated
View File

@@ -482,13 +482,13 @@ testutils = ["gitpython (>3)"]
[[package]]
name = "pytest"
version = "8.3.3"
version = "8.3.4"
description = "pytest: simple powerful testing with Python"
optional = false
python-versions = ">=3.8"
files = [
{file = "pytest-8.3.3-py3-none-any.whl", hash = "sha256:a6853c7375b2663155079443d2e45de913a911a11d669df02a50814944db57b2"},
{file = "pytest-8.3.3.tar.gz", hash = "sha256:70b98107bd648308a7952b06e6ca9a50bc660be218d53c257cc1fc94fda10181"},
{file = "pytest-8.3.4-py3-none-any.whl", hash = "sha256:50e16d954148559c9a74109af1eaf0c945ba2d8f30f0a3d3335edde19788b6f6"},
{file = "pytest-8.3.4.tar.gz", hash = "sha256:965370d062bce11e73868e0335abac31b4d3de0e82f4007408d242b4f8610761"},
]
[package.dependencies]

View File

@@ -1,6 +1,6 @@
[tool.poetry]
name = "rfd-notify"
version = "1.0.0"
version = "2.0.0"
description = "get notified of deals based on regex"
authors = ["Dave Gallant <dave.gallant@gmail.com>"]
readme = "README.md"

View File

@@ -1,16 +1,12 @@
from typing import List
from datetime import datetime, timezone
import apprise
from models.topic import Topic
from models.post import Post
from loguru import logger
from constants import API_BASE_URL
def send_notification(
topic: Topic, posts: List[Post], expression: str, servers: str
) -> None:
def send_notification(topic: Topic, expression: str, servers: str) -> None:
if servers is None:
logger.warning("APPRISE_URL is not set. Will not send notification")
return
@@ -18,30 +14,12 @@ 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> {dealer_name}
<br>
<br>
<b>Deal:</b> {topic.title}
<br>
<br>
<b>Post:</b> {API_BASE_URL}{topic.web_path}\
<br>
<br>
<b>Body:</b> {posts[0].body}
<br>
<br>
<b>Matched by expression:</b> {expression}
"""
{API_BASE_URL}{topic.web_path}
Age: {datetime.now(timezone.utc) - datetime.fromisoformat(topic.post_time)}
Matched by expression: {expression}
"""
logger.debug("Sending notification")

View File

@@ -84,9 +84,8 @@ def look_for_matches(
continue
if str(topic.topic_id) not in previous_matches:
posts = get_topic(topic.topic_id)
previous_matches[str(topic.topic_id)] = 1
send_notification(topic, posts, expression, apprise_url)
send_notification(topic, expression, apprise_url)
else:
logger.debug(f"Already matched topic '{topic.title}'")
break