piratebot/main.py

29 lines
1.3 KiB
Python
Executable File

#!/usr/bin/env python3
# Copyright (C) 2020 Lynne (@lynnesbian@fedi.lynnesbian.space)
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
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)