mirror of
https://github.com/davegallant/rfd-notify.git
synced 2025-08-05 08:13:39 +00:00
Remove html formatting in notifications to support other notification systems
This commit is contained in:
2
.github/workflows/push-container.yml
vendored
2
.github/workflows/push-container.yml
vendored
@@ -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}
|
||||||
|
@@ -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:
|
||||||
|
@@ -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"]
|
||||||
|
@@ -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"
|
||||||
|
@@ -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")
|
||||||
|
|
||||||
|
@@ -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
|
||||||
|
Reference in New Issue
Block a user