mirror of
https://github.com/davegallant/rfd-notify.git
synced 2025-08-14 12:10:19 +00:00
Compare commits
2 Commits
bf20aa2b6c
...
67c1b24a25
Author | SHA1 | Date | |
---|---|---|---|
|
67c1b24a25 | ||
|
9a4a12bf54 |
2
.github/workflows/push-container.yml
vendored
2
.github/workflows/push-container.yml
vendored
@@ -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}
|
||||
|
@@ -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:
|
||||
|
@@ -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"]
|
||||
|
20
poetry.lock
generated
20
poetry.lock
generated
@@ -21,13 +21,13 @@ requests-oauthlib = "*"
|
||||
|
||||
[[package]]
|
||||
name = "astroid"
|
||||
version = "3.2.4"
|
||||
version = "3.3.8"
|
||||
description = "An abstract syntax tree for Python with inference support."
|
||||
optional = false
|
||||
python-versions = ">=3.8.0"
|
||||
python-versions = ">=3.9.0"
|
||||
files = [
|
||||
{file = "astroid-3.2.4-py3-none-any.whl", hash = "sha256:413658a61eeca6202a59231abb473f932038fbcbf1666587f66d482083413a25"},
|
||||
{file = "astroid-3.2.4.tar.gz", hash = "sha256:0e14202810b30da1b735827f78f5157be2bbd4a7a59b7707ca0bfc2fb4c0063a"},
|
||||
{file = "astroid-3.3.8-py3-none-any.whl", hash = "sha256:187ccc0c248bfbba564826c26f070494f7bc964fd286b6d9fff4420e55de828c"},
|
||||
{file = "astroid-3.3.8.tar.gz", hash = "sha256:a88c7994f914a4ea8572fac479459f4955eeccc877be3f2d959a33273b0cf40b"},
|
||||
]
|
||||
|
||||
[package.dependencies]
|
||||
@@ -453,24 +453,24 @@ testing = ["pytest", "pytest-benchmark"]
|
||||
|
||||
[[package]]
|
||||
name = "pylint"
|
||||
version = "3.2.6"
|
||||
version = "3.3.4"
|
||||
description = "python code static checker"
|
||||
optional = false
|
||||
python-versions = ">=3.8.0"
|
||||
python-versions = ">=3.9.0"
|
||||
files = [
|
||||
{file = "pylint-3.2.6-py3-none-any.whl", hash = "sha256:03c8e3baa1d9fb995b12c1dbe00aa6c4bcef210c2a2634374aedeb22fb4a8f8f"},
|
||||
{file = "pylint-3.2.6.tar.gz", hash = "sha256:a5d01678349454806cff6d886fb072294f56a58c4761278c97fb557d708e1eb3"},
|
||||
{file = "pylint-3.3.4-py3-none-any.whl", hash = "sha256:289e6a1eb27b453b08436478391a48cd53bb0efb824873f949e709350f3de018"},
|
||||
{file = "pylint-3.3.4.tar.gz", hash = "sha256:74ae7a38b177e69a9b525d0794bd8183820bfa7eb68cc1bee6e8ed22a42be4ce"},
|
||||
]
|
||||
|
||||
[package.dependencies]
|
||||
astroid = ">=3.2.4,<=3.3.0-dev0"
|
||||
astroid = ">=3.3.8,<=3.4.0-dev0"
|
||||
colorama = {version = ">=0.4.5", markers = "sys_platform == \"win32\""}
|
||||
dill = [
|
||||
{version = ">=0.2", markers = "python_version < \"3.11\""},
|
||||
{version = ">=0.3.7", markers = "python_version >= \"3.12\""},
|
||||
{version = ">=0.3.6", markers = "python_version >= \"3.11\" and python_version < \"3.12\""},
|
||||
]
|
||||
isort = ">=4.2.5,<5.13.0 || >5.13.0,<6"
|
||||
isort = ">=4.2.5,<5.13.0 || >5.13.0,<7"
|
||||
mccabe = ">=0.6,<0.8"
|
||||
platformdirs = ">=2.2.0"
|
||||
tomli = {version = ">=1.1.0", markers = "python_version < \"3.11\""}
|
||||
|
@@ -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"
|
||||
|
@@ -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")
|
||||
|
||||
|
@@ -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
|
||||
|
Reference in New Issue
Block a user