From d328fc0a7b8b3ed32fcec0a9f9e4f461697b1196 Mon Sep 17 00:00:00 2001 From: lluni Date: Sat, 10 Dec 2022 00:46:15 +0100 Subject: [PATCH 1/3] Extracted subreddit into a new env variable --- .env.example | 1 + script.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.env.example b/.env.example index 5dbf49c..f3fe3df 100644 --- a/.env.example +++ b/.env.example @@ -4,6 +4,7 @@ REDDIT_AUTH_TOKEN="" REDDIT_REFRESH_TOKEN="" REDDIT_CLIENT_ID="" REDDIT_CLIENT_SECRET="" +REDDIT_SUBREDDIT="" MASTODON_URL="" MASTODON_EMAIL="" MASTODON_PASSWORD="" diff --git a/script.py b/script.py index ba7d157..450b6a2 100644 --- a/script.py +++ b/script.py @@ -26,7 +26,7 @@ mastodon = Mastodon( # get recent posts to check for duplicates last_posts = mastodon.account_statuses(getenv("MASTODON_USER_ID"), limit=15) -for submission in reddit.subreddit("ich_iel").top(time_filter="day", limit=10): +for submission in reddit.subreddit(str(getenv("REDDIT_SUBREDDIT"))).top(time_filter="day", limit=10): # skip post if it is a stickied post if (submission.stickied): continue From 8762852c8dd4b3c8c8656589b852ff8ec91c5340 Mon Sep 17 00:00:00 2001 From: lluni Date: Sat, 10 Dec 2022 00:47:44 +0100 Subject: [PATCH 2/3] Added some more example values in .env.example --- .env.example | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.env.example b/.env.example index f3fe3df..e93598f 100644 --- a/.env.example +++ b/.env.example @@ -4,11 +4,11 @@ REDDIT_AUTH_TOKEN="" REDDIT_REFRESH_TOKEN="" REDDIT_CLIENT_ID="" REDDIT_CLIENT_SECRET="" -REDDIT_SUBREDDIT="" +REDDIT_SUBREDDIT="ich_iel" MASTODON_URL="" -MASTODON_EMAIL="" -MASTODON_PASSWORD="" +MASTODON_EMAIL="mail@example.com" +MASTODON_PASSWORD="password" MASTODON_USER_ID="" -MASTODON_APP_NAME="" +MASTODON_APP_NAME="Reddit Mastodon Crossposter" MASTODON_USER_SECRET="usercred.secret" MASTODON_CLIENT_SECRET="clientcred.secret" From 4c3f56bf2b9fabf0d9c9ebb5bf8776afab72f522 Mon Sep 17 00:00:00 2001 From: lluni Date: Sat, 10 Dec 2022 00:49:03 +0100 Subject: [PATCH 3/3] Added env var disclaimer --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 04a3ad4..5253b50 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ 3. Initialize Mastodon.py with e.g. `masto.py` (please refer to the [Mastodon.py docs](https://mastodonpy.readthedocs.io)). -4. Set all `.env` variables if there are any remaining. +4. Set all `.env` variables if there are any remaining. (The code does not check for missing environment variables and assumes that everything is set correctly.) 5. Create a script `post_toots.sh` and make it executable `chmod +x post_toots.sh`: