2 Commits

Author SHA1 Message Date
renovate[bot]
0c7daf44a4 Update dependency black to v25 2025-02-14 01:12:12 +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 38 additions and 62 deletions

View File

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

View File

@@ -7,7 +7,6 @@ This was originally written before [alerts](https://www.redflagdeals.com/alerts/
## Prerequisites ## Prerequisites
- either [poetry](https://github.com/python-poetry/poetry), docker, or github actions - 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 ## Usage
@@ -30,7 +29,7 @@ The following environment variables are required:
| VARIABLE | DESCRIPTION | | 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 ## Example Configuration
@@ -93,7 +92,7 @@ With Gitlab Pipelines, the following configuration works:
#.gitlab-ci.yml #.gitlab-ci.yml
default: default:
image: image:
name: ghcr.io/davegallant/rfd-notify:1 name: ghcr.io/davegallant/rfd-notify:2
entrypoint: [""] entrypoint: [""]
run: 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"] ENTRYPOINT ["python", "/app/rfd_notify/cli.py", "-c", "config.yml"]

52
poetry.lock generated
View File

@@ -35,33 +35,33 @@ typing-extensions = {version = ">=4.0.0", markers = "python_version < \"3.11\""}
[[package]] [[package]]
name = "black" name = "black"
version = "24.8.0" version = "25.1.0"
description = "The uncompromising code formatter." description = "The uncompromising code formatter."
optional = false optional = false
python-versions = ">=3.8" python-versions = ">=3.9"
files = [ files = [
{file = "black-24.8.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:09cdeb74d494ec023ded657f7092ba518e8cf78fa8386155e4a03fdcc44679e6"}, {file = "black-25.1.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:759e7ec1e050a15f89b770cefbf91ebee8917aac5c20483bc2d80a6c3a04df32"},
{file = "black-24.8.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:81c6742da39f33b08e791da38410f32e27d632260e599df7245cccee2064afeb"}, {file = "black-25.1.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:0e519ecf93120f34243e6b0054db49c00a35f84f195d5bce7e9f5cfc578fc2da"},
{file = "black-24.8.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:707a1ca89221bc8a1a64fb5e15ef39cd755633daa672a9db7498d1c19de66a42"}, {file = "black-25.1.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:055e59b198df7ac0b7efca5ad7ff2516bca343276c466be72eb04a3bcc1f82d7"},
{file = "black-24.8.0-cp310-cp310-win_amd64.whl", hash = "sha256:d6417535d99c37cee4091a2f24eb2b6d5ec42b144d50f1f2e436d9fe1916fe1a"}, {file = "black-25.1.0-cp310-cp310-win_amd64.whl", hash = "sha256:db8ea9917d6f8fc62abd90d944920d95e73c83a5ee3383493e35d271aca872e9"},
{file = "black-24.8.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:fb6e2c0b86bbd43dee042e48059c9ad7830abd5c94b0bc518c0eeec57c3eddc1"}, {file = "black-25.1.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:a39337598244de4bae26475f77dda852ea00a93bd4c728e09eacd827ec929df0"},
{file = "black-24.8.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:837fd281f1908d0076844bc2b801ad2d369c78c45cf800cad7b61686051041af"}, {file = "black-25.1.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:96c1c7cd856bba8e20094e36e0f948718dc688dba4a9d78c3adde52b9e6c2299"},
{file = "black-24.8.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:62e8730977f0b77998029da7971fa896ceefa2c4c4933fcd593fa599ecbf97a4"}, {file = "black-25.1.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:bce2e264d59c91e52d8000d507eb20a9aca4a778731a08cfff7e5ac4a4bb7096"},
{file = "black-24.8.0-cp311-cp311-win_amd64.whl", hash = "sha256:72901b4913cbac8972ad911dc4098d5753704d1f3c56e44ae8dce99eecb0e3af"}, {file = "black-25.1.0-cp311-cp311-win_amd64.whl", hash = "sha256:172b1dbff09f86ce6f4eb8edf9dede08b1fce58ba194c87d7a4f1a5aa2f5b3c2"},
{file = "black-24.8.0-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:7c046c1d1eeb7aea9335da62472481d3bbf3fd986e093cffd35f4385c94ae368"}, {file = "black-25.1.0-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:4b60580e829091e6f9238c848ea6750efed72140b91b048770b64e74fe04908b"},
{file = "black-24.8.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:649f6d84ccbae73ab767e206772cc2d7a393a001070a4c814a546afd0d423aed"}, {file = "black-25.1.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:1e2978f6df243b155ef5fa7e558a43037c3079093ed5d10fd84c43900f2d8ecc"},
{file = "black-24.8.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:2b59b250fdba5f9a9cd9d0ece6e6d993d91ce877d121d161e4698af3eb9c1018"}, {file = "black-25.1.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:3b48735872ec535027d979e8dcb20bf4f70b5ac75a8ea99f127c106a7d7aba9f"},
{file = "black-24.8.0-cp312-cp312-win_amd64.whl", hash = "sha256:6e55d30d44bed36593c3163b9bc63bf58b3b30e4611e4d88a0c3c239930ed5b2"}, {file = "black-25.1.0-cp312-cp312-win_amd64.whl", hash = "sha256:ea0213189960bda9cf99be5b8c8ce66bb054af5e9e861249cd23471bd7b0b3ba"},
{file = "black-24.8.0-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:505289f17ceda596658ae81b61ebbe2d9b25aa78067035184ed0a9d855d18afd"}, {file = "black-25.1.0-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:8f0b18a02996a836cc9c9c78e5babec10930862827b1b724ddfe98ccf2f2fe4f"},
{file = "black-24.8.0-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:b19c9ad992c7883ad84c9b22aaa73562a16b819c1d8db7a1a1a49fb7ec13c7d2"}, {file = "black-25.1.0-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:afebb7098bfbc70037a053b91ae8437c3857482d3a690fefc03e9ff7aa9a5fd3"},
{file = "black-24.8.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:1f13f7f386f86f8121d76599114bb8c17b69d962137fc70efe56137727c7047e"}, {file = "black-25.1.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:030b9759066a4ee5e5aca28c3c77f9c64789cdd4de8ac1df642c40b708be6171"},
{file = "black-24.8.0-cp38-cp38-win_amd64.whl", hash = "sha256:f490dbd59680d809ca31efdae20e634f3fae27fba3ce0ba3208333b713bc3920"}, {file = "black-25.1.0-cp313-cp313-win_amd64.whl", hash = "sha256:a22f402b410566e2d1c950708c77ebf5ebd5d0d88a6a2e87c86d9fb48afa0d18"},
{file = "black-24.8.0-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:eab4dd44ce80dea27dc69db40dab62d4ca96112f87996bca68cd75639aeb2e4c"}, {file = "black-25.1.0-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:a1ee0a0c330f7b5130ce0caed9936a904793576ef4d2b98c40835d6a65afa6a0"},
{file = "black-24.8.0-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:3c4285573d4897a7610054af5a890bde7c65cb466040c5f0c8b732812d7f0e5e"}, {file = "black-25.1.0-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:f3df5f1bf91d36002b0a75389ca8663510cf0531cca8aa5c1ef695b46d98655f"},
{file = "black-24.8.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:9e84e33b37be070ba135176c123ae52a51f82306def9f7d063ee302ecab2cf47"}, {file = "black-25.1.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:d9e6827d563a2c820772b32ce8a42828dc6790f095f441beef18f96aa6f8294e"},
{file = "black-24.8.0-cp39-cp39-win_amd64.whl", hash = "sha256:73bbf84ed136e45d451a260c6b73ed674652f90a2b3211d6a35e78054563a9bb"}, {file = "black-25.1.0-cp39-cp39-win_amd64.whl", hash = "sha256:bacabb307dca5ebaf9c118d2d2f6903da0d62c9faa82bd21a33eecc319559355"},
{file = "black-24.8.0-py3-none-any.whl", hash = "sha256:972085c618ee94f402da1af548a4f218c754ea7e5dc70acb168bfaca4c2542ed"}, {file = "black-25.1.0-py3-none-any.whl", hash = "sha256:95e8176dae143ba9097f351d174fdaf0ccd29efb414b362ae3fd72bf0f710717"},
{file = "black-24.8.0.tar.gz", hash = "sha256:2500945420b6784c38b9ee885af039f5e7471ef284ab03fa35ecdde4688cd83f"}, {file = "black-25.1.0.tar.gz", hash = "sha256:33496d5cd1222ad73391352b4ae8da15253c5de89b93a80b3e2c8d9a19ec2666"},
] ]
[package.dependencies] [package.dependencies]
@@ -75,7 +75,7 @@ typing-extensions = {version = ">=4.0.1", markers = "python_version < \"3.11\""}
[package.extras] [package.extras]
colorama = ["colorama (>=0.4.3)"] colorama = ["colorama (>=0.4.3)"]
d = ["aiohttp (>=3.7.4)", "aiohttp (>=3.7.4,!=3.9.0)"] d = ["aiohttp (>=3.10)"]
jupyter = ["ipython (>=7.8.0)", "tokenize-rt (>=3.2.0)"] jupyter = ["ipython (>=7.8.0)", "tokenize-rt (>=3.2.0)"]
uvloop = ["uvloop (>=0.15.2)"] uvloop = ["uvloop (>=0.15.2)"]
@@ -725,4 +725,4 @@ dev = ["black (>=19.3b0)", "pytest (>=4.6.2)"]
[metadata] [metadata]
lock-version = "2.0" lock-version = "2.0"
python-versions = "^3.10" python-versions = "^3.10"
content-hash = "f34bb31c71d4f4c83f881c0f2d28b7dc616eacfee63de3d1fd18e97996ed123d" content-hash = "5aa566ddd905579ebaaa263114dbf1b5452b8d86c81e92ff58f8f54be1ce996f"

View File

@@ -1,6 +1,6 @@
[tool.poetry] [tool.poetry]
name = "rfd-notify" name = "rfd-notify"
version = "1.0.0" version = "2.0.0"
description = "get notified of deals based on regex" description = "get notified of deals based on regex"
authors = ["Dave Gallant <dave.gallant@gmail.com>"] authors = ["Dave Gallant <dave.gallant@gmail.com>"]
readme = "README.md" readme = "README.md"
@@ -15,7 +15,7 @@ apprise = "^1.7.1"
[tool.poetry.group.dev.dependencies] [tool.poetry.group.dev.dependencies]
pytest = "^8.0.0" pytest = "^8.0.0"
black = "^24.0.0" black = "^25.0.0"
pylint = "^3.0.3" pylint = "^3.0.3"
rope = "^1.11.0" rope = "^1.11.0"
mypy = "^1.8.0" mypy = "^1.8.0"

View File

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

View File

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