aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorclarkzjw <[email protected]>2023-02-22 14:01:16 -0800
committerclarkzjw <[email protected]>2023-02-23 12:07:26 -0800
commitae99c2d7237021e2abb20d4b41a24e0b73028519 (patch)
tree4c4a2a4d954a51148890d5bf589c938f24633f28 /callback.py
parent75b88bc06d354df64c12497330f124392fa7fc57 (diff)
downloadswarm2fediverse-ae99c2d7237021e2abb20d4b41a24e0b73028519.tar.gz
bot: support Mastodon OAuth2 login
test callback test mastodon callback test callback clean customwebhook example bot: test oauth login test callback url test callback
Diffstat (limited to 'callback.py')
-rw-r--r--callback.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/callback.py b/callback.py
index 2c69fbd..e7a8308 100644
--- a/callback.py
+++ b/callback.py
@@ -57,6 +57,21 @@ async def process_media_group(context: CallbackContext):
57 await context.bot.send_message(chat_id=chat_id, text=PROMPT_DONE, reply_markup=MAIN_MENU) 57 await context.bot.send_message(chat_id=chat_id, text=PROMPT_DONE, reply_markup=MAIN_MENU)
58 58
59 59
60async def callback_generate_fedi_login_url(update: Update, context: ContextTypes.DEFAULT_TYPE) -> int:
61 # generate fedi OAuth login url
62 home_instance = update.effective_message.text
63 mastodon_client = Mastodon(client_id=MASTODON_CLIENT_ID_FILE, api_base_url=home_instance)
64 oauth_url = mastodon_client.auth_request_url(redirect_uris="{}{}".format(BOT_DOMAIN, FEDI_LOGIN_CALLBACK_URL),
65 scopes=['write:media', 'write:statuses'],
66 state=update.effective_user.id)
67
68 await update.message.reply_text(PROMPT_FEDI_LOGIN,
69 reply_markup=InlineKeyboardMarkup([[InlineKeyboardButton("Login", url=oauth_url)]]),
70 parse_mode=ParseMode.MARKDOWN)
71
72 return FEDI_LOGIN
73
74
60async def callback_location_sharing(update: Update, context: ContextTypes.DEFAULT_TYPE) -> int: 75async def callback_location_sharing(update: Update, context: ContextTypes.DEFAULT_TYPE) -> int:
61 if update.message.venue is not None: 76 if update.message.venue is not None:
62 context.user_data["fsq_id"] = update.message.venue.foursquare_id 77 context.user_data["fsq_id"] = update.message.venue.foursquare_id
Powered by cgit v1.2.3 (git 2.41.0)