aboutsummaryrefslogtreecommitdiff
path: root/bot.py
diff options
context:
space:
mode:
authorclarkzjw <[email protected]>2023-02-23 16:46:25 -0800
committerclarkzjw <[email protected]>2023-02-23 16:46:25 -0800
commitaf56ead63269aff81c7b23251fca3ca650eb94fe (patch)
treeb7b9491817e83452f69750655fe240702ab44e0e /bot.py
parent20b8220a12fc92f95ecae267ce4eb5a80584f564 (diff)
parentb98b8bf3ced39afcb04e705d500cd5184d8b5254 (diff)
downloadswarm2fediverse-af56ead63269aff81c7b23251fca3ca650eb94fe.tar.gz
Merge branch 'feature/oauth-pleroma'
- 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.py8
1 files changed, 6 insertions, 2 deletions
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:
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
Powered by cgit v1.2.3 (git 2.41.0)