From 317b72f178a23a85384b8beef8315fe79a1b699b Mon Sep 17 00:00:00 2001 From: Hugh Rundle Date: Mon, 16 Sep 2024 09:08:29 +1000 Subject: [PATCH] clean up --- README.md | 4 ++-- get_party.sh | 2 +- latest_post.txt | 0 webhook.py | 10 +++++----- 4 files changed, 8 insertions(+), 8 deletions(-) create mode 100644 latest_post.txt diff --git a/README.md b/README.md index 2e122ad..7c078f6 100644 --- a/README.md +++ b/README.md @@ -51,6 +51,6 @@ There are also a couple of other things we need to do: ## RSS feed -The rss feed is `https://newcardigan.org/category/cardiparties/?feed=cardipartyfeed`. +The rss feed is `https://newcardigan.org/category/cardiparties/?feed=featured_image_feed`. -This special `cardipartyfeed` is a slightly modified RSS2 feed. The only thing it does differently is filter out everything that isn't a cardiparty ,and include the featured image in an `enclosure` so that we can pick it up directly from the feed. See the newcardigan WordPress theme for how this works. \ No newline at end of file +This special `featured_image_feed` is a slightly modified RSS2 feed. The only thing it does differently is include the featured image in an `enclosure` so that we can pick it up directly from the feed. See the newcardigan WordPress theme for how this works. \ No newline at end of file diff --git a/get_party.sh b/get_party.sh index 7fda6c0..6fe167b 100755 --- a/get_party.sh +++ b/get_party.sh @@ -4,7 +4,7 @@ export PATH=/home/cardigan/rss-discord-bot/venv/bin:usr/local/bin:usr/bin: source /home/cardigan/rss-discord-bot/venv/bin/activate export CIVICRM_SETTINGS="/var/www/html/wp-content/uploads/civicrm/civicrm.settings.php" -export DISCORD_SERVER="" +export DISCORD_GUILD="" export DISCORD_TOKEN="" export DISCORD_CARDIPARTY_PING="" diff --git a/latest_post.txt b/latest_post.txt new file mode 100644 index 0000000..e69de29 diff --git a/webhook.py b/webhook.py index 35281fd..5e9666a 100755 --- a/webhook.py +++ b/webhook.py @@ -8,12 +8,12 @@ import sys import feedparser import requests -dc_server = os.getenv("DISCORD_SERVER") # this is actually the instance, not a channel +guild = os.getenv("DISCORD_GUILD") # the Discord server/guild id token = os.getenv("DISCORD_TOKEN") # token for this bot cardiparty_ping = os.getenv("DISCORD_CARDIPARTY_PING") # get the latest cardiparty with image as enclosure -f = feedparser.parse("https://newcardigan.org/category/cardiparties/?feed=cardipartyfeed") +f = feedparser.parse("https://newcardigan.org/category/cardiparties/?feed=featured_image_feed") first = f.entries[0] # check whether we have already seen this entry with open("latest_post.txt", "r+") as f: @@ -48,7 +48,7 @@ if guid != first.guid: }] headers = {'user-agent': 'cardiParty-discord-bot/1.0.0'} - url = f"https://discord.com/api/webhooks/{dc_server}/{token}" + url = f"https://discord.com/api/webhooks/{guild}/{token}" payload = { "thread_name": f"{first.title} | {title}", "content": content, @@ -57,5 +57,5 @@ if guid != first.guid: } r = requests.post(url, json=payload, headers=headers) - print(r) - r.raise_for_status() # if we got a 4xx response this will log it + print(datetime.now().isoformat(' '), r) + r.raise_for_status() # if we got a 4xx response