21 lines
670 B
Python
21 lines
670 B
Python
import requests
|
|
|
|
|
|
class WebhookNotifier:
|
|
def __init__(self, webhook_url, disable_webhook=False):
|
|
self.webhook_url = webhook_url
|
|
self.disable_webhook = disable_webhook
|
|
|
|
def send_notification(self, submission):
|
|
title = submission.title
|
|
url = submission.url
|
|
permalink = submission.permalink
|
|
selftext = submission.selftext
|
|
content = f"""
|
|
**New Deal!**
|
|
**Title:** {title}
|
|
**URL:** {url}
|
|
**Permalink:** https://old.reddit.com{permalink}
|
|
**Selftext:** {selftext}"""
|
|
if not self.disable_webhook:
|
|
requests.post(self.webhook_url, data={"content": content}) |