add support for other mastodon-api compatible fedi servers

workspace
Brendan Howell 4 years ago
parent 96ba564525
commit 3065a671b4

@ -51,22 +51,23 @@ class PublicRelations(Bureau):
self.auth = twitter.OAuth(oauth_token, oauth_secret, CK, CS)
self.t.t = twitter.Twitter(auth=self.auth)
# TODO: expand config to have other masto servers
MASTO_CREDS = os.path.expanduser('~/.screenless/masto_creds')
if not os.path.exists(MASTO_CREDS):
Mastodon.create_app('screenless',
api_base_url='https://mastodon.social',
to_file=MASTO_CREDS)
# TODO: catch the error when our token is too old and throw it out
self.masto = Mastodon(client_id=MASTO_CREDS,
api_base_url='https://mastodon.social')
try:
MASTO_CREDS = os.path.expanduser('~/.screenless/masto_creds')
masto_server = self.config["mastodon"]["server"]
if not os.path.exists(MASTO_CREDS):
Mastodon.create_app('screenless',
api_base_url=masto_server,
to_file=MASTO_CREDS)
# TODO: catch the error when our token is too old and throw it out
self.masto = Mastodon(client_id=MASTO_CREDS,
api_base_url=masto_server)
masto_user = self.config["mastodon"]["user"]
masto_pass = self.config["mastodon"]["password"]
self.masto.log_in(masto_user, masto_pass)
except KeyError:
print("no mastodon config found.")
print("you can add a 'mastodon:' section to PR.yml with:")
print(" server: my.server.name")
print(" user: myuser")
print(" password: mypassword")
print("skipping masto login for now...")

Loading…
Cancel
Save