Add some comments
This commit is contained in:
parent
091927de06
commit
f86e7f0a02
3 changed files with 21 additions and 11 deletions
12
masto.py
12
masto.py
|
@ -4,17 +4,20 @@ from dotenv import load_dotenv
|
|||
from mastodon import Mastodon
|
||||
from os import getenv
|
||||
|
||||
# load .env
|
||||
# ----- load .env ----- #
|
||||
|
||||
load_dotenv()
|
||||
|
||||
# register application
|
||||
# ----- register application ----- #
|
||||
|
||||
Mastodon.create_app(
|
||||
getenv("MASTODON_APP_NAME"),
|
||||
api_base_url = str(getenv("MASTODON_URL")),
|
||||
to_file = getenv("MASTODON_CLIENT_SECRET")
|
||||
)
|
||||
|
||||
# login
|
||||
# ----- login Mastodon account ----- #
|
||||
|
||||
mastodon = Mastodon(
|
||||
client_id = getenv("MASTODON_CLIENT_SECRET"),
|
||||
api_base_url = getenv("MASTODON_URL")
|
||||
|
@ -25,5 +28,6 @@ mastodon.log_in(
|
|||
to_file = getenv("MASTODON_USER_SECRET")
|
||||
)
|
||||
|
||||
# test toot
|
||||
# ----- post test toot ----- #
|
||||
|
||||
mastodon.toot("Hello World")
|
||||
|
|
|
@ -4,10 +4,12 @@ import praw
|
|||
from dotenv import load_dotenv
|
||||
from os import getenv
|
||||
|
||||
# load .env
|
||||
# ----- load .env ----- #
|
||||
|
||||
load_dotenv()
|
||||
|
||||
# initialize reddit
|
||||
# ----- initialize reddit ----- #
|
||||
|
||||
reddit = praw.Reddit(
|
||||
client_id = getenv("REDDIT_CLIENT_ID"),
|
||||
client_secret = getenv("REDDIT_CLIENT_SECRET"),
|
||||
|
|
|
@ -6,9 +6,12 @@ from mastodon import Mastodon
|
|||
from os import getenv, remove
|
||||
from os.path import getsize
|
||||
|
||||
# load .env
|
||||
# ----- load .env ----- #
|
||||
|
||||
load_dotenv()
|
||||
|
||||
# ----- initialization ----- #
|
||||
|
||||
# initialize reddit
|
||||
reddit = praw.Reddit(
|
||||
client_id = getenv("REDDIT_CLIENT_ID"),
|
||||
|
@ -23,6 +26,8 @@ mastodon = Mastodon(
|
|||
api_base_url = getenv("MASTODON_URL")
|
||||
)
|
||||
|
||||
# ----- main script ----- #
|
||||
|
||||
# get recent posts to check for duplicates
|
||||
last_posts = mastodon.account_statuses(getenv("MASTODON_USER_ID"), limit=15)
|
||||
|
||||
|
@ -68,4 +73,3 @@ for submission in reddit.subreddit(str(getenv("REDDIT_SUBREDDIT"))).top(time_fil
|
|||
mastodon.status_post(status_text, media_ids=media["id"], visibility="unlisted")
|
||||
remove(filename)
|
||||
break
|
||||
|
Loading…
Reference in a new issue