From 390becef63b3d306d8e4efd703a09042125bf147 Mon Sep 17 00:00:00 2001 From: Camille Frantz Date: Fri, 22 Sep 2023 20:10:01 -0500 Subject: [PATCH] initial --- .nova/Configuration.json | 4 ++++ README.md | 13 +++++++++++++ main.py | 40 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 57 insertions(+) create mode 100644 .nova/Configuration.json create mode 100644 README.md create mode 100644 main.py diff --git a/.nova/Configuration.json b/.nova/Configuration.json new file mode 100644 index 0000000..6c1367f --- /dev/null +++ b/.nova/Configuration.json @@ -0,0 +1,4 @@ +{ + "workspace.color" : 2, + "workspace.name" : "release tracker bot" +} diff --git a/README.md b/README.md new file mode 100644 index 0000000..600c7b3 --- /dev/null +++ b/README.md @@ -0,0 +1,13 @@ +# fedi platform release bot + +this program will run at a pre-defined interval to check for releases on the following platform repositories: + +- mastodon +- firefish +- hometown +- akkoma +- gotosocial + +other repositories can and will be added later. + +once a new release is discovered, the link and title will be posted to discord in a channel that can be subscribed to from other places. \ No newline at end of file diff --git a/main.py b/main.py new file mode 100644 index 0000000..c0aab65 --- /dev/null +++ b/main.py @@ -0,0 +1,40 @@ +import dotenv +import requests +from discord import SyncWebhook +from datetime import datetime as dt + +# initialise variables +new_ts = dt.now() +old_ts = '' + +# read in old timestamp if it exists +try: + old_ts = open('last_check','r').read() +except: + pass +# load in the relevant .env variables +dotenv.load_dotenv() +conf = dotenv.dotenv_valules() + +# list with urls to check +the_urls = [ + 'https://github.com/mastodon/mastodon/releases.atom', + 'https://github.com/hometown-fork/hometown/releases.atom', + 'https://git.joinfirefish.org/firefish/firefish/-/releases', + 'https://akkoma.dev/AkkomaGang/akkoma/releases', + 'https://github.com/superseriousbusiness/gotosocial/releases' +] + +discord_user = conf['DISCORD_USERNAME'] +dicord_webhook_url = conf['DISCORD_WEBHOOK_TEST'] +webhook = SyncWebhook.from_url(conf['DISCORD_WEBHOOK_TEST']) + +# test the last release date against the last check date: +# if old_ts.rstrip() != '' and {{release_date}} > old_ts.rstrip(): +# post +# else: +# break + +# write out current check timestamp to file for next check. +with open('last_check','w') as last_check: + print(ts.year + ts.month + ts.day + ts.hour + ts.minute + ts.second, file=last_check)