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}"
|
||||
|
||||
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"]
|
||||
|
@@ -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,29 +14,11 @@ 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