From a0d9a89997de2eafb1c12b6b3e32879739aca484 Mon Sep 17 00:00:00 2001 From: nanos Date: Mon, 6 Mar 2023 12:51:46 +0000 Subject: [PATCH] Update get_context.py --- get_context.py | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/get_context.py b/get_context.py index c89563f..7485e73 100644 --- a/get_context.py +++ b/get_context.py @@ -388,31 +388,26 @@ class OrderedSet: if __name__ == "__main__": HELP_MESSAGE = """ -Usage: ACCESS_TOKEN=XXXX python3 pull_context.py +Usage: python3 pull_context.py -To run this script, set the ACCESS_TOKEN environment variable to your -Mastodon access token. The access token can be generated at +The access token can be generated at https:///settings/applications, and must have read:search, read:statuses and admin:read:accounts scopes. """ - try: - ACCESS_TOKEN = os.environ["ACCESS_TOKEN"] - except KeyError: - print("ACCESS_TOKEN environment variable not set.") + + + if len(sys.argv) < 5: print(HELP_MESSAGE) sys.exit(1) - if len(sys.argv) < 4: - print(HELP_MESSAGE) - sys.exit(1) - - SERVER = sys.argv[1] - REPLY_INTERVAL_IN_HOURS = int(sys.argv[2]) + ACCESS_TOKEN = sys.argv[2] + SERVER = sys.argv[2] + REPLY_INTERVAL_IN_HOURS = int(sys.argv[3]) SEEN_URLS_FILE = "artifacts/seen_urls" REPLIED_TOOT_SERVER_IDS_FILE = "artifacts/replied_toot_server_ids" - MAX_HOME_TIMELINE_LENGTH = int(sys.argv[3]) + MAX_HOME_TIMELINE_LENGTH = int(sys.argv[4]) SEEN_URLS = OrderedSet([]) if os.path.exists(SEEN_URLS_FILE): @@ -437,4 +432,4 @@ read:statuses and admin:read:accounts scopes. f.write("\n".join(list(SEEN_URLS)[:10000])) with open(REPLIED_TOOT_SERVER_IDS_FILE, "w", encoding="utf-8") as f: - json.dump(dict(list(REPLIED_TOOT_SERVER_IDS.items())[:10000]), f) \ No newline at end of file + json.dump(dict(list(REPLIED_TOOT_SERVER_IDS.items())[:10000]), f)