From b98b8bf3ced39afcb04e705d500cd5184d8b5254 Mon Sep 17 00:00:00 2001 From: clarkzjw Date: Thu, 23 Feb 2023 16:45:01 -0800 Subject: - bot: support pleroma instances - status_update() in mastodon.py currently doesn't support content_type, thus it still fallbacks to text/plain on pleroma instances when adding comments --- bot.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'bot.py') diff --git a/bot.py b/bot.py index 7d10ddd..6479460 100644 --- a/bot.py +++ b/bot.py @@ -99,12 +99,16 @@ async def process_oauth_login_callback(update: FediLoginCallbackUpdate, context: home_instance = user.home_instance if len(user.access_key) == 0: - mastodon_client = Mastodon(client_id=client_id, client_secret=client_secret, api_base_url=home_instance) + mastodon_client = Mastodon(client_id=client_id, client_secret=client_secret, + api_base_url=home_instance, version_check_mode="none") access_token = mastodon_client.log_in( code=update.code, redirect_uri="{}{}".format(BOT_DOMAIN, FEDI_LOGIN_CALLBACK_URL), scopes=BOT_SCOPE ) + instance_info = mastodon_client.instance_nodeinfo() + if instance_info["software"]["name"] == "pleroma": + user.home_instance_type = "pleroma" user.access_key = encrypt(access_token, ENCRYPT_KEY) user.save() @@ -207,7 +211,7 @@ async def main() -> None: app=starlette_app, port=BOT_PORT, use_colors=False, - host="127.0.0.1", + host="100.93.242.2", ) ) -- cgit v1.2.3