piratebot/main.py

21 lines
943 B
Python
Executable File

#!/usr/bin/env python3
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
from mastodon import Mastodon
from os import path
scopes = ["read:statuses", "read:accounts", "read:follows", "write:statuses"]
if not path.exists("clientcred.secret"):
print("No clientcred.secret, registering application")
Mastodon.create_app("piratebot", api_base_url="https://botsin.space", to_file="clientcred.secret", scopes=scopes, website="https://lynnesbian.space")
if not path.exists("usercred.secret"):
print("No usercred.secret, registering application")
client = Mastodon(client_id="clientcred.secret", api_base_url="https://botsin.space")
print("Visit this url:")
print(client.auth_request_url(scopes=scopes))
client.log_in(code=input("Secret: "), to_file="usercred.secret", scopes=scopes)