forked from ruangrupa/konfluks
centralise config in scripts
This commit is contained in:
parent
be3e14ac6c
commit
23e57d08c2
@ -15,7 +15,11 @@ from ics import Calendar
|
||||
from natural import date
|
||||
from slugify import slugify
|
||||
|
||||
from event_feed_config import calendar_url, output_dir
|
||||
# a publicly accessible ICS calendar
|
||||
calendar_url = os.environ.get("CALENDAR_URL", "")
|
||||
|
||||
# your Hugo content directory
|
||||
output_dir = os.environ.get("OUTPUT_DIR", "")
|
||||
|
||||
cal = Calendar(requests.get(calendar_url).text)
|
||||
|
||||
|
@ -11,18 +11,33 @@ import jinja2
|
||||
import requests
|
||||
from mastodon import Mastodon
|
||||
|
||||
import config_hashtag_bot
|
||||
# Which instance to login to
|
||||
instance = "https://social.lumbung.space"
|
||||
|
||||
# n.b. if it is the first time you use this script
|
||||
# You need to register the app:
|
||||
# https://mastodonpy.readthedocs.io/en/stable/#module-mastodon
|
||||
|
||||
# Login credentials for bot account
|
||||
email = ""
|
||||
password = ""
|
||||
|
||||
# Which hashtags to publish
|
||||
hashtags = ["jalansesama"]
|
||||
|
||||
# your Hugo content directory
|
||||
output_dir = os.environ.get("OUTPUT_DIR", "path/to/hugo/content")
|
||||
|
||||
|
||||
def login_mastodon_bot():
|
||||
mastodon = Mastodon(
|
||||
client_id="publishbot_clientcred.secret",
|
||||
api_base_url=config_hashtag_bot.instance,
|
||||
api_base_url=instance,
|
||||
)
|
||||
|
||||
mastodon.log_in(
|
||||
config_hashtag_bot.email,
|
||||
config_hashtag_bot.password,
|
||||
email,
|
||||
password,
|
||||
to_file="publishbot_usercred.secret",
|
||||
scopes=["read"],
|
||||
)
|
||||
@ -92,7 +107,7 @@ def filter_mastodon_urls(content):
|
||||
|
||||
mastodon = login_mastodon_bot()
|
||||
|
||||
output_dir = config_hashtag_bot.output_dir
|
||||
output_dir = output_dir
|
||||
|
||||
|
||||
env = jinja2.Environment(loader=jinja2.FileSystemLoader(os.path.curdir))
|
||||
@ -107,7 +122,7 @@ if not os.path.exists(output_dir):
|
||||
os.mkdir(output_dir)
|
||||
|
||||
|
||||
for hashtag in config_hashtag_bot.hashtags:
|
||||
for hashtag in hashtags:
|
||||
|
||||
hashtag_dir = os.path.join(output_dir, hashtag)
|
||||
if not os.path.exists(hashtag_dir):
|
||||
|
Loading…
Reference in New Issue
Block a user