diff options
author | clarkzjw <[email protected]> | 2023-02-23 16:45:01 -0800 |
---|---|---|
committer | clarkzjw <[email protected]> | 2023-02-23 16:46:12 -0800 |
commit | b98b8bf3ced39afcb04e705d500cd5184d8b5254 (patch) | |
tree | b7b9491817e83452f69750655fe240702ab44e0e /bot.py | |
parent | 20b8220a12fc92f95ecae267ce4eb5a80584f564 (diff) | |
download | swarm2fediverse-b98b8bf3ced39afcb04e705d500cd5184d8b5254.tar.gz |
- 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
Diffstat (limited to 'bot.py')
-rw-r--r-- | bot.py | 8 |
1 files changed, 6 insertions, 2 deletions
@@ -99,12 +99,16 @@ async def process_oauth_login_callback(update: FediLoginCallbackUpdate, context: | |||
99 | home_instance = user.home_instance | 99 | home_instance = user.home_instance |
100 | 100 | ||
101 | if len(user.access_key) == 0: | 101 | if len(user.access_key) == 0: |
102 | mastodon_client = Mastodon(client_id=client_id, client_secret=client_secret, api_base_url=home_instance) | 102 | mastodon_client = Mastodon(client_id=client_id, client_secret=client_secret, |
103 | api_base_url=home_instance, version_check_mode="none") | ||
103 | access_token = mastodon_client.log_in( | 104 | access_token = mastodon_client.log_in( |
104 | code=update.code, | 105 | code=update.code, |
105 | redirect_uri="{}{}".format(BOT_DOMAIN, FEDI_LOGIN_CALLBACK_URL), | 106 | redirect_uri="{}{}".format(BOT_DOMAIN, FEDI_LOGIN_CALLBACK_URL), |
106 | scopes=BOT_SCOPE | 107 | scopes=BOT_SCOPE |
107 | ) | 108 | ) |
109 | instance_info = mastodon_client.instance_nodeinfo() | ||
110 | if instance_info["software"]["name"] == "pleroma": | ||
111 | user.home_instance_type = "pleroma" | ||
108 | user.access_key = encrypt(access_token, ENCRYPT_KEY) | 112 | user.access_key = encrypt(access_token, ENCRYPT_KEY) |
109 | user.save() | 113 | user.save() |
110 | 114 | ||
@@ -207,7 +211,7 @@ async def main() -> None: | |||
207 | app=starlette_app, | 211 | app=starlette_app, |
208 | port=BOT_PORT, | 212 | port=BOT_PORT, |
209 | use_colors=False, | 213 | use_colors=False, |
210 | host="127.0.0.1", | 214 | host="100.93.242.2", |
211 | ) | 215 | ) |
212 | ) | 216 | ) |
213 | 217 | ||